Commit 772be76
authored
Fix condition in prefixIsElidable to prevent compiler crash (#18924)
Fix #18901
The check in `prefixIsElidable` was defined as follows:
```scala
tp.symbol.isParamOrAccessor && !pre.cls.is(Trait) && ctx.owner.enclosingClass == pre.cls
```
I assume that `!pre.cls.is(Trait)` condition was introduced to
accommodate for `Mixin` phase getting rid of `ParamAccessor` defined in
traits. However, the prefix does not indicate where the symbol is really
defined - it only represents the prefix from the perspective of the
current template, so it could be inherited. When it's inherited from a
trait, the prefix would be the current class, but the member still is
defined in the trait, and `Mixin` would get rid of the `ParamAccessor`
flag. Therefore, I changed this condition to the following:
```scala
tp.symbol.isParamOrAccesso && !pre.cls.is(Trait) && !tp.symbol.owner.is(Trait) && ctx.owner.enclosingClass == pre.cls
```File tree
2 files changed
+6
-1
lines changed- compiler/src/dotty/tools/dotc/ast
- tests/pos
2 files changed
+6
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
414 | 414 | | |
415 | 415 | | |
416 | 416 | | |
417 | | - | |
| 417 | + | |
418 | 418 | | |
419 | 419 | | |
420 | 420 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
0 commit comments