@@ -31,7 +31,7 @@ trait Stable212Base extends CrossCompatibility { self: SemanticRule =>
31
31
val foldLeftSymbol = foldSymbol(isLeft = true )
32
32
val foldRightSymbol = foldSymbol(isLeft = false )
33
33
34
- val iterator = normalized( " _root_.scala.collection.TraversableLike.toIterator. " )
34
+
35
35
val toTpe = normalized(
36
36
" _root_.scala.collection.TraversableLike.to." ,
37
37
" _root_.scala.collection.TraversableOnce.to." ,
@@ -73,6 +73,7 @@ trait Stable212Base extends CrossCompatibility { self: SemanticRule =>
73
73
" _root_.scala.collection.immutable.TreeSet#until(Ljava/lang/Object;)Lscala/collection/immutable/TreeSet;."
74
74
)
75
75
76
+ val `TraversableLike.toIterator` = normalized(" _root_.scala.collection.TraversableLike.toIterator." )
76
77
val traversableOnce = exact(
77
78
" _root_.scala.collection.TraversableOnce#" ,
78
79
" _root_.scala.package.TraversableOnce#"
@@ -98,6 +99,13 @@ trait Stable212Base extends CrossCompatibility { self: SemanticRule =>
98
99
}
99
100
100
101
def replaceTraversable (ctx : RuleCtx ): Patch = {
102
+
103
+ val traversableIterator =
104
+ ctx.tree.collect {
105
+ case `TraversableLike.toIterator`(t : Name ) =>
106
+ ctx.replaceTree(t, " iterator" )
107
+ }.asPatch
108
+
101
109
val traversableToIterable =
102
110
ctx.replaceSymbols(
103
111
" scala.Traversable" -> " scala.Iterable" ,
@@ -122,10 +130,10 @@ trait Stable212Base extends CrossCompatibility { self: SemanticRule =>
122
130
}.asPatch
123
131
124
132
val compatImport =
125
- if (traversableOnceToIterableOnce.nonEmpty) addCompatImport(ctx)
133
+ if (traversableOnceToIterableOnce.nonEmpty || traversableIterator.nonEmpty ) addCompatImport(ctx)
126
134
else Patch .empty
127
135
128
- traversableOnceToIterableOnce + traversableToIterable + compatImport
136
+ traversableOnceToIterableOnce + traversableToIterable + traversableIterator + compatImport
129
137
}
130
138
131
139
def replaceSymbolicFold (ctx : RuleCtx ): Patch = {
@@ -256,14 +264,8 @@ trait Stable212Base extends CrossCompatibility { self: SemanticRule =>
256
264
}
257
265
}
258
266
259
- def replaceToList (ctx : RuleCtx ): Patch = {
260
- val replaceToIterator =
261
- ctx.tree.collect {
262
- case iterator(t : Name ) =>
263
- ctx.replaceTree(t, " iterator" )
264
- }.asPatch
265
-
266
- val replaceTo =
267
+ def replaceTo (ctx : RuleCtx ): Patch = {
268
+ val patch =
267
269
ctx.tree.collect {
268
270
case Term .ApplyType (Term .Select (_, t @ toTpe(n : Name )), _) if ! handledTo.contains(n) =>
269
271
trailingBrackets(n, ctx).map { case (open, close) =>
@@ -291,10 +293,10 @@ trait Stable212Base extends CrossCompatibility { self: SemanticRule =>
291
293
}.asPatch
292
294
293
295
val compatImport =
294
- if (replaceTo .nonEmpty) addCompatImport(ctx)
296
+ if (patch .nonEmpty) addCompatImport(ctx)
295
297
else Patch .empty
296
298
297
- compatImport + replaceToIterator + replaceTo
299
+ compatImport + patch
298
300
}
299
301
300
302
def replaceFuture (ctx : RuleCtx ): Patch = {
@@ -573,7 +575,7 @@ trait Stable212Base extends CrossCompatibility { self: SemanticRule =>
573
575
override def fix (ctx : RuleCtx ): Patch = {
574
576
replaceTraversable(ctx) +
575
577
replaceCanBuildFrom(ctx) +
576
- replaceToList (ctx) +
578
+ replaceTo (ctx) +
577
579
replaceCopyToBuffer(ctx) +
578
580
replaceSymbolicFold(ctx) +
579
581
replaceSetMapPlus2(ctx) +
0 commit comments