-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Change pretyping of argument closure #2018
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
Conversation
case-closures (which are represented as Match nodes) have a known arity just like other function literals. So shape analysis for overloading resolution should apply to them as well.
Follow scalac in taking the lub of all formal parameters instead of requiring that they are all the same. This conforms to the spec change in https://github.com/scala/scala/pull/5307/files#diff-5d74b019862ed901d7800b4ace79fb5b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I appreciate that we're aligning our spec & impl here, though I also agree that it probably doesn't matter in practice whether we lub argument types or require them to be the same. Personally, I think the lub approach is a bit more aesthetically pleasing :-)
@adriaanm Through test failures here I discovered two problems with the LUB approach. The first is the failing test `tests/pos/overloaded.scala'. Here we find:
This used to compile OK, but now gives errors, and scalac produces errors as well:
It seems we need a finer resolution which only LUBS those arguments that do not already have a type declared. The second problem is dotty only, in test file
We used to get a missing parameter type, but with the LUB change this now compiles into non-sensical code:
There's an unbound |
The last commit implements the selective LUB change. But the leaking local parameter problem still persists. |
I am going to close this, because the second problem mentioned above looks too messy to solve, given the limited usefulness.
|
Yes, we approximate abstract types with (unbounded) wildcards. I'll keep an eye on the dotty approach and the collections rework to make sure we stay compatible. |
Follow scalac in taking the lub of all formal parameters
instead of requiring that they are all the same.
This conforms to the spec change in
https://github.com/scala/scala/pull/5307/files#diff-5d74b019862ed901d7800b4ace79fb5b
Review by @adriaanm ?
Note this PR is based on #2015. Only the last commit is relevant here.