Skip to content

Commit 8e682da

Browse files
authored
Merge pull request #7834 from dotty-staging/fix-#7822
Fix #7822: Avoid crash in liftToThis
2 parents 21d5b07 + 740ca02 commit 8e682da

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

compiler/src/dotty/tools/dotc/core/TypeComparer.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1114,7 +1114,7 @@ class TypeComparer(initctx: Context) extends ConstraintHandling[AbsentContext] w
11141114
findEnclosingThis(tp.symbol.moduleClass, ctx.owner)
11151115
case tp: TypeRef =>
11161116
val pre1 = liftToThis(tp.prefix)
1117-
if (pre1 ne tp.prefix) tp.withPrefix(pre1) else tp
1117+
if ((pre1 ne tp.prefix) && pre1.exists) tp.withPrefix(pre1) else tp
11181118
case tp: ThisType if tp.cls.is(Package) =>
11191119
findEnclosingThis(tp.cls, ctx.owner)
11201120
case tp: AppliedType =>

tests/pos/i7822.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class Code {
2+
type Ctx
3+
}
4+
def foo(o0:Code,o1:Code) = new Code { type Ctx = o0.Ctx & o1.Ctx }
5+
def foo0(o0:Code,o1:Code): Code { type Ctx = o0.Ctx & o1.Ctx } = foo(o0,o1)

0 commit comments

Comments
 (0)