Skip to content

Commit

Permalink
Backport "Fix infinite loop in Mirror synthesis of unreducible match …
Browse files Browse the repository at this point in the history
…type" to LTS (#21042)

Backports #20133 to the LTS branch.

PR submitted by the release tooling.
[skip ci]
  • Loading branch information
WojciechMazur authored Jul 5, 2024
2 parents 47cb24c + f73c990 commit d57fb04
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
4 changes: 3 additions & 1 deletion compiler/src/dotty/tools/dotc/typer/Synthesizer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,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
Expand Down
13 changes: 13 additions & 0 deletions tests/neg/i19198.scala
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit d57fb04

Please sign in to comment.