-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Intersection type with refined type member as upper bound does not compile #4623
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
More succinctly, the issue is that we cannot type: Any with Any { type T } (or any other refinement that looks like trait <refinement> extends Any with Any { type T } and we do not allow the same class to appear twice in the extends clause. I don't think we can relax this restriction for the synthetic |
Okay, I see the problem. However, since you can easily construct concrete types for the abstract type members, I think you would assume that the code compiles.
Is it important to disallow multiple appearances of the same type? This means the following does not compile: trait L[+T]
trait T extends L[Any] with L[String] But this does: trait L[+T]
trait A extends L[Any]
trait B extends L[String]
trait T extends A with B Naively, both variants look similar. For both,
Isn't the logic that is already implemented to compute the linearization basically what is required here; or do I see that wrong? |
Right, so maybe we can indeed lift this restriction just for typing refinements and nothing bad will happen. (It could also be lifted in general but there's no reason for a user to write |
Thanks, sounds good :-)
That's true, I agree. |
Or it could arise through type aliases that arise elsewhere and are hard to modify. I'm fine with forbidding direct appearances, though that could also be just a warning. (I thought #4557 was related, but on a closer look it's probably not). |
Fix #4623: Don't check for repeated parents in refinement classes
The following code compiles using Scala:
Dotty produces the following compiler error:
Notably, the following code compiles:
The text was updated successfully, but these errors were encountered: