-
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
Extend pattern type constraining to sealed hierarchies #16924
Conversation
8a09d70
to
9e430a4
Compare
OK, so if I understand this correctly, after this PR I think we should have more tests too, for instance ones that show Guillaume's examples from here #16885 (comment) do not work anymore. Also, it's not clear to me if this example should compile, scala> object O {
| sealed trait Foo[+A] {
| def foo: A
| }
|
| sealed trait Bar[+A] extends Foo[A] {
| def bar: A
| }
|
| sealed trait FB extends Bar[Any] with Foo[Int] {
| def bar: Any = ""
| def foo: Int = 1
| }
| }
// defined object O Last thing: the impact of changing how |
Sure, no problem.
It isn't necessary to forbid that, is it? I assume there are other cases like that - but perhaps not. |
It's not necessary, but |
Ok, so it's really not looking like I will have any time to experiment with this branch and see what the code is actually doing. As far as I can tell, there are two approaches here: 1) Require sealed traits to be extended invariantlyThis is effectively what the changes to Also, if this is what you intend to do, then 2) Check sealed traits for being effectively extended invariantlyThis seems to be what you're trying to do in If this is what you intend to do, then there should be no change to Also, this is a very subtle change. I would expect to see multiple tests that exercise the change and show what does and what doesn't work, ideally closer to 5 tests rather than 1. |
9e430a4
to
7e3765b
Compare
7e3765b
to
849598f
Compare
849598f
to
1d88777
Compare
Fixes #4790
Adds
sealed
tocase
, where #14820 looked to handle all classes.Require sealed traits to be extended invariantly.