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

Rename InlineCopier to ConservativeTreeCopier, use it in TypeMaps #21941

Merged
merged 1 commit into from
Nov 14, 2024

Conversation

mbovel
Copy link
Member

@mbovel mbovel commented Nov 13, 2024

Another attempt to fix #17242.

Previous attempts: #17256 and #21884.

@mbovel
Copy link
Member Author

mbovel commented Nov 13, 2024

The context of this PR is best described in #21595 and #17242.

@mbovel mbovel marked this pull request as ready for review November 14, 2024 11:29
@mbovel mbovel requested a review from odersky November 14, 2024 14:57
Copy link
Contributor

@odersky odersky left a comment

Choose a reason for hiding this comment

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

Looks good.

@mbovel mbovel merged commit a304c85 into scala:main Nov 14, 2024
29 checks passed
@mbovel mbovel deleted the mb/17242-2 branch November 15, 2024 14:12
@WojciechMazur WojciechMazur added this to the 3.6.3 milestone Nov 25, 2024
mbovel added a commit that referenced this pull request 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`](https://github.com/scala/scala3/blob/cb97c40930d335e0fca38238682d218c3e718bd8/compiler/src/dotty/tools/dotc/typer/TypeAssigner.scala#L298)
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.
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.

Selection on term defined in current clause unexpectedly fails
3 participants