Skip to content

Commit 6a6e4e3

Browse files
committed
CLJS-3236: defprotocol externs inference warnings
in defprotocol macro mark protocol properties, ignore them
1 parent 017d0f9 commit 6a6e4e3

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/main/clojure/cljs/analyzer.cljc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3351,7 +3351,8 @@
33513351
;; (. (...) -p)
33523352
(defmethod build-dot-form [::expr ::property ()]
33533353
[[target prop _]]
3354-
{:dot-action ::access :target target :field (-> prop name (.substring 1) symbol)})
3354+
{:dot-action ::access :target target
3355+
:field (with-meta (-> prop name (.substring 1) symbol) (meta prop))})
33553356

33563357
;; (. o -p <args>)
33573358
(defmethod build-dot-form [::expr ::property ::list]
@@ -3410,7 +3411,8 @@
34103411
update-in [:prefix] (fnil conj '[Object]) prop))
34113412
nil)]
34123413
(when (and (not= 'constructor prop)
3413-
(not (string/starts-with? (str prop) "cljs$")))
3414+
(not (string/starts-with? (str prop) "cljs$"))
3415+
(not (-> prop meta :protocol-method)))
34143416
;; Adding to Object
34153417
(when (= 'Object (first (-> tag meta :prefix)))
34163418
(warning :infer-warning env

src/main/clojure/cljs/core.cljc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2109,7 +2109,8 @@
21092109
;; check protocol property on object (first check executed)
21102110
check
21112111
`(if (and (not (nil? ~fsig))
2112-
(not (nil? (. ~fsig ~(symbol (core/str "-" slot)))))) ;; Property access needed here.
2112+
;; Property access needed here.
2113+
(not (nil? (. ~fsig ~(with-meta (symbol (core/str "-" slot)) {:protocol-method true})))))
21132114
(. ~fsig ~slot ~@sig)
21142115
(~dyn-name ~@sig))]
21152116
`(~sig ~check)))
@@ -2160,7 +2161,8 @@
21602161
(defn ~fname
21612162
~@(map (core/fn [sig]
21622163
(expand-sig dyn-name
2163-
(symbol (core/str slot "$arity$" (count sig)))
2164+
(with-meta (symbol (core/str slot "$arity$" (count sig)))
2165+
{:protocol-method true})
21642166
sig))
21652167
sigs)))))]
21662168
`(do

0 commit comments

Comments
 (0)