Skip to content

Commit

Permalink
Fix condition in prefixIsElidable to prevent compiler crash
Browse files Browse the repository at this point in the history
[Cherry-picked c35a700]
  • Loading branch information
szymon-rd authored and WojciechMazur committed Jun 23, 2024
1 parent 43dde38 commit 685d292
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 && !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 685d292

Please sign in to comment.