diff --git a/compiler/src/dotty/tools/dotc/typer/Synthesizer.scala b/compiler/src/dotty/tools/dotc/typer/Synthesizer.scala index c94724faf4d4..d244af12dd91 100644 --- a/compiler/src/dotty/tools/dotc/typer/Synthesizer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Synthesizer.scala @@ -379,7 +379,9 @@ class Synthesizer(typer: Typer)(using @constructorOnly c: Context): // avoid type aliases for tuples Right(MirrorSource.GenericTuple(types)) case _ => reduce(tp.underlying) - case tp: MatchType => reduce(tp.normalized) + case tp: MatchType => + val n = tp.tryNormalize + if n.exists then reduce(n) else Left(i"its subpart `$tp` is an unreducible match type.") case _ => reduce(tp.superType) case tp @ AndType(l, r) => for diff --git a/tests/neg/i19198.scala b/tests/neg/i19198.scala new file mode 100644 index 000000000000..be4fc1602697 --- /dev/null +++ b/tests/neg/i19198.scala @@ -0,0 +1,13 @@ +import deriving.Mirror +import compiletime.summonInline + +type DoesNotReduce[T] = T match + case String => Any + +type DoesNotReduce2[T] <: T = T match + case String => T + +class Foo +@main def Test: Unit = + summonInline[Mirror.Of[DoesNotReduce[Option[Int]]]] // error + summonInline[Mirror.Of[DoesNotReduce2[Option[Int]]]] // error