Skip to content

Commit d91207c

Browse files
mfikesswannodette
authored andcommitted
CLJS-2790: Externs inference warnings for defrecord fields
Applies the same solution to supress access to the other object's __extmap in the IEquiv implementation (adding a type tag) to generated accessors to the other object's fields.
1 parent 44379a6 commit d91207c

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

Diff for: src/main/clojure/cljs/core.cljc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1816,7 +1816,7 @@
18161816
(.-constructor ~other))
18171817
~@(map (core/fn [field]
18181818
`(= (.. ~this ~(to-property field))
1819-
(.. ~other ~(to-property field))))
1819+
(.. ~(with-meta other {:tag tagname}) ~(to-property field))))
18201820
base-fields)
18211821
(= (.-__extmap ~this)
18221822
(.-__extmap ~(with-meta other {:tag tagname}))))))

Diff for: src/test/clojure/cljs/analyzer_tests.clj

+11
Original file line numberDiff line numberDiff line change
@@ -1096,3 +1096,14 @@
10961096
:with-core? true})]
10971097
(is (empty? @ws))
10981098
(is (not (string/includes? res "cljs.core")))))
1099+
1100+
(deftest test-cljs-2790-defrecord-fields
1101+
(let [ws (atom [])
1102+
res (infer-test-helper
1103+
{:forms '[(ns cjls-2790.core)
1104+
(defrecord Foo [a b])]
1105+
:externs ["src/test/externs/test.js"]
1106+
:warnings ws
1107+
:with-core? true})]
1108+
(is (empty? @ws))
1109+
(is (not (string/includes? res "cljs.core")))))

0 commit comments

Comments
 (0)