Skip to content

Commit 8838bb9

Browse files
committed
we need to erase the prefix after a method call we don't the return type for, add test
1 parent ca57179 commit 8838bb9

2 files changed

Lines changed: 18 additions & 7 deletions

File tree

src/main/clojure/cljs/analyzer.cljc

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2627,17 +2627,21 @@
26272627
nil)]
26282628
(when (and (not (string/starts-with? (str prop) "cljs$"))
26292629
(not= 'js target-tag))
2630+
;; Cannot determine type of the target
26302631
(when (and (get-in env [:locals target])
26312632
(or (nil? target-tag)
26322633
('#{any} target-tag)))
26332634
(warning :infer-warning env
26342635
{:warn-type :target :form form}))
2635-
(let [[pre' pre] ((juxt (comp butlast butlast) identity) ;; drop prototype from pre'
2636+
;; Unresolveable property on existing extern
2637+
(let [[pre' pre] ((juxt butlast identity) ;; drop prototype from pre'
26362638
(-> tag meta :prefix))]
26372639
(when (and (has-extern? pre') (not (has-extern? pre)))
26382640
(warning :infer-warning env
26392641
{:warn-type :property :form form
2640-
:type (symbol "js" (string/join "." pre'))
2642+
:type (symbol "js"
2643+
(string/join "."
2644+
(cond-> pre' (= 'prototype (last pre')) butlast)))
26412645
:property prop}))))
26422646
(when (js-tag? tag)
26432647
(let [pre (-> tag meta :prefix)]
@@ -2665,7 +2669,7 @@
26652669
:args argexprs
26662670
:children children
26672671
:tag (if (js-tag? tag)
2668-
(or (js-tag (-> tag meta :prefix) :ret-tag) tag)
2672+
(or (js-tag (-> tag meta :prefix) :ret-tag) 'js)
26692673
tag)}))))
26702674

26712675
(defmethod parse '.

src/test/clojure/cljs/analyzer_tests.clj

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -676,10 +676,17 @@
676676
(a/analyze (a/empty-env) '(def foo (js/woz)))))
677677
:tag)))
678678
(is (= 'js
679-
(-> (binding [a/*cljs-ns* a/*cljs-ns*]
680-
(e/with-compiler-env externs-cenv
681-
(a/analyze (a/empty-env) '(def foo js/boz))))
682-
:tag))))
679+
(-> (binding [a/*cljs-ns* a/*cljs-ns*]
680+
(e/with-compiler-env externs-cenv
681+
(a/analyze (a/empty-env) '(def foo js/boz))))
682+
:tag)))
683+
(is (nil? (-> (binding [a/*cljs-ns* a/*cljs-ns*]
684+
(a/no-warn
685+
(e/with-compiler-env externs-cenv
686+
(a/analyze (a/empty-env)
687+
'(let [z (.baz ^js/Foo.Bar x)]
688+
z)))))
689+
:tag meta :prefix))))
683690

684691
(comment
685692
(require '[cljs.compiler :as cc])

0 commit comments

Comments
 (0)