Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Resolve overloading: keep track of prefix and indices of all default getters #16009

Merged
merged 3 commits into from
Oct 9, 2022

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Sep 9, 2022

Fixes #16006
Fixes #15287

When resolving overloading using parameter lists after the first one, we used mapped
symbols that forgot about the prefix of the original call and how many parameters were
skipped. Consequently, overloading resolution got confused when there were default
parameters in following parameter lists. We now keep track of these values in an
annotation that gets added to the mapped symbols.

We also use findDefaultGetter directly to compute the number of default parameters
in sizeFits. The previous scheme of checking the HasParam flag of parameters
fails for default values inherited from overriden methods.

…getters

When resolving overloading using parameter lists after the first one, we used mapped
symbols that forgot about the prefix of the original call and how many parameters were
skipped. Consequently, overloading resolution got confused when there were default
parameters in following parameter lists. We now keep track of these values in an
annotation that gets added to the mapped symbols.

We also use `findDefaultGetter` directly to compute the number of default parameters
in `sizeFits`. The previous scheme of checking the `HasParam` flag of parameters
fails for default values inherited from overriden methods.
@odersky odersky changed the title Keep HasDefault flag updated in overriding methods Resolve overloading: keep track of prefix and indices of all default getters Sep 11, 2022
Default arguments in later parameter sections are functions that take
ealier arguments as parameters. When we just want to test whether a method
is applicable, we don't keep track of these earlier arguments. Therefore,
we always assume in this case that a default getter matches, if one was found.
We need to show argument lists after the first one if they were
used for overloading resolution.
@odersky
Copy link
Contributor Author

odersky commented Oct 9, 2022

This PR fixes two bugs but has been lingering for 4 weeks with no review. Going to merge.

@odersky odersky merged commit 16b80fb into scala:main Oct 9, 2022
@odersky odersky deleted the fix-16006 branch October 9, 2022 10:57
@Kordyjan Kordyjan added this to the 3.2.2 milestone Aug 1, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
4 participants