Skip to content

Commit 8bbd534

Browse files
committed
Handle another case in newExpr
The typed prefix of an `apply` may also be this ThisType of a module class. Fixes #11230
1 parent 0273336 commit 8bbd534

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

compiler/src/dotty/tools/dotc/typer/Typer.scala

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3696,8 +3696,12 @@ class Typer extends Namer
36963696
val Select(qual, nme.apply) = tree; @unchecked
36973697
val tycon = tree.tpe.widen.finalResultType.underlyingClassRef(refinementOK = false)
36983698
val tpt = qual match
3699-
case Ident(name) => cpy.Ident(qual)(name.toTypeName)
3700-
case Select(pre, name) => cpy.Select(qual)(pre, name.toTypeName)
3699+
case Ident(name) =>
3700+
cpy.Ident(qual)(name.toTypeName)
3701+
case Select(pre, name) =>
3702+
cpy.Select(qual)(pre, name.toTypeName)
3703+
case This(name) if qual.symbol.is(ModuleClass) =>
3704+
cpy.Ident(qual)(qual.symbol.name.toTypeName)
37013705
typed(
37023706
untpd.Select(
37033707
untpd.New(untpd.TypedSplice(tpt.withType(tycon))),

tests/pos/i11230.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
trait TyperCrasher {
2+
class CrashTyper(i: Int) {}
3+
object CrashTyper {
4+
def init: CrashTyper = CrashTyper(0)
5+
}
6+
}

0 commit comments

Comments
 (0)