Skip to content

Commit 5cd08b4

Browse files
committed
CLJS-2862: Externs inference warning when extending Object
extend-type macro modifies the prototype with one helper. Just add meta to the returned form and check that case in 'set! analysis.
1 parent 7b4bd89 commit 5cd08b4

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

src/main/clojure/cljs/analyzer.cljc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2514,7 +2514,13 @@
25142514

25152515
:else
25162516
(when (seq? target)
2517-
(let [texpr (analyze-seq enve target nil)]
2517+
(let [texpr (if (-> target meta :extend-type)
2518+
;; we're setting a prototype via extend-type macro
2519+
;; nothing to warn
2520+
(binding [*cljs-warnings*
2521+
(assoc *cljs-warnings* :infer-warning false)]
2522+
(analyze-seq enve target nil))
2523+
(analyze-seq enve target nil))]
25182524
(when (:field texpr)
25192525
texpr))))
25202526
vexpr (analyze enve val)]

src/main/clojure/cljs/core.cljc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1461,7 +1461,8 @@
14611461
[tsym sym] `(.. ~tsym ~(to-property sym)))
14621462

14631463
(core/defmethod extend-prefix :default
1464-
[tsym sym] `(.. ~tsym ~'-prototype ~(to-property sym)))
1464+
[tsym sym]
1465+
(with-meta `(.. ~tsym ~'-prototype ~(to-property sym)) {:extend-type true}))
14651466

14661467
(core/defn- adapt-obj-params [type [[this & args :as sig] & body]]
14671468
(core/list (vec args)

src/test/clojure/cljs/externs_infer_tests.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
[cljs.test-util :refer [unsplit-lines]]
1010
[cljs.util :as util]
1111
[clojure.string :as string]
12-
[clojure.test :refer [is are deftest testing]]))
12+
[clojure.test :as test :refer [is are deftest testing]]))
1313

1414
(def externs-cenv
1515
(atom

0 commit comments

Comments
 (0)