diff --git a/compiler/src/dotty/tools/dotc/core/TypeComparer.scala b/compiler/src/dotty/tools/dotc/core/TypeComparer.scala index 0e1abfe060ad..a9438ac8561f 100644 --- a/compiler/src/dotty/tools/dotc/core/TypeComparer.scala +++ b/compiler/src/dotty/tools/dotc/core/TypeComparer.scala @@ -3355,8 +3355,9 @@ class TrackingTypeComparer(initctx: Context) extends TypeComparer(initctx) { stableScrut.member(typeMemberName) match case denot: SingleDenotation if denot.exists => val info = denot.info match - case TypeAlias(alias) => alias - case info => info // Notably, RealTypeBounds, which will eventually give a MatchResult.NoInstances + case TypeAlias(alias) => alias // Extract the alias + case ClassInfo(prefix, cls, _, _, _) => prefix.select(cls) // Re-select the class from the prefix + case info => info // Notably, RealTypeBounds, which will eventually give a MatchResult.NoInstances val infoRefersToSkolem = stableScrut match case stableScrut: SkolemType => new TypeAccumulator[Boolean] { @@ -3365,26 +3366,11 @@ class TrackingTypeComparer(initctx: Context) extends TypeComparer(initctx) { }.apply(false, info) case _ => false - if infoRefersToSkolem && info.isInstanceOf[ClassInfo] then - /* We would like to create a `RealTypeBounds(info, info)` to get a `MatchResult.NoInstances` - * but that is not allowed for `ClassInfo`. So instead we return `false`, which will result - * in a `MatchResult.Stuck` instead. - */ - false - else - val info1 = info match - case ClassInfo(prefix, cls, _, _, _) => - // Re-select the class from the prefix - prefix.select(cls) - case info: TypeBounds => - // Will already trigger a MatchResult.NoInstances - info - case _ if infoRefersToSkolem => - // Explicitly trigger a MatchResult.NoInstances - RealTypeBounds(info, info) - case _ => - info - rec(capture, info1, variance = 0, scrutIsWidenedAbstract) + val info1 = info match + case info: TypeBounds => info // Will already trigger a MatchResult.NoInstances + case _ if infoRefersToSkolem => RealTypeBounds(info, info) // Explicitly trigger a MatchResult.NoInstances + case _ => info // We have a match + rec(capture, info1, variance = 0, scrutIsWidenedAbstract) case _ => false end rec diff --git a/tests/neg/match-type-enumeration-value-hack.check b/tests/neg/match-type-enumeration-value-hack.check index 0847ae5ba18f..13e425b80dbf 100644 --- a/tests/neg/match-type-enumeration-value-hack.check +++ b/tests/neg/match-type-enumeration-value-hack.check @@ -7,5 +7,7 @@ | | trying to reduce EnumValue[Suit] | failed since selector Suit - | does not match case EnumValueAux[t] => t - | and cannot be shown to be disjoint from it either. + | does not uniquely determine parameter t in + | case EnumValueAux[t] => t + | The computed bounds for the parameter are: + | t >: ?1.Value <: ?1.Value