Commit 72d0026
authored
Approximate annotated types in
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.wildApprox (#22893)File tree
2 files changed
+16
-0
lines changed- compiler/src/dotty/tools/dotc/typer
- tests/pos
2 files changed
+16
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1017 | 1017 | | |
1018 | 1018 | | |
1019 | 1019 | | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
1020 | 1029 | | |
1021 | 1030 | | |
1022 | 1031 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
0 commit comments