Skip to content

Type-hinting a shadowed this inside a proxy method crashes the compiler #9

@skydread1

Description

@skydread1

Problem

Inside a proxy method, binding this to a type-hinted local crashes the analyzer. For example:

(proxy [System.IO.StringWriter] []
  (Flush [] (let [^System.IO.StringWriter this this]
              (proxy-super Flush))))

fails with Could not invoke zero arity member 'BaseType' ...: the compiler calls .BaseType on the AST binding node instead of a Type. This is the ClojureCLR proxy-super idiom, and valid Clojure that ClojureCLR compiles.

Suggestion

In magic/analyzer/types.clj (ast-type-impl :local) and the proxy rewrite in magic/analyzer/typed_passes.clj (around lines 360-400), treat this as :proxy-this only when the resolved binding has :local :proxy-this; let a shadowing :local :let binding fall through to normal tag resolution. Gate any change on the magic.test.proxy and magic.test.reify suites.

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions