-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Compiler doesn't generate error "takes type parameters" in extends list #22334
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
Interesting. This seems to be a pretty old regression (unless it's an intended change I don't know about). Last good stable release: 3.3.0 The bisect script crashes in between on
cc @som-snytt @smarter @odersky @dwijnand The range is quite wide, might need some effort to narrow this down. |
It's not kind polymorphism, it's type arg inference - and Nothing is a valid type argument. I feel like this has been seen before and we decided to not change it, but I don't have an issue reference. |
We could potentially rule out type arg inference if there are no term arguments that follow. After all, there's nothing to infer then and we always end up with Nothing which is often not helpful. I am not sure there was an explicit discussion about this in the past? |
I'm probably thinking of #3434 (comment).
Sounds good to me (also not changing anything sounds fine to me too). |
The discussion on #3434 seems to imply that at least in 2017 the Scala 2 compiler did infer |
BTW, the original code example is taken from here: I noticed IntelliJ reporting the error while the code compiles: |
I think we have three choices:
|
After #16896, both Scala 2 and 3 are trying to infer type arguments for the parent types, so they have the same behaviour in this sense. The reason why Scala 3 doesn't give error when extending the trait is because traits have constructors in Scala 3 but not in Scala 2. After discussion at the core meeting, we decided to keep the current Scala 3 behaviour to avoid breaking any existing code. |
Uh oh!
There was an error while loading. Please reload this page.
Scala 3.3.3 or 3.6.2
Actual behaviour
No error for
extends MyTrait
.It's treated as
MyTrait[Nothing]
Expected behaviour
Scala 3 compiler should generate the error "trait MyTrait takes type parameters" like in Scala 2.
Or "Missing type parameter for MyTrait" as for
val value: MyTrait
It might be some unintended side-effect of changes in kind polymorphism in Scala 3.
Originally asked in Discord:
https://discord.com/channels/632150470000902164/632150470000902166/1327234334758797322
The text was updated successfully, but these errors were encountered: