@@ -3745,6 +3745,7 @@ static public class FnExpr extends ObjExpr{
3745
3745
IPersistentCollection methods ;
3746
3746
private boolean hasPrimSigs ;
3747
3747
private boolean hasMeta ;
3748
+ private boolean hasEnclosingMethod ;
3748
3749
// String superName = null;
3749
3750
3750
3751
public FnExpr (Object tag ){
@@ -3790,6 +3791,7 @@ static Expr parse(C context, ISeq form, String name) {
3790
3791
FnExpr fn = new FnExpr (tagOf (form ));
3791
3792
fn .src = form ;
3792
3793
ObjMethod enclosingMethod = (ObjMethod ) METHOD .deref ();
3794
+ fn .hasEnclosingMethod = enclosingMethod != null ;
3793
3795
if (((IMeta ) form .first ()).meta () != null )
3794
3796
{
3795
3797
fn .onceOnly = RT .booleanCast (RT .get (RT .meta (form .first ()), Keyword .intern (null , "once" )));
@@ -3936,18 +3938,20 @@ public final IPersistentCollection methods(){
3936
3938
}
3937
3939
3938
3940
public void emitForDefn (ObjExpr objx , GeneratorAdapter gen ){
3939
- // if(!hasPrimSigs && closes.count() == 0)
3940
- // {
3941
- // Type thunkType = Type.getType(FnLoaderThunk.class);
3942
- //// presumes var on stack
3943
- // gen.dup();
3944
- // gen.newInstance(thunkType);
3945
- // gen.dupX1();
3946
- // gen.swap();
3947
- // gen.push(internalName.replace('/','.'));
3948
- // gen.invokeConstructor(thunkType,Method.getMethod("void <init>(clojure.lang.Var,String)"));
3949
- // }
3950
- // else
3941
+ if (!hasEnclosingMethod && !hasPrimSigs && closes .count () == 0 )
3942
+ {
3943
+ String iname = internalName .replace ('/' ,'.' );
3944
+ // System.out.println("emit var for defn: " + name + ", iname: " + iname);
3945
+ Type thunkType = Type .getType (FnLoaderThunk .class );
3946
+ // presumes var on stack
3947
+ gen .dup ();
3948
+ gen .newInstance (thunkType );
3949
+ gen .dupX1 ();
3950
+ gen .swap ();
3951
+ gen .push (iname );
3952
+ gen .invokeConstructor (thunkType ,Method .getMethod ("void <init>(clojure.lang.Var,String)" ));
3953
+ }
3954
+ else
3951
3955
emit (C .EXPRESSION ,objx ,gen );
3952
3956
}
3953
3957
}
0 commit comments