Skip to content

Commit dee62ab

Browse files
committed
detector for new clearing
1 parent 7f23606 commit dee62ab

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

src/jvm/clojure/lang/Compiler.java

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5860,9 +5860,8 @@ static FnMethod parse(ObjExpr objx, ISeq form, Object rettag) {
58605860
method.line = lineDeref();
58615861
method.column = columnDeref();
58625862
//register as the current method and set up a new env frame
5863-
PathNode pnode = (PathNode) CLEAR_PATH.get();
5864-
if(pnode == null)
5865-
pnode = new PathNode(PATHTYPE.PATH,null);
5863+
PathNode pnode = new PathNode(PATHTYPE.PATH,null);
5864+
method.clearRoot = pnode;
58665865
Var.pushThreadBindings(
58675866
RT.mapUniqueKeys(
58685867
METHOD, method,
@@ -6306,6 +6305,7 @@ abstract public static class ObjMethod{
63066305
boolean usesThis = false;
63076306
PersistentHashSet localsUsedInCatchFinally = PersistentHashSet.EMPTY;
63086307
protected IPersistentMap methodMeta;
6308+
PathNode clearRoot;
63096309

63106310

63116311
public final IPersistentMap locals(){
@@ -6560,12 +6560,20 @@ public LocalBindingExpr(LocalBinding b, Symbol tag)
65606560
}
65616561
}
65626562

6563-
if(clearRoot == b.clearPathRoot)
6563+
ObjMethod method = ((ObjMethod) METHOD.deref());
6564+
boolean closedOver = method.objx.closes.containsKey(b);
6565+
boolean oldd = clearRoot == b.clearPathRoot;
6566+
boolean newd = closedOver && (clearRoot == method.clearRoot);
6567+
if (oldd || newd)
65646568
{
65656569
this.shouldClear = true;
65666570
sites = RT.conj(sites,this);
65676571
CLEAR_SITES.set(RT.assoc(CLEAR_SITES.get(), b, sites));
65686572
}
6573+
if (!oldd && newd && method.objx.onceOnly) {
6574+
RT.errPrintWriter().format("%s:%d closed-over %s improperly retained\n",
6575+
currentNS(), lineDeref(), b.sym);
6576+
}
65696577
// else
65706578
// dummy = null;
65716579
}
@@ -8062,7 +8070,6 @@ static void closeOver(LocalBinding b, ObjMethod method){
80628070
}
80638071
}
80648072

8065-
80668073
static LocalBinding referenceLocal(Symbol sym) {
80678074
if(!LOCAL_ENV.isBound())
80688075
return null;
@@ -8967,7 +8974,8 @@ static NewInstanceMethod parse(ObjExpr objx, ISeq form, Symbol thistag,
89678974
method.line = lineDeref();
89688975
method.column = columnDeref();
89698976
//register as the current method and set up a new env frame
8970-
PathNode pnode = new PathNode(PATHTYPE.PATH, (PathNode) CLEAR_PATH.get());
8977+
PathNode pnode = new PathNode(PATHTYPE.PATH, null);
8978+
method.clearRoot = pnode;
89718979
Var.pushThreadBindings(
89728980
RT.mapUniqueKeys(
89738981
METHOD, method,

0 commit comments

Comments
 (0)