Skip to content

Commit d57fb04

Browse files
Backport "Fix infinite loop in Mirror synthesis of unreducible match type" to LTS (#21042)
Backports #20133 to the LTS branch. PR submitted by the release tooling. [skip ci]
2 parents 47cb24c + f73c990 commit d57fb04

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,9 @@ class Synthesizer(typer: Typer)(using @constructorOnly c: Context):
378378
// avoid type aliases for tuples
379379
Right(MirrorSource.GenericTuple(types))
380380
case _ => reduce(tp.underlying)
381-
case tp: MatchType => reduce(tp.normalized)
381+
case tp: MatchType =>
382+
val n = tp.tryNormalize
383+
if n.exists then reduce(n) else Left(i"its subpart `$tp` is an unreducible match type.")
382384
case _ => reduce(tp.superType)
383385
case tp @ AndType(l, r) =>
384386
for

tests/neg/i19198.scala

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import deriving.Mirror
2+
import compiletime.summonInline
3+
4+
type DoesNotReduce[T] = T match
5+
case String => Any
6+
7+
type DoesNotReduce2[T] <: T = T match
8+
case String => T
9+
10+
class Foo
11+
@main def Test: Unit =
12+
summonInline[Mirror.Of[DoesNotReduce[Option[Int]]]] // error
13+
summonInline[Mirror.Of[DoesNotReduce2[Option[Int]]]] // error

0 commit comments

Comments
 (0)