Skip to content

Commit

Permalink
Normalise mirrorType for mirror Synthesis (#19199)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bishabosha committed Dec 12, 2023
2 parents fa49c51 + f7e2e7c commit bdeb05a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions compiler/src/dotty/tools/dotc/typer/Synthesizer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,7 @@ 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 _ => reduce(tp.superType)
case tp @ AndType(l, r) =>
for
Expand Down
13 changes: 13 additions & 0 deletions tests/pos/i19198.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import deriving.Mirror
import compiletime.summonInline

inline def check1[Tps <: NonEmptyTuple]: Unit =
summonInline[Mirror.Of[Tuple.Head[Tps]]]

inline def check2[Tps <: NonEmptyTuple]: Unit =
type FromType = Tuple.Head[Tps]
summonInline[Mirror.Of[FromType]]

@main def Test: Unit =
check1[Option[Int] *: EmptyTuple] // Ok
check2[Option[Int] *: EmptyTuple] // Error: FromType is widened to Any in Syntheziser

0 comments on commit bdeb05a

Please sign in to comment.