Skip to content

Commit 273bcd3

Browse files
anmonteirodnolen
authored andcommitted
CLJS-1607: bug with specify! in JS prototypes with static-fns true
1 parent 1589e58 commit 273bcd3

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

src/main/clojure/cljs/compiler.cljc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -933,7 +933,7 @@
933933
;; ignore new type hints for now - David
934934
(and (not (set? tag))
935935
(not ('#{any clj clj-or-nil clj-nil number string boolean function object array} tag))
936-
(when-let [ps (:protocols (ana/resolve-existing-var (dissoc env :locals) tag))]
936+
(when-let [ps (:protocols (ana/resolve-existing-var env (symbol (name tag))))]
937937
(ps protocol)))))))
938938
opt-not? (and (= (:name info) 'cljs.core/not)
939939
(= (ana/infer-tag env (first (:args expr))) 'boolean))

src/test/clojure/cljs/compiler_tests.clj

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,39 @@
147147
`(cljs.user/foo ~(tags/->JSValue []))
148148
'(cljs.user/foo (make-array 0))))))
149149

150+
;; CLJS-1607
151+
152+
(deftest test-cljs-1607
153+
(let [define-Foo #(assoc-in % [::ana/namespaces 'cljs.user :defs 'Foo]
154+
{:ns 'cljs.user
155+
:name 'cljs.user/Foo
156+
:protocol-symbol true
157+
:protocol-info {:methods '{foo [[this]]}}
158+
:protocol 'cljs.user/Foo})
159+
define-foo #(assoc-in % [::ana/namespaces 'cljs.user :defs 'foo]
160+
{:ns 'cljs.user
161+
:name 'cljs.user/foo
162+
:fn-var true
163+
:method-params '([x])
164+
:protocol 'cljs.user/Foo})
165+
aenv-with-foo (-> aenv define-foo define-Foo)
166+
cenv-with-foo (-> @cenv define-foo define-Foo)]
167+
(binding [ana/*cljs-static-fns* true]
168+
(are [form]
169+
(empty?
170+
(capture-warnings
171+
(env/with-compiler-env (atom cenv-with-foo)
172+
(with-out-str
173+
(comp/emit
174+
(ana/analyze aenv-with-foo form))))))
175+
'(specify! []
176+
cljs.user/Foo
177+
(cljs.user/foo [this]
178+
:none)
179+
Object
180+
(bar [this]
181+
(cljs.user/foo this)))))))
182+
150183
;; CLJS-1225
151184

152185
(comment

0 commit comments

Comments
 (0)