|
1346 | 1346 | *file-defs*
|
1347 | 1347 | (get @*file-defs* sym))
|
1348 | 1348 | (warning :redef-in-file env {:sym sym :line (:line v)})))
|
1349 |
| - (when *file-defs* |
1350 |
| - (swap! *file-defs* conj sym)) |
1351 | 1349 | (let [env (if (or (and (not= ns-name 'cljs.core)
|
1352 | 1350 | (core-name? env sym))
|
1353 | 1351 | (some? (get-in @env/*compiler* [::namespaces ns-name :uses sym])))
|
|
1380 | 1378 | (when (and (not (-> sym meta :declared))
|
1381 | 1379 | (and (true? (:fn-var v)) (not fn-var?)))
|
1382 | 1380 | (warning :fn-var env {:ns-name ns-name :sym sym})))
|
1383 |
| - (swap! env/*compiler* assoc-in [::namespaces ns-name :defs sym] |
1384 |
| - (merge |
1385 |
| - {:name var-name} |
1386 |
| - ;; remove actual test metadata, as it includes non-valid EDN and |
1387 |
| - ;; cannot be present in analysis cached to disk - David |
1388 |
| - (cond-> sym-meta |
1389 |
| - (:test sym-meta) (assoc :test true)) |
1390 |
| - {:meta (-> sym-meta |
1391 |
| - (dissoc :test) |
1392 |
| - (update-in [:file] |
1393 |
| - (fn [f] |
1394 |
| - (if (= (-> env :ns :name) 'cljs.core) |
1395 |
| - "cljs/core.cljs" |
1396 |
| - f))))} |
1397 |
| - (when doc {:doc doc}) |
1398 |
| - (when const? |
1399 |
| - (let [const-expr |
1400 |
| - (binding [*passes* (conj *passes* (replace-env-pass {:context :expr}))] |
1401 |
| - (analyze env (:init args)))] |
1402 |
| - (when (constant-value? const-expr) |
1403 |
| - {:const-expr const-expr}))) |
1404 |
| - (when (true? dynamic) {:dynamic true}) |
1405 |
| - (source-info var-name env) |
1406 |
| - ;; the protocol a protocol fn belongs to |
1407 |
| - (when protocol |
1408 |
| - {:protocol protocol}) |
1409 |
| - ;; symbol for reified protocol |
1410 |
| - (when-let [protocol-symbol (-> sym meta :protocol-symbol)] |
1411 |
| - {:protocol-symbol protocol-symbol |
1412 |
| - :info (-> protocol-symbol meta :protocol-info) |
1413 |
| - :impls #{}}) |
1414 |
| - (when fn-var? |
1415 |
| - (let [params (map #(vec (map :name (:params %))) (:methods init-expr))] |
1416 |
| - (merge |
1417 |
| - {:fn-var (not (:macro sym-meta)) |
1418 |
| - ;; protocol implementation context |
1419 |
| - :protocol-impl (:protocol-impl init-expr) |
1420 |
| - ;; inline protocol implementation context |
1421 |
| - :protocol-inline (:protocol-inline init-expr)} |
1422 |
| - (if-some [top-fn-meta (:top-fn sym-meta)] |
1423 |
| - top-fn-meta |
1424 |
| - {:variadic (:variadic init-expr) |
1425 |
| - :max-fixed-arity (:max-fixed-arity init-expr) |
1426 |
| - :method-params params |
1427 |
| - :arglists (:arglists sym-meta) |
1428 |
| - :arglists-meta (doall (map meta (:arglists sym-meta)))})))) |
1429 |
| - (if (and fn-var? (some? tag)) |
1430 |
| - {:ret-tag tag} |
1431 |
| - (when tag {:tag tag})))) |
| 1381 | + |
| 1382 | + ;; declare must not replace any analyzer data of an already def'd sym |
| 1383 | + (when (or (nil? (get-in @env/*compiler* [::namespaces ns-name :defs sym])) |
| 1384 | + (not (:declared sym-meta))) |
| 1385 | + (when *file-defs* |
| 1386 | + (swap! *file-defs* conj sym)) |
| 1387 | + |
| 1388 | + (swap! env/*compiler* assoc-in [::namespaces ns-name :defs sym] |
| 1389 | + (merge |
| 1390 | + {:name var-name} |
| 1391 | + ;; remove actual test metadata, as it includes non-valid EDN and |
| 1392 | + ;; cannot be present in analysis cached to disk - David |
| 1393 | + (cond-> sym-meta |
| 1394 | + (:test sym-meta) (assoc :test true)) |
| 1395 | + {:meta (-> sym-meta |
| 1396 | + (dissoc :test) |
| 1397 | + (update-in [:file] |
| 1398 | + (fn [f] |
| 1399 | + (if (= (-> env :ns :name) 'cljs.core) |
| 1400 | + "cljs/core.cljs" |
| 1401 | + f))))} |
| 1402 | + (when doc {:doc doc}) |
| 1403 | + (when const? |
| 1404 | + (let [const-expr |
| 1405 | + (binding [*passes* (conj *passes* (replace-env-pass {:context :expr}))] |
| 1406 | + (analyze env (:init args)))] |
| 1407 | + (when (constant-value? const-expr) |
| 1408 | + {:const-expr const-expr}))) |
| 1409 | + (when (true? dynamic) {:dynamic true}) |
| 1410 | + (source-info var-name env) |
| 1411 | + ;; the protocol a protocol fn belongs to |
| 1412 | + (when protocol |
| 1413 | + {:protocol protocol}) |
| 1414 | + ;; symbol for reified protocol |
| 1415 | + (when-let [protocol-symbol (-> sym meta :protocol-symbol)] |
| 1416 | + {:protocol-symbol protocol-symbol |
| 1417 | + :info (-> protocol-symbol meta :protocol-info) |
| 1418 | + :impls #{}}) |
| 1419 | + (when fn-var? |
| 1420 | + (let [params (map #(vec (map :name (:params %))) (:methods init-expr))] |
| 1421 | + (merge |
| 1422 | + {:fn-var (not (:macro sym-meta)) |
| 1423 | + ;; protocol implementation context |
| 1424 | + :protocol-impl (:protocol-impl init-expr) |
| 1425 | + ;; inline protocol implementation context |
| 1426 | + :protocol-inline (:protocol-inline init-expr)} |
| 1427 | + (if-some [top-fn-meta (:top-fn sym-meta)] |
| 1428 | + top-fn-meta |
| 1429 | + {:variadic (:variadic init-expr) |
| 1430 | + :max-fixed-arity (:max-fixed-arity init-expr) |
| 1431 | + :method-params params |
| 1432 | + :arglists (:arglists sym-meta) |
| 1433 | + :arglists-meta (doall (map meta (:arglists sym-meta)))})))) |
| 1434 | + (if (and fn-var? (some? tag)) |
| 1435 | + {:ret-tag tag} |
| 1436 | + (when tag {:tag tag}))))) |
1432 | 1437 | (merge
|
1433 | 1438 | {:env env
|
1434 | 1439 | :op :def
|
|
0 commit comments