Skip to content

Commit

Permalink
flow type hints on static invoke calls
Browse files Browse the repository at this point in the history
  • Loading branch information
richhickey committed Jun 10, 2010
1 parent d4239d0 commit 9ad685b
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/jvm/clojure/lang/Compiler.java
Expand Up @@ -2843,15 +2843,17 @@ static class StaticInvokeExpr implements Expr, MaybePrimitiveExpr{
public final Type[] paramtypes;
public final IPersistentVector args;
public final boolean variadic;
public final Symbol tag;

StaticInvokeExpr(Type target, Class retClass, Class[] paramclasses, Type[] paramtypes, boolean variadic,
IPersistentVector args){
IPersistentVector args,Symbol tag){
this.target = target;
this.retClass = retClass;
this.paramclasses = paramclasses;
this.paramtypes = paramtypes;
this.args = args;
this.variadic = variadic;
this.tag = tag;
}

public Object eval() throws Exception{
Expand All @@ -2876,7 +2878,7 @@ public boolean hasJavaClass() throws Exception{
}

public Class getJavaClass() throws Exception{
return retClass;
return tag != null ? HostExpr.tagToClass(tag) : retClass;
}

public boolean canEmitPrimitive(){
Expand Down Expand Up @@ -2921,7 +2923,7 @@ private Type getReturnType(){
return Type.getType(retClass);
}

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

return new StaticInvokeExpr(target,retClass,paramClasses.toArray(new Class[paramClasses.size()]),
paramTypes.toArray(new Type[paramTypes.size()]),variadic, argv);
paramTypes.toArray(new Type[paramTypes.size()]),variadic, argv, tag);
}
}

Expand Down Expand Up @@ -3208,7 +3210,7 @@ static public Expr parse(C context, ISeq form) throws Exception{
Var v = ((VarExpr)fexpr).var;
if(RT.booleanCast(RT.get(RT.meta(v),staticKey)))
{
return StaticInvokeExpr.parse(v, RT.next(form));
return StaticInvokeExpr.parse(v, RT.next(form), tagOf(form));
}
}

Expand Down

0 comments on commit 9ad685b

Please sign in to comment.