File tree 1 file changed +11
-7
lines changed
scalafix/rules/src/main/scala/fix
1 file changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -45,17 +45,21 @@ trait Stable212Base extends CrossCompatibility { self: SemanticRule =>
45
45
val traversable = exact(
46
46
" _root_.scala.package.Traversable#" ,
47
47
" _root_.scala.collection.Traversable#" ,
48
- " _root_.scala.package.Iterable#" ,
49
- " _root_.scala.collection.Iterable#"
50
48
)
51
49
52
50
// == Rules ==
53
-
54
51
def replaceIterableSameElements (ctx : RuleCtx ): Patch = {
55
- ctx.tree.collect {
56
- case Term .Apply (Term .Select (lhs, iterableSameElement(_)), List (_)) =>
57
- ctx.addRight(lhs, " .iterator" )
58
- }.asPatch
52
+ val sameElements =
53
+ ctx.tree.collect {
54
+ case Term .Apply (Term .Select (lhs, iterableSameElement(_)), List (_)) =>
55
+ ctx.addRight(lhs, " .iterator" )
56
+ }.asPatch
57
+
58
+ val compatImport =
59
+ if (sameElements.nonEmpty) addCompatImport(ctx)
60
+ else Patch .empty
61
+
62
+ sameElements + compatImport
59
63
}
60
64
61
65
You can’t perform that action at this time.
0 commit comments