Skip to content

Commit bdeb05a

Browse files
authored
Normalise mirrorType for mirror Synthesis (#19199)
If `MirrorSource.reduce` is given a proxy to an unreduced match type, it will simply get its supertype `Any`. We need to normalise the `mirroredType` before attempting to reduce it to a kind of mirror source. Fix #19198
2 parents fa49c51 + f7e2e7c commit bdeb05a

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,7 @@ class Synthesizer(typer: Typer)(using @constructorOnly c: Context):
379379
// avoid type aliases for tuples
380380
Right(MirrorSource.GenericTuple(types))
381381
case _ => reduce(tp.underlying)
382+
case tp: MatchType => reduce(tp.normalized)
382383
case _ => reduce(tp.superType)
383384
case tp @ AndType(l, r) =>
384385
for

tests/pos/i19198.scala

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import deriving.Mirror
2+
import compiletime.summonInline
3+
4+
inline def check1[Tps <: NonEmptyTuple]: Unit =
5+
summonInline[Mirror.Of[Tuple.Head[Tps]]]
6+
7+
inline def check2[Tps <: NonEmptyTuple]: Unit =
8+
type FromType = Tuple.Head[Tps]
9+
summonInline[Mirror.Of[FromType]]
10+
11+
@main def Test: Unit =
12+
check1[Option[Int] *: EmptyTuple] // Ok
13+
check2[Option[Int] *: EmptyTuple] // Error: FromType is widened to Any in Syntheziser

0 commit comments

Comments
 (0)