File tree 3 files changed +39
-1
lines changed
compiler/src/dotty/tools/dotc/typer
3 files changed +39
-1
lines changed Original file line number Diff line number Diff line change @@ -767,7 +767,22 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
767
767
val qual1 = qual.cast(liftedTp)
768
768
val tree1 = cpy.Select (tree0)(qual1, selName)
769
769
val rawType1 = selectionType(tree1, qual1)
770
- tryType(tree1, qual1, rawType1)
770
+ val adapted = tryType(tree1, qual1, rawType1)
771
+ if ! adapted.isEmpty && sourceVersion == `3.6-migration` then
772
+ val adaptedOld = tryExt(tree, qual)
773
+ if ! adaptedOld.isEmpty then
774
+ val symOld = adaptedOld.symbol
775
+ val underlying = liftedTp match
776
+ case tp : TypeProxy => i " ${tp.translucentSuperType}"
777
+ case _ => " "
778
+ report.migrationWarning(
779
+ em """ Previously this selected the extension ${symOld}${symOld.showExtendedLocation}
780
+ |Now it selects $selName on the opaque type's underlying type $underlying
781
+ |
782
+ |You can change this back by selecting $adaptedOld
783
+ |Or by defining the extension method outside of the opaque type's scope.
784
+ | """ , tree0)
785
+ adapted
771
786
else EmptyTree
772
787
773
788
// Otherwise, try to expand a named tuple selection
Original file line number Diff line number Diff line change
1
+ -- Migration Warning: tests/warn/i21239.Frac.scala:14:8 ----------------------------------------------------------------
2
+ 14 | f + Frac.wrap(((-g.numerator).toLong << 32) | (g.unwrap & 0xFFFFFFFFL)) // warn
3
+ | ^^^
4
+ | Previously this selected the extension method + in object Frac
5
+ | Now it selects + on the opaque type's underlying type Long
6
+ |
7
+ | You can change this back by selecting kse.maths.Frac.+(f)
8
+ | Or by defining the extension method outside of the opaque type's scope.
Original file line number Diff line number Diff line change
1
+ package kse .maths
2
+
3
+ import scala .language .`3.6-migration`
4
+
5
+ opaque type Frac = Long
6
+ object Frac {
7
+ inline def wrap (f : Long ): kse.maths.Frac = f
8
+ extension (f : Frac )
9
+ inline def unwrap : Long = f
10
+ inline def numerator : Int = ((f : Long ) >>> 32 ).toInt
11
+ extension (f : kse.maths.Frac )
12
+ def + (g : Frac ): kse.maths.Frac = f // eliding domain-specific addition logic
13
+ def - (g : Frac ): kse.maths.Frac =
14
+ f + Frac .wrap(((- g.numerator).toLong << 32 ) | (g.unwrap & 0xFFFFFFFFL)) // warn
15
+ }
You can’t perform that action at this time.
0 commit comments