Skip to content

Commit 9ad685b

Browse files
committed
flow type hints on static invoke calls
1 parent d4239d0 commit 9ad685b

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/jvm/clojure/lang/Compiler.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2843,15 +2843,17 @@ static class StaticInvokeExpr implements Expr, MaybePrimitiveExpr{
28432843
public final Type[] paramtypes;
28442844
public final IPersistentVector args;
28452845
public final boolean variadic;
2846+
public final Symbol tag;
28462847

28472848
StaticInvokeExpr(Type target, Class retClass, Class[] paramclasses, Type[] paramtypes, boolean variadic,
2848-
IPersistentVector args){
2849+
IPersistentVector args,Symbol tag){
28492850
this.target = target;
28502851
this.retClass = retClass;
28512852
this.paramclasses = paramclasses;
28522853
this.paramtypes = paramtypes;
28532854
this.args = args;
28542855
this.variadic = variadic;
2856+
this.tag = tag;
28552857
}
28562858

28572859
public Object eval() throws Exception{
@@ -2876,7 +2878,7 @@ public boolean hasJavaClass() throws Exception{
28762878
}
28772879

28782880
public Class getJavaClass() throws Exception{
2879-
return retClass;
2881+
return tag != null ? HostExpr.tagToClass(tag) : retClass;
28802882
}
28812883

28822884
public boolean canEmitPrimitive(){
@@ -2921,7 +2923,7 @@ private Type getReturnType(){
29212923
return Type.getType(retClass);
29222924
}
29232925

2924-
public static Expr parse(Var v, ISeq args) throws Exception{
2926+
public static Expr parse(Var v, ISeq args, Symbol tag) throws Exception{
29252927
IPersistentCollection paramlists = (IPersistentCollection) RT.get(v.meta(), arglistsKey);
29262928
if(paramlists == null)
29272929
throw new IllegalStateException("Can't call static fn with no arglists: " + v);
@@ -2987,7 +2989,7 @@ else if(alist.count() == argcount)
29872989
argv = argv.cons(analyze(C.EXPRESSION, s.first()));
29882990

29892991
return new StaticInvokeExpr(target,retClass,paramClasses.toArray(new Class[paramClasses.size()]),
2990-
paramTypes.toArray(new Type[paramTypes.size()]),variadic, argv);
2992+
paramTypes.toArray(new Type[paramTypes.size()]),variadic, argv, tag);
29912993
}
29922994
}
29932995

@@ -3208,7 +3210,7 @@ static public Expr parse(C context, ISeq form) throws Exception{
32083210
Var v = ((VarExpr)fexpr).var;
32093211
if(RT.booleanCast(RT.get(RT.meta(v),staticKey)))
32103212
{
3211-
return StaticInvokeExpr.parse(v, RT.next(form));
3213+
return StaticInvokeExpr.parse(v, RT.next(form), tagOf(form));
32123214
}
32133215
}
32143216

0 commit comments

Comments
 (0)