Skip to content

Commit

Permalink
Dont insert compat for iterable
Browse files Browse the repository at this point in the history
  • Loading branch information
MasseGuillaume committed Jul 20, 2018
1 parent 75e3881 commit a70886d
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions scalafix/rules/src/main/scala/fix/Stable212Base.scala
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,21 @@ trait Stable212Base extends CrossCompatibility { self: SemanticRule =>
val traversable = exact(
"_root_.scala.package.Traversable#",
"_root_.scala.collection.Traversable#",
"_root_.scala.package.Iterable#",
"_root_.scala.collection.Iterable#"
)

// == Rules ==

def replaceIterableSameElements(ctx: RuleCtx): Patch = {
ctx.tree.collect {
case Term.Apply(Term.Select(lhs, iterableSameElement(_)), List(_)) =>
ctx.addRight(lhs, ".iterator")
}.asPatch
val sameElements =
ctx.tree.collect {
case Term.Apply(Term.Select(lhs, iterableSameElement(_)), List(_)) =>
ctx.addRight(lhs, ".iterator")
}.asPatch

val compatImport =
if(sameElements.nonEmpty) addCompatImport(ctx)
else Patch.empty

sameElements + compatImport
}


Expand Down

0 comments on commit a70886d

Please sign in to comment.