scala icon indicating copy to clipboard operation
scala copied to clipboard

Warning about changed precedence in imports when migrating to 2.13

Open lrytz opened this issue 3 years ago • 2 comments

lrytz avatar Jul 28 '22 12:07 lrytz

maybe this should be enabled by -Xmigration?

SethTisue avatar Jul 28 '22 15:07 SethTisue

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).

lrytz avatar Jul 29 '22 12:07 lrytz

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

lrytz avatar Aug 16 '22 11:08 lrytz

Very useful!

retronym avatar Aug 17 '22 14:08 retronym

Thanks, I never thought to do that.

som-snytt avatar Aug 18 '22 10:08 som-snytt