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 17, 2018
1 parent 98e6300 commit dae6c54
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 dae6c54

Please sign in to comment.