Skip to content

Commit b1ce4f4

Browse files
committed
Fix #6061: Handle malformed opaque type aliases
1 parent b537220 commit b1ce4f4

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1039,7 +1039,7 @@ class Namer { typer: Typer =>
10391039
val finalSelfInfo: TypeOrSymbol =
10401040
if (cls.isOpaqueCompanion) {
10411041
// The self type of an opaque companion is refined with the type-alias of the original opaque type
1042-
def refineOpaqueCompanionSelfType(mt: Type, stats: List[Tree]): RefinedType = (stats: @unchecked) match {
1042+
def refineOpaqueCompanionSelfType(mt: Type, stats: List[Tree]): Type = (stats: @unchecked) match {
10431043
case (td @ TypeDef(localName, rhs)) :: _
10441044
if td.mods.is(SyntheticOpaque) && localName == name.stripModuleClassSuffix =>
10451045
// create a context owned by the current opaque helper symbol,
@@ -1053,6 +1053,8 @@ class Namer { typer: Typer =>
10531053
RefinedType(mt, localName, bounds)
10541054
case _ :: stats1 =>
10551055
refineOpaqueCompanionSelfType(mt, stats1)
1056+
case _ =>
1057+
mt // can happen for malformed inputs.
10561058
}
10571059
selfInfo match {
10581060
case self: Type =>

tests/neg/i6061.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
opaque object
2+
// error

0 commit comments

Comments
 (0)