-
Notifications
You must be signed in to change notification settings - Fork 1.1k
GADT matching doesn't brings subtyping relation into scope #9833
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
Comments
This is an interesting issue. First off, GADTs currently cannot constrain type parameters of classes: #4323 (though this might actually be changing in the future, there's a person on this right now!) Even if we modify
I think this error is not necessary. I will need to take a closer look. Bottom line is, this works: https://github.com/lampepfl/dotty/blob/master/tests/neg/gadt-approximation-interaction.scala#L1
|
I have another case where I expect GADTs to bring contraint to scope: enum Ev[F <: AnyKind]:
case HK() extends Ev[List]
def f[F <: AnyKind](ev: Ev[F]): Unit = ev match {
case Ev.HK() =>
type T = F[Int] // Error: F does not take type parameters
()
} In this example, |
@IndiscriminateCoding in this example you will have to extract enum Ev[F <: AnyKind]:
case HK() extends Ev[List]
def f[F <: AnyKind](ev: Ev[F]): Unit = ev match {
case Ev.HK(): Ev[f] =>
val m: f[Int] = List(1,2,3)
()
} |
@bishabosha Interesting! |
Fix scala#9769 Fix scala#9833 Fix scala#10389 Fix scala#10897 Fix scala#11163 Fix scala#11556 Fix scala#12474 Fix scala#10994 Fix scala#11729
Minimized code
Output
Expectation
I expect
A <: B
to be visible insideExtends.Ev()
case bodyThe text was updated successfully, but these errors were encountered: