-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Type bound breaks extraction of covariant type parameter from singleton type #16504
Comments
I don't think you can expect this to work with a covariant box, since the match type has nothing to work with. It certainly cannot give a unique instantiation of It does work if class Box[A](a: A)
val box: Box[Int] = Box(123)
type Elem[T] = T match
case Box[a] => a
def x1[F](f: F): Elem[f.type] = ???
def y1 = x1(box)
def x2[F <: Box[?]](f: F): Elem[f.type] = ???
def y2: Elem[box.type] = x2(box) |
What seems strange to me here is that it works with a covariant def x1[F](f: F): Elem[f.type]
def y1: Int Also somehow this used to work for some time with covariance and a type bound. I'm trying to bisect it now. Currently I got to this point:
|
Bisection seems to point to 02f775f791 |
Looks similar enough that it would probably compile as desired with #16206. |
Yeah, like that issue, |
Not reproducible in 3.2.2 https://scastie.scala-lang.org/DmytroMitin/eECHNH2IRdCKRUNPU4x0Vg/1 |
@DmytroMitin the issue is still there but it's not directly observable when you just compile this snippet in a file or in scastie. It becomes evident if you change def |
Fixed with #17180 |
Compiler version
3.2.1, 3.3.0-RC1-bin-20221209-231f9ab-NIGHTLY
Used to work in 3.1.3
Minimized code
Output
As seen in REPL:
Expectation
Elem[f.type]
should be properly computed asInt
, as in 3.1.3:The text was updated successfully, but these errors were encountered: