@@ -106,15 +106,15 @@ private static CollectionWrite collectionWrite(AssignmentStatement assignment, E
106106 if (collection .is (Kind .SLICE_EXPR , Kind .SUBSCRIPTION )) {
107107 CollectionWrite nested = collectionWrite (assignment , collection );
108108 if (nested != null ) {
109- return new CollectionWrite (nested .collectionKey .nest (key ), nested .leftBracket , rBracket , assignment );
109+ return new CollectionWrite (nested .collectionKey .nest (key ), nested .leftBracket , rBracket , assignment , collection );
110110 }
111111 }
112112
113113 if (collection instanceof HasSymbol ) {
114114 Symbol symbol = ((HasSymbol ) collection ).symbol ();
115115 if (symbol != null ) {
116116 CollectionKey collectionKey = new CollectionKey (symbol , key );
117- return new CollectionWrite (collectionKey , lBracket , rBracket , assignment );
117+ return new CollectionWrite (collectionKey , lBracket , rBracket , assignment , collection );
118118 }
119119 }
120120
@@ -163,8 +163,7 @@ private static void reportOverwrites(SubscriptionContext ctx, Map<CollectionKey,
163163 CollectionWrite firstWrite = writes .get (0 );
164164 CollectionWrite secondWrite = writes .get (1 );
165165 AssignmentStatement assignment = secondWrite .assignment ;
166- Expression lhs = lhs (assignment );
167- if (TreeUtils .hasDescendant (assignment .assignedValue (), t -> CheckUtils .areEquivalent (lhs , t ))) {
166+ if (TreeUtils .hasDescendant (assignment .assignedValue (), t -> CheckUtils .areEquivalent (firstWrite .collection , t ))) {
168167 return ;
169168 }
170169 String message = String .format (
@@ -192,12 +191,14 @@ private static class CollectionWrite {
192191 private final Token leftBracket ;
193192 private final Token rightBracket ;
194193 private final AssignmentStatement assignment ;
194+ private final Expression collection ;
195195
196- private CollectionWrite (CollectionKey collectionKey , Token leftBracket , Token rightBracket , AssignmentStatement assignment ) {
196+ private CollectionWrite (CollectionKey collectionKey , Token leftBracket , Token rightBracket , AssignmentStatement assignment , Expression collection ) {
197197 this .collectionKey = collectionKey ;
198198 this .leftBracket = leftBracket ;
199199 this .rightBracket = rightBracket ;
200200 this .assignment = assignment ;
201+ this .collection = collection ;
201202 }
202203 }
203204}
0 commit comments