Skip to content

Commit 4458da5

Browse files
committed
Harden parentType
1 parent 0fab13b commit 4458da5

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

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

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -907,14 +907,19 @@ class Namer { typer: Typer =>
907907
case TypeApply(core, targs) => (core, targs)
908908
case core => (core, Nil)
909909
}
910-
val Select(New(tpt), nme.CONSTRUCTOR) = core
911-
val targs1 = targs map (typedAheadType(_))
912-
val ptype = typedAheadType(tpt).tpe appliedTo targs1.tpes
913-
if (ptype.typeParams.isEmpty) ptype
914-
else {
915-
if (denot.is(ModuleClass) && denot.sourceModule.is(Implicit))
916-
missingType(denot.symbol, "parent ")(creationContext)
917-
fullyDefinedType(typedAheadExpr(parent).tpe, "class parent", parent.pos)
910+
core match {
911+
case Select(New(tpt), nme.CONSTRUCTOR) =>
912+
val targs1 = targs map (typedAheadType(_))
913+
val ptype = typedAheadType(tpt).tpe appliedTo targs1.tpes
914+
if (ptype.typeParams.isEmpty) ptype
915+
else {
916+
if (denot.is(ModuleClass) && denot.sourceModule.is(Implicit))
917+
missingType(denot.symbol, "parent ")(creationContext)
918+
fullyDefinedType(typedAheadExpr(parent).tpe, "class parent", parent.pos)
919+
}
920+
case _ =>
921+
assert(ctx.reporter.errorsReported)
922+
UnspecifiedErrorType
918923
}
919924
}
920925

tests/neg/parser-stability-8.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
case class I0 extends this // error // error

0 commit comments

Comments
 (0)