-
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
Adding support of path-dependent GADT reasoning #14754
Conversation
What's required to push this PR to the finish line? I have a system similar to trait T[X]
case object Foo extends T[Unit]
trait AsParam[L] {
val tl: T[L]
}
def testParam[A](ap: AsParam[A]): Unit =
ap.tl match {
case Foo => println(summon[A =:= Unit])
case _ => ()
} that I'd like to refactor into the equivalent of (the currently non-compiling on mainline Dotty) trait AsMember {
type L
val tl: T[L]
}
def testMember(am: AsMember): Unit =
am.tl match {
case Foo => println(summon[am.L =:= Unit])
case _ => ()
} so that methods can return val asParamQ: AsParam[?] = someFunction
asParamQ match {
case apt: AsParam[t] => apt.tl match {
case Foo => println(summon[t =:= Unit])
case _ => ()
}
} to consume (which does happen to compile on mainline). |
Hi! Glad to see this PR can benefit real-world development. It is currently blocked by #14776. This is a bug discovered when developing this PR and the tests currently broken would work after fixing this issue. |
Just verified that the following snippet compiles on this branch. :) trait T[X]
case object Foo extends T[Unit]
trait AsMember {
type L
val tl: T[L]
}
def testMember(am: AsMember): Unit =
am.tl match {
case Foo => println(summon[am.L =:= Unit])
case _ => ()
} |
Thanks to the path-dependent GADT reasoning logic, these limitation errors can be dropped from the testcases. See scala#14754.
Thanks to the path-dependent GADT reasoning logic, these limitation errors can be dropped from the testcases. See scala#14754.
Thanks to the path-dependent GADT reasoning logic, these limitation errors can be dropped from the testcases. See scala#14754.
Thanks to the path-dependent GADT reasoning logic, these limitation errors can be dropped from the testcases. See scala#14754.
Thanks to the path-dependent GADT reasoning logic, these limitation errors can be dropped from the testcases. See scala#14754.
Thanks to the path-dependent GADT reasoning logic, these limitation errors can be dropped from the testcases. See scala#14754.
test performance please |
performance test scheduled: 1 job(s) in queue, 0 running. |
Performance test finished successfully: Visit https://dotty-bench.epfl.ch/14754/ to see the changes. Benchmarks is based on merging with main (634c580) |
Thanks to the path-dependent GADT reasoning logic, these limitation errors can be dropped from the testcases. See scala#14754.
test performance please |
performance test scheduled: 1 job(s) in queue, 0 running. |
Performance test finished successfully: Visit https://dotty-bench.epfl.ch/14754/ to see the changes. Benchmarks is based on merging with main (e560c2d) |
Hey Alex! @abgruszecki I have finished one round of PR polishing. I have done the following things:
There are one thing we discussed before but not in the review comments yet, so I am not sure whether I should do it: refactoring the states related to pattern and scrutinee paths into another class in |
Hey @Linyxus are you willing to give this a rebase? If so, I think we can try and get this reviewed. |
Similarly, we will wait for a refactorization of GADT (#15928) before proceeding this feature. I will close this for now and go back to it after the refactorization is done. |
#15928 was closed. Is there any future for the changes in this PR? |
Previously, GADT reasoning only works on type parameters. This PR supports GADT reasoning for path-dependent types (that is, type members addressed from stable paths).
It mainly makes the following two things possible:
Fixes #15868.