diff --git a/compiler/src/dotty/tools/dotc/typer/Namer.scala b/compiler/src/dotty/tools/dotc/typer/Namer.scala index f1ba950f1cd2..0d5a5aa2e341 100644 --- a/compiler/src/dotty/tools/dotc/typer/Namer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Namer.scala @@ -1039,7 +1039,7 @@ class Namer { typer: Typer => val finalSelfInfo: TypeOrSymbol = if (cls.isOpaqueCompanion) { // The self type of an opaque companion is refined with the type-alias of the original opaque type - def refineOpaqueCompanionSelfType(mt: Type, stats: List[Tree]): RefinedType = (stats: @unchecked) match { + def refineOpaqueCompanionSelfType(mt: Type, stats: List[Tree]): Type = (stats: @unchecked) match { case (td @ TypeDef(localName, rhs)) :: _ if td.mods.is(SyntheticOpaque) && localName == name.stripModuleClassSuffix => // create a context owned by the current opaque helper symbol, @@ -1053,6 +1053,8 @@ class Namer { typer: Typer => RefinedType(mt, localName, bounds) case _ :: stats1 => refineOpaqueCompanionSelfType(mt, stats1) + case _ => + mt // can happen for malformed inputs. } selfInfo match { case self: Type => diff --git a/tests/neg/i6061.scala b/tests/neg/i6061.scala new file mode 100644 index 000000000000..b1028d2889b3 --- /dev/null +++ b/tests/neg/i6061.scala @@ -0,0 +1,2 @@ +opaque object + // error \ No newline at end of file