@@ -29,6 +29,12 @@ case class Scalacollectioncompat_newcollections(index: SemanticdbIndex)
29
29
Symbol (" _root_.scala.runtime.Tuple2Zipped.Ops.zipped." ),
30
30
Symbol (" _root_.scala.runtime.Tuple3Zipped.Ops.zipped." )
31
31
)
32
+ val mutSetPlus = SymbolMatcher .exact(
33
+ Symbol (" _root_.scala.collection.mutable.SetLike#`+`(Ljava/lang/Object;)Lscala/collection/mutable/Set;." )
34
+ )
35
+ val mutMapPlus = SymbolMatcher .exact(
36
+ Symbol (" _root_.scala.collection.mutable.MapLike#`+`(Lscala/Tuple2;)Lscala/collection/mutable/Map;." )
37
+ )
32
38
def foldSymbol (isLeft : Boolean ): SymbolMatcher = {
33
39
val op =
34
40
if (isLeft) " /:"
@@ -156,6 +162,21 @@ case class Scalacollectioncompat_newcollections(index: SemanticdbIndex)
156
162
ctx.replaceTree(t, " lazyAppendedAll" )
157
163
}.asPatch
158
164
165
+ def replaceMutSetMapPlus (ctx : RuleCtx ): Patch = {
166
+ def rewriteMutPlus (lhs : Term , op : Term .Name ): Patch = {
167
+ ctx.addRight(lhs, " .clone()" ) +
168
+ ctx.addRight(op, " =" )
169
+ }
170
+
171
+ ctx.tree.collect {
172
+ case Term .ApplyInfix (lhs, op @ mutSetPlus(_), _, List (_)) =>
173
+ rewriteMutPlus(lhs, op)
174
+
175
+ case Term .ApplyInfix (lhs, op @ mutMapPlus(_), _, List (_)) =>
176
+ rewriteMutPlus(lhs, op)
177
+ }.asPatch
178
+ }
179
+
159
180
override def fix (ctx : RuleCtx ): Patch = {
160
181
// println(ctx.index.database)
161
182
@@ -166,6 +187,7 @@ case class Scalacollectioncompat_newcollections(index: SemanticdbIndex)
166
187
replaceStreamAppend(ctx) +
167
188
replaceMutableMap(ctx) +
168
189
replaceMutableSet(ctx) +
169
- replaceSymbolicFold(ctx)
190
+ replaceSymbolicFold(ctx) +
191
+ replaceMutSetMapPlus(ctx)
170
192
}
171
193
}
0 commit comments