@@ -5860,9 +5860,8 @@ static FnMethod parse(ObjExpr objx, ISeq form, Object rettag) {
5860
5860
method .line = lineDeref ();
5861
5861
method .column = columnDeref ();
5862
5862
//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 ;
5866
5865
Var .pushThreadBindings (
5867
5866
RT .mapUniqueKeys (
5868
5867
METHOD , method ,
@@ -6306,6 +6305,7 @@ abstract public static class ObjMethod{
6306
6305
boolean usesThis = false ;
6307
6306
PersistentHashSet localsUsedInCatchFinally = PersistentHashSet .EMPTY ;
6308
6307
protected IPersistentMap methodMeta ;
6308
+ PathNode clearRoot ;
6309
6309
6310
6310
6311
6311
public final IPersistentMap locals (){
@@ -6560,12 +6560,20 @@ public LocalBindingExpr(LocalBinding b, Symbol tag)
6560
6560
}
6561
6561
}
6562
6562
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 )
6564
6568
{
6565
6569
this .shouldClear = true ;
6566
6570
sites = RT .conj (sites ,this );
6567
6571
CLEAR_SITES .set (RT .assoc (CLEAR_SITES .get (), b , sites ));
6568
6572
}
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
+ }
6569
6577
// else
6570
6578
// dummy = null;
6571
6579
}
@@ -8062,7 +8070,6 @@ static void closeOver(LocalBinding b, ObjMethod method){
8062
8070
}
8063
8071
}
8064
8072
8065
-
8066
8073
static LocalBinding referenceLocal (Symbol sym ) {
8067
8074
if (!LOCAL_ENV .isBound ())
8068
8075
return null ;
@@ -8967,7 +8974,8 @@ static NewInstanceMethod parse(ObjExpr objx, ISeq form, Symbol thistag,
8967
8974
method .line = lineDeref ();
8968
8975
method .column = columnDeref ();
8969
8976
//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 ;
8971
8979
Var .pushThreadBindings (
8972
8980
RT .mapUniqueKeys (
8973
8981
METHOD , method ,
0 commit comments