Commit aa613d8
committed
Refine criterion when to skip identifiers in pattern constructors
There's a strange and almost forgotten rule that disqualifies method symbols
from direct lookup when the identifier is the constructor of a pattern. This
is done to make code like this work:
```
class List[T]:
def :: (that: T): List[T]
def f(...) = this match
case x :: xs => ...
object `::`:
def unapply...
```
Without the rule, the `::` in the pattern would resolve to the `::` method
in `List` which does not have an `unapply`. We need to skip that method to get
to the outer `::` object.
The rule plays badly with export forwarders, which are methods, and therefore
were ineligible for pattern constructurs. We now change the rule so that methods
are also accepted as unqualified `unapply` prefixes as long as they are parameterless.
Fixes #153471 parent 78dbc59 commit aa613d8
File tree
2 files changed
+13
-4
lines changed- compiler/src/dotty/tools/dotc/typer
- tests/pos
2 files changed
+13
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
176 | 176 | | |
177 | 177 | | |
178 | 178 | | |
179 | | - | |
180 | | - | |
| 179 | + | |
| 180 | + | |
181 | 181 | | |
182 | 182 | | |
183 | 183 | | |
| |||
187 | 187 | | |
188 | 188 | | |
189 | 189 | | |
| 190 | + | |
| 191 | + | |
190 | 192 | | |
191 | | - | |
192 | | - | |
| 193 | + | |
193 | 194 | | |
194 | 195 | | |
195 | 196 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
0 commit comments