-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Labels
area:gadtitype:bugregressionThis worked in a previous version but doesn't anymoreThis worked in a previous version but doesn't anymore
Milestone
Description
Compiler version
Compiles correctly for 3.0.0, 3.0.1
Gives an error for 3.0.2
Compiles correctly for 3.1.0, 3.1.1
Gives an error for 3.1.2, 3.1.3, 3.2.0-RC1, 3.2.1-RC1-bin-20220712-7e20b81-NIGHTLY
Minimized code
class Interval[E, D[_]]
class BoundedAbove[E, D[_]] extends Interval[E, D] {
def upper: Upper[E] = ???
}
class Upper[E]
def reference: Interval[Int, Option] = ???
def bound: Upper[Int] =
reference match {
case int: BoundedAbove[_, _] => int.upper
case _ => null
}Output
[error] ./main.scala:13:37: Found: Upper[_]
[error] Required: Upper[Int]
[error] case int: BoundedAbove[_, _] => int.upper
[error] ^^^^^^^^^Expectation
Compile correctly.
It should be possible to prove that int.upper.type <:< Upper[Int]
More information
Interestingly, the following piece of code compiles correctly. (If we change the kind of D to * or remove it altogether)
class Interval[E, D]
class BoundedAbove[E, D] extends Interval[E, D] {
def upper: Upper[E] = ???
}
class Upper[E]
def reference: Interval[Int, String] = ???
def bound: Upper[Int] =
reference match {
case int: BoundedAbove[_, _] => int.upper
case _ => null
}Metadata
Metadata
Assignees
Labels
area:gadtitype:bugregressionThis worked in a previous version but doesn't anymoreThis worked in a previous version but doesn't anymore