Skip to content

Commit 552aad0

Browse files
committed
not a field access if there are param-tags
1 parent 6973437 commit 552aad0

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/jvm/clojure/lang/Compiler.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -4372,7 +4372,9 @@ static public Expr parse(C context, ISeq form) {
43724372
Class c = ((StaticFieldExpr) fexpr).c;
43734373
String name = ((StaticFieldExpr) fexpr).fieldName;
43744374

4375-
if (RT.count(args) == 0 && QualifiedMethodExpr.methodsWithName(c, name, QualifiedMethodExpr.MethodKind.STATIC).isEmpty())
4375+
if (RT.count(args) == 0
4376+
// && ((form.first() instanceof Symbol) && (paramTagsOf((Symbol)form.first()) == null))
4377+
&& QualifiedMethodExpr.methodsWithName(c, name, QualifiedMethodExpr.MethodKind.STATIC).isEmpty())
43764378
return fexpr;
43774379
else {
43784380
Symbol sym = Symbol.intern(c.getName(), name);
@@ -7838,7 +7840,7 @@ private static Expr analyzeSymbol(Symbol sym) {
78387840
Class c = HostExpr.maybeClass(nsSym, false);
78397841
if(c != null)
78407842
{
7841-
if(Reflector.getField(c, sym.name, true) != null)
7843+
if((paramTagsOf(sym) == null) && (Reflector.getField(c, sym.name, true) != null))
78427844
return new StaticFieldExpr(lineDeref(), columnDeref(), c, sym.name, tag);
78437845
else
78447846
return new QualifiedMethodExpr(c, sym);

test/clojure/test_clojure/param_tags.clj

+2-1
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,9 @@
175175
(is (= "" (clojure.test.SwissArmy/doppelganger))) ;; favor 0-arity call over unwrap static field bug
176176
(is (= "int-int" (clojure.test.SwissArmy/.doppelganger (clojure.test.SwissArmy/new) (int 1) (int 2))))
177177
(is (= "int-int" (apply clojure.test.SwissArmy/.doppelganger (clojure.test.SwissArmy/new) (int 1) (int 2) [])))
178-
;; Can't distinguish field vs static method in value position
178+
;; Can't distinguish field vs static method in value position w/o param-tags
179179
;; (is (= "int-int-long" (apply clojure.test.SwissArmy/doppelganger (int 1) (int 2) (long 42) [])))
180+
(is (= "" (apply ^[] clojure.test.SwissArmy/doppelganger [])))
180181
(is (= "int-int-long" (clojure.test.SwissArmy/doppelganger (int 1) (int 2) (long 42)))))
181182

182183
(defmacro arg-tags-called-in-macro

0 commit comments

Comments
 (0)