Open
Description
A simple source with TravesableOnce
results in a strange IterableOnceIterableOnce
identifier (the correct identifier is repeated twice):
package com.github.ondrejspanel.scafi
object TraversableOnce {
def shuffle[T](random: scala.util.Random, src: TraversableOnce[T]): List[T] = {
src.foldLeft(List.empty[T]) { (list, item) =>
val len = list.length
val index = (random.nextDouble() * (len + 1)).toInt
list.patch(index, List(item), 0)
}
}
}
Using scalafix Collection213Upgrade
was rewritten as:
package com.github.ondrejspanel.scafi
import scala.IterableOnce
object TraversableOnce {
def shuffle[T](random: scala.util.Random, src: IterableOnceIterableOnce[T]): List[T] = {
src.foldLeft(List.empty[T]) { (list, item) =>
val len = list.length
val index = (random.nextDouble() * (len + 1)).toInt
list.patch(index, List(item), 0)
}
}
}
Complete project available at https://github.com/OndrejSpanel/ScalaFixSimple