Skip to content

Conversation

@retronym
Copy link
Owner

@retronym retronym commented Aug 23, 2021

package foo
package bar

import scala.collection.immutable

class Test {
  val x: collection.Seq[collection.Seq[Int]] = collection.Seq(collection.Seq(1, 2, 3))
  def needsQualification(collection: String): collection.Seq[Int] = {
    collection.Seq(1)
  }

  def needsQualification2 {
    object X { val collection = ""}
    import X._
    scala.collection.Seq(1)
  }

  val ss: Set[String] = List(1).map(_.toString)(collection.breakOut[List[Int], String, Set[String]])

  def needsQualificatiomn3 {
    val ls = List(1)
    val ss: Set[String] = {
      val List, Set, String = ""
      type List = Nothing
      type Set = Nothing
      type String = Nothing
      ls.map(_.toString)(collection.breakOut[scala.collection.immutable.List[Int], java.lang.String, scala.Predef.Set[scala.Predef.String]])
    }
  }

}
$ cp /tmp/input.scala /tmp/rewrite.scala && ~/code/scala/build/quick/bin/scalac -Yrewrites:collectionSeq /tmp/rewrite.scala && cat /tmp/rewrite.scala
package foo
package bar

import scala.collection.immutable

class Test {
  val x: collection.Seq[collection.Seq[Int]] = collection.Seq(collection.Seq(1, 2, 3))
  def needsQualification(collection: String): collection.Seq[Int] = {
    collection.Seq(1)
  }

  def needsQualification2 {
    object X { val collection = ""}
    import X._
    scala.collection.Seq(1)
  }

  val ss: Set[String] = List(1).map(_.toString)(collection.breakOut[List[Int], String, Set[String]])

  def needsQualificatiomn3 {
    val ls = List(1)
    val ss: Set[String] = {
      val List, Set, String = ""
      type List = Nothing
      type Set = Nothing
      type String = Nothing
      ls.map(_.toString)(collection.breakOut[scala.collection.immutable.List[Int], java.lang.String, scala.Predef.Set[scala.Predef.String]])
    }
  }

}

lrytz and others added 6 commits August 13, 2021 14:30
```
class Test {
  val touch = {
    val x: scala.collection.Seq[Int] = Nil
    val y: scala.collection.Seq[scala.collection.Seq[Int]] = Nil
    scala.collection.Seq(scala.collection.Seq(1), scala.collection.Seq(2))
  }
  val dontTouch1 = {
    val Seq = 24
    Seq
  }

}
```

```
$ cp /tmp/input.scala /tmp/rewrite.scala && ~/code/scala/build/quick/bin/scalac -Yrewrites:collectionSeq /tmp/rewrite.scala && cat /tmp/rewrite.scala
```

```
class Test {
  val touch = {
    val x: scala.collection.Seq[Int] = Nil
    val y: scala.collection.Seq[scala.collection.Seq[Int]] = Nil
    scala.collection.Seq(scala.collection.Seq(1), scala.collection.Seq(2))
  }
  val dontTouch1 = {
    val Seq = 24
    Seq
  }

}
```
@retronym retronym force-pushed the topic/collection-seq branch 2 times, most recently from fd0a3b3 to 8669bc6 Compare August 24, 2021 00:52
@retronym retronym force-pushed the topic/collection-seq branch from 8669bc6 to babc2b2 Compare August 24, 2021 04:39
@retronym retronym force-pushed the topic/collection-seq branch from 3d42ac0 to 9f845fb Compare August 24, 2021 12:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants