Skip to content

Conversation

mbovel
Copy link
Member

@mbovel mbovel commented Apr 1, 2025

Fixes #22874.

wildApprox approximates parameter references and type variables by wildcards. When doing so for an AnnotatedType, this can produce trees with wildcards types, causing the type assigner to fail. For example, consider Apply(fn, args) where fn has type TermParamRef. Applying wildApprox will approximate the type of fn to a wildcard, leading the type assigner for Apply to emit an error stating that <?> does not take parameters.

This issue is somehow similar to the one described in #19957 (comment), which was fixed by #21941 (and re-worked in #22839).

This PR fixes the issue by approximating annotated types in wildApprox: annotated types are approximated by their parent types if they are not refining, or by wildcards upper-bounded by their parent types if they are.

@mbovel mbovel requested a review from smarter April 1, 2025 11:29
Copy link
Member

@smarter smarter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, maybe add a comment in the added case pointing to the test for illustration?

@mbovel
Copy link
Member Author

mbovel commented Apr 1, 2025

Thanks a lot for the quick review! Comment added!

@mbovel mbovel merged commit 72d0026 into scala:main Apr 1, 2025
29 checks passed
@mbovel mbovel deleted the mb/22874 branch April 1, 2025 15:40
@WojciechMazur WojciechMazur added this to the 3.7.1 milestone May 1, 2025
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.

value of type <?> does not take parameters from wildApprox when typing a parameter with an annotated type and a default value

3 participants