scala
scala copied to clipboard
Warning about changed precedence in imports when migrating to 2.13
maybe this should be enabled by -Xmigration?
I was thinking which flag to re-use; -Xmigration is for the @migration annotation, so I don't think it's a good match?
Probably -Xsource is the right choice, it enables additional warnings and errors (but also aligns some type checking and implicit logic with 2.13).
This can lead to additional import cycle errors under -Xsource:2.13. Once a symbol is found in the current package, lookup continues to see if there's an import that also makes a matching symbol available. However, the same import cycle errors show up under 2.13, so this is expected.
Here's an example (3 separate files) that compiles with 2.12, but not with -Xsource:2.13, and neither with a 2.13 compiler:
package p
trait A
package p
import p.C._
object B extends A
package p
import p.B._
object C extends A
Very useful!
Thanks, I never thought to do that.