Skip to content
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

Incorrect overload resolution ends in type error. #3515

Merged
merged 3 commits into from
Jan 5, 2025

Conversation

stephan-herrmann
Copy link
Contributor

  • record when Poly*Method is part of a set of overloads
    • in that case don't propagate premature bounds inner -> outer

Fixes #2941

+ record when Poly*Method is part of a set of overloads
  + in that case don't propagate premature bounds inner -> outer

Fixes eclipse-jdt#2941
@stephan-herrmann stephan-herrmann added this to the 4.35 M2 milestone Jan 4, 2025
+ better strategy to detect ambiguous PolyParam*MethodBinding

Fixes eclipse-jdt#2941
+ stop early when innerMethod was ambigous

Fixes eclipse-jdt#2941
@stephan-herrmann
Copy link
Contributor Author

Initially during inference, resolving from(stream) could not select an overload due to insufficient type information. At this point three things are created: two PolyParameterizedMethodBinding, one for each of the candidates, and one ProblemMethodBinding(Ambiguous) holding one of the candidates as its closestMatch. This opportunistic selection is where declaration order influenced the outcome. Somehow that closest match surfaced in our implementation of 18.5.2.2. (specifically: addConstraintsToC_OneExpr()), where the type information of the inner from(stream) influenced the outer inference. When the wrong overload is used, this led to inference not finding the desired solution.

To fix this we'll now refuse to add further constraints based on type information from unresolved overload disambiguation. To detect the situation, at the point where we create the ProblemMethodBinding(Ambiguous) we tag the closestMatch PolyParameterizedMethodBinding as having overloads. That flag then prevents spilling premature information into outer inference.

@stephan-herrmann stephan-herrmann merged commit c928ff1 into eclipse-jdt:master Jan 5, 2025
10 checks passed
@stephan-herrmann stephan-herrmann deleted the issue2941 branch January 5, 2025 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incorrect overload resolution ends in type error.
1 participant