Skip to content

Commit 6f70a1b

Browse files
Backport "Fix condition in prefixIsElidable to prevent compiler crash" to LTS (#20752)
Backports #18924 to the LTS branch. PR submitted by the release tooling. [skip ci]
2 parents 5ab89f4 + aa0a904 commit 6f70a1b

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

compiler/src/dotty/tools/dotc/ast/tpd.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
407407
case pre: ThisType =>
408408
tp.isType ||
409409
pre.cls.isStaticOwner ||
410-
tp.symbol.isParamOrAccessor && !pre.cls.is(Trait) && ctx.owner.enclosingClass == pre.cls
410+
tp.symbol.isParamOrAccessor && !pre.cls.is(Trait) && !tp.symbol.owner.is(Trait) && ctx.owner.enclosingClass == pre.cls
411411
// was ctx.owner.enclosingClass.derivesFrom(pre.cls) which was not tight enough
412412
// and was spuriously triggered in case inner class would inherit from outer one
413413
// eg anonymous TypeMap inside TypeMap.andThen

tests/pos/i18091.scala

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
trait B(val y: Int)
2+
3+
class C extends B(20) {
4+
def foo(): Unit = println(y)
5+
}

0 commit comments

Comments
 (0)