-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Deskolemize PatternTypeConstrainer #12506
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3840,9 +3840,15 @@ class Typer extends Namer | |
|
||
// approximate type params with bounds | ||
def approx = new ApproximatingTypeMap { | ||
var alreadyExpanding: List[TypeRef] = Nil | ||
def apply(tp: Type) = tp.dealias match | ||
case tp: TypeRef if !tp.symbol.isClass => | ||
expandBounds(tp.info.bounds) | ||
if alreadyExpanding contains tp then tp else | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How is this connected to the rest of the changes? Did the rest trigger a SO here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, this is the source of the SO that happened after restoring GADT constraints on failed subtype checks. |
||
val saved = alreadyExpanding | ||
alreadyExpanding ::= tp | ||
val res = expandBounds(tp.info.bounds) | ||
alreadyExpanding = saved | ||
res | ||
case _ => | ||
mapOver(tp) | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
object Test { | ||
sealed abstract class Foo[T] | ||
case object Bar1 extends Foo[Int] | ||
case object Bar2 extends Foo[String] | ||
case object Bar3 extends Foo[AnyRef] | ||
|
||
def fail4[T <: AnyRef](xx: (Foo[T], Foo[T])) = xx match { | ||
case (Bar1, Bar1) => () // error // error | ||
case (Bar2, Bar3) => () | ||
case (Bar3, _) => () | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
@main def test: Unit = { | ||
class Foo | ||
class Bar | ||
|
||
trait UpBnd[+A] | ||
trait P extends UpBnd[Foo] | ||
|
||
def pmatch[A, T <: UpBnd[A]](s: T): A = s match { | ||
case p: P => | ||
new Foo // error | ||
} | ||
|
||
class UpBndAndB extends UpBnd[Bar] with P | ||
// ClassCastException: Foo cannot be cast to Bar | ||
val x = pmatch(new UpBndAndB) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
object test { | ||
def foo[A, B](m: B) = { | ||
m match { | ||
case _: A => | ||
m match { | ||
case _: B => // crash with -Yno-deep-subtypes | ||
} | ||
} | ||
} | ||
} |
Uh oh!
There was an error while loading. Please reload this page.