-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Requirements for type bounds stricter than scalac #525
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
I'd like to leave that open for a while. It would be good to get input from theory (DOT) on that question. |
From a soundness point of view, this shouldn't matter, because at use site, bounds conformance is checked anyways, and if a function is never used, nothing can go wrong. But from a language design point of view, I find it more consistent to reject this example, because if you do "the same" with type members, it's also rejected: class Foo[T] {
type A
type B >: T <: A
} |
@samuelgruetter Good point. So I think we can leave it as it is. |
The test had to be slightly modified because of dotty's stricter checking of type bounds validity, see scala#525 where this was discussed.
I agree now that soundness is not the issue. The problems I was thinking of before all had to do with null being handled specially or with lazy values. In short, we manufactured an empty type plus a value that had that type. The value was either null or a lazy val. Without this trick I do not see how empty bounds could cause us a problem. |
Turns out it's not a soundness issue, but an expressiveness issue: The test in
but it's rejected with the error |
Not sure if this is something that we want to change or not, but:
fails with:
But it compiles with
scalac
.The code can easily be changed to also compile with dotty:
Do we want to be compatible with
scalac
here? I came across this because./tests/pending/pos/strip-tvars-for-lubbasetypes.scala
relies on it, but we could modify that test.The text was updated successfully, but these errors were encountered: