-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Drop phase.isTyper use in isLegalPrefix/asf (#21954)
Note that "asSeenFrom" (aka asf) is used by SymDenotation#findMember, which is used by TypeComparer's "hasMatchingMember", as a part of "compareRefinedSlow". Previously (using the minimisation in i17222.8.scala) `summonOne` is inlined during the "inlining" phase, while "summonInline" is inlined during typing. The result is that during inlining we fail to find `Reader[BC, Int]` because we incorrectly consider `A{type F = Int}` as stable. Fixes #17222
- Loading branch information
Showing
18 changed files
with
647 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import scala.compiletime.* | ||
|
||
trait Reader[-In, Out] | ||
|
||
trait A: | ||
type T | ||
type F[X] | ||
type Q = F[T] | ||
|
||
object Reader: | ||
|
||
given [X]: Reader[A { type Q = X }, X] with {} | ||
|
||
object Test: | ||
|
||
trait B[X] extends A: | ||
type T = X | ||
|
||
trait C extends A: | ||
type F[X] = X | ||
|
||
trait D[X] extends B[X] with C | ||
|
||
val d = new D[Int] {} | ||
val bc = new B[Int] with C | ||
|
||
summonAll[(Reader[d.type, Int], Reader[d.type, Int])] // works | ||
summonAll[(Reader[bc.type, Int], Reader[bc.type, Int])] // error | ||
summonInline[Reader[d.type, Int]] // works | ||
summonInline[Reader[bc.type, Int]] // works?? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import scala.compiletime.* | ||
|
||
trait Reader[-In, Out] | ||
|
||
trait A: | ||
type T | ||
type F[X] | ||
type Q = F[T] | ||
|
||
object Reader: | ||
|
||
given [X]: Reader[A { type Q = X }, X] with {} | ||
|
||
object Test: | ||
|
||
trait B[X] extends A: | ||
type T = X | ||
|
||
trait C extends A: | ||
type F[X] = X | ||
|
||
trait D[X] extends B[X] with C | ||
|
||
val d = new D[Int] {} | ||
val bc = new B[Int] with C | ||
|
||
case class Box[T](value: T) | ||
|
||
/** compiletime.summonAll, but with one case */ | ||
inline def summonOne[T <: Box[?]]: T = | ||
val res = | ||
inline erasedValue[T] match | ||
case _: Box[t] => summonInline[t] | ||
end match | ||
Box(res).asInstanceOf[T] | ||
end summonOne | ||
|
||
summonOne[Box[Reader[d.type, Int]]] // works | ||
summonOne[Box[Reader[bc.type, Int]]] // errors |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import scala.compiletime.* | ||
|
||
trait Reader[-In, Out] | ||
|
||
trait A: | ||
type T | ||
type F[X] | ||
type Q = F[T] | ||
|
||
given [X]: Reader[A { type Q = X }, X] with {} | ||
|
||
case class Box[T](x: T) | ||
|
||
/** compiletime.summonAll, but with one case */ | ||
inline def summonOne[T]: T = | ||
val res = | ||
inline erasedValue[T] match | ||
case _: Box[t] => summonInline[t] | ||
end match | ||
Box(res).asInstanceOf[T] | ||
end summonOne | ||
|
||
|
||
@main def main = | ||
|
||
|
||
trait B[X] extends A: | ||
type T = X | ||
|
||
trait C extends A: | ||
type F[X] = X | ||
|
||
|
||
val bc = new B[Int] with C | ||
|
||
summonOne[Box[Reader[bc.type, Int]]] // errors | ||
|
||
|
||
val bc2: A { type Q = Int } = new B[Int] with C | ||
|
||
summonOne[Box[Reader[bc2.type, Int]]] // works | ||
|
||
|
||
object BC extends B[Int] with C | ||
|
||
summonOne[Box[Reader[BC.type, Int]]] // works | ||
|
||
|
||
val a = new A: | ||
type T = Int | ||
type F[X] = X | ||
|
||
summonOne[Box[Reader[a.type, Int]]] // works | ||
|
||
|
||
val b = new B[Int]: | ||
type F[X] = X | ||
|
||
summonOne[Box[Reader[b.type, Int]]] // works | ||
|
||
|
||
val ac = new A with C: | ||
type T = Int | ||
|
||
summonOne[Box[Reader[ac.type, Int]]] // works | ||
|
||
|
||
trait D[X] extends B[X] with C | ||
val d = new D[Int] {} | ||
|
||
summonOne[Box[Reader[d.type, Int]]] // works |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import scala.compiletime.* | ||
|
||
trait Reader[-In, Out] | ||
|
||
trait A: | ||
type T | ||
type F[X] | ||
type Q = F[T] | ||
|
||
given [X]: Reader[A { type Q = X }, X] with {} | ||
|
||
case class Box[T](x: T) | ||
|
||
inline def summonOne[T]: T = | ||
summonInline[T] | ||
end summonOne | ||
|
||
@main def main = | ||
trait B[X] extends A: | ||
type T = X | ||
trait C extends A: | ||
type F[X] = X | ||
|
||
val bc = new B[Int] with C | ||
summonInline[Reader[bc.type, Int]] // (I) Works | ||
summonOne[Reader[bc.type, Int]] // (II) Errors |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import scala.compiletime.* | ||
|
||
trait A: | ||
type F | ||
type Q = F | ||
|
||
trait Reader[-In, Out] | ||
object Reader: | ||
given [X]: Reader[A { type Q = X }, X] with {} | ||
|
||
class Test: | ||
//type BC = A { type F = Int } & A // ok | ||
type BC = A & A { type F = Int } // fail, also ok when manually de-aliased | ||
|
||
inline def summonOne: Unit = summonInline[Reader[BC, Int]] | ||
|
||
def t1(): Unit = summonInline[Reader[BC, Int]] // ok | ||
def t2(): Unit = summonOne // error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class Foo: | ||
type In | ||
type Bar = { def go(in: In): Unit } | ||
type False = false | ||
|
||
class Test: | ||
def t1: Unit = valueOf[Foo#False] |
Oops, something went wrong.