Skip to content

Commit

Permalink
Backport "Fix condition in prefixIsElidable to prevent compiler crash…
Browse files Browse the repository at this point in the history
…" to LTS (#20752)

Backports #18924 to the LTS branch.

PR submitted by the release tooling.
[skip ci]
  • Loading branch information
WojciechMazur authored Jun 23, 2024
2 parents 5ab89f4 + aa0a904 commit 6f70a1b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/ast/tpd.scala
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
case pre: ThisType =>
tp.isType ||
pre.cls.isStaticOwner ||
tp.symbol.isParamOrAccessor && !pre.cls.is(Trait) && ctx.owner.enclosingClass == pre.cls
tp.symbol.isParamOrAccessor && !pre.cls.is(Trait) && !tp.symbol.owner.is(Trait) && ctx.owner.enclosingClass == pre.cls
// was ctx.owner.enclosingClass.derivesFrom(pre.cls) which was not tight enough
// and was spuriously triggered in case inner class would inherit from outer one
// eg anonymous TypeMap inside TypeMap.andThen
Expand Down
5 changes: 5 additions & 0 deletions tests/pos/i18091.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
trait B(val y: Int)

class C extends B(20) {
def foo(): Unit = println(y)
}

0 comments on commit 6f70a1b

Please sign in to comment.