Skip to content

Commit 088d539

Browse files
committed
bind reused fields
1 parent 6c148a6 commit 088d539

File tree

1 file changed

+52
-50
lines changed

1 file changed

+52
-50
lines changed

typed/clj.analyzer/src/typed/clj/analyzer/passes/analyze_host_expr.cljc

Lines changed: 52 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -163,53 +163,55 @@
163163
A :host-interop node represents either an instance-field or a no-arg instance-method. "
164164
{:pass-info {:walk :post :depends #{}}}
165165
[ast opts]
166-
(case (:op ast)
167-
(:host-interop :host-call :host-field)
168-
(let [target (:target ast)
169-
tag (:tag ast)
170-
env (:env ast)
171-
target (if-let [the-class (and (= :local (:op target))
172-
(u/maybe-class-literal (:form target)))]
173-
(merge target
174-
(assoc (ana/analyze-const the-class env :class opts)
175-
:tag #?(:cljr Type :default Class)
176-
:o-tag #?(:cljr Type :default Class)))
177-
target)
178-
class? (and (= :const (:op target))
179-
(= :class (:type target))
180-
(:form target))
181-
target-type (if class? :static :instance)]
182-
(merge' (dissoc ast :assignable? :target :args :children)
183-
(case (:op ast)
184-
185-
:host-call
186-
(analyze-host-call target-type (:method ast)
187-
(:args ast) target class? env)
188-
189-
:host-field
190-
(analyze-host-field target-type (:field ast)
191-
target (or class? (:tag target)) env)
192-
193-
:host-interop
194-
(-analyze-host-expr target-type (:m-or-f ast)
195-
target class? env))
196-
(when tag
197-
{:tag tag})))
198-
:var
199-
(let [form (:form ast)
200-
env (:env ast)]
201-
(if-let [the-class (and (not (namespace form))
202-
(pos? (#?(:cljr .IndexOf :default .indexOf) (str form) "."))
203-
(u/maybe-class-literal form))]
204-
(assoc (ana/analyze-const the-class env :class opts) :form form)
205-
ast))
206-
207-
:maybe-class
208-
(let [form (:form ast)
209-
env (:env ast)
210-
class (:class ast)]
211-
(if-let [the-class (u/maybe-class-literal class)]
212-
(assoc (ana/analyze-const the-class env :class opts) :form form)
213-
ast))
214-
215-
ast))
166+
(let [op (:op ast)]
167+
(case op
168+
(:host-interop :host-call :host-field)
169+
(let [target (:target ast)
170+
tag (:tag ast)
171+
env (:env ast)
172+
target-op (:op target)
173+
target (if-let [the-class (and (= :local target-op)
174+
(u/maybe-class-literal (:form target)))]
175+
(merge target
176+
(assoc (ana/analyze-const the-class env :class opts)
177+
:tag #?(:cljr Type :default Class)
178+
:o-tag #?(:cljr Type :default Class)))
179+
target)
180+
class? (and (= :const target-op)
181+
(= :class (:type target))
182+
(:form target))
183+
target-type (if class? :static :instance)]
184+
(merge' (dissoc ast :assignable? :target :args :children)
185+
(case op
186+
187+
:host-call
188+
(analyze-host-call target-type (:method ast)
189+
(:args ast) target class? env)
190+
191+
:host-field
192+
(analyze-host-field target-type (:field ast)
193+
target (or class? (:tag target)) env)
194+
195+
:host-interop
196+
(-analyze-host-expr target-type (:m-or-f ast)
197+
target class? env))
198+
(when tag
199+
{:tag tag})))
200+
:var
201+
(let [form (:form ast)
202+
env (:env ast)]
203+
(if-let [the-class (and (not (namespace form))
204+
(pos? (#?(:cljr .IndexOf :default .indexOf) (str form) "."))
205+
(u/maybe-class-literal form))]
206+
(assoc (ana/analyze-const the-class env :class opts) :form form)
207+
ast))
208+
209+
:maybe-class
210+
(let [form (:form ast)
211+
env (:env ast)
212+
class (:class ast)]
213+
(if-let [the-class (u/maybe-class-literal class)]
214+
(assoc (ana/analyze-const the-class env :class opts) :form form)
215+
ast))
216+
217+
ast)))

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy