Commit 2a41413
committed
Fix signatures involving WildcardTypes
A `WildcardType` never appears in the type of a tree, but it can appear
in an expected type and because TypeComparer checks if
`tp1.signature consistentParams tp2.signature`, we can end up calling
`sigName` on a `WildcardType`.
Before this commit, the result was either a custom type name or the
upper-bound of the wildcard, but both of these options means that
`consistentParams` could return false in situations where the two method
types would in fact match. We fix this by always returning
`tpnme.Uninstantiated`, meaning that `consistentParams` will always
allow a wildcard to match any other type. This does not cause any
over-approximation because the TypeComparer will always check that the
actual types match after checking that the signatures match.
Also use tpnme.ERROR instead of tpnme.Wildcard for ErrorType and NoType
to make it easier to spot their usage.
Fixes #11481.1 parent 1e484e5 commit 2a41413
File tree
2 files changed
+5
-3
lines changed- compiler/src/dotty/tools/dotc/core
- tests/pos
2 files changed
+5
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
821 | 821 | | |
822 | 822 | | |
823 | 823 | | |
824 | | - | |
825 | | - | |
826 | 824 | | |
827 | | - | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
828 | 828 | | |
829 | 829 | | |
830 | 830 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
0 commit comments