Skip to content

Commit 1787e74

Browse files
EugeneFlesselleWojciechMazur
authored andcommitted
Normalize mirrorType before reducing to mirrorSource
[Cherry-picked d3174a1]
1 parent 8f59a2c commit 1787e74

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ class Synthesizer(typer: Typer)(using @constructorOnly c: Context):
338338
* or a TermRef to a singleton value. These are
339339
* the base elements required to generate a mirror.
340340
*/
341-
def reduce(mirroredType: Type)(using Context): Either[String, MirrorSource] = mirroredType match
341+
def reduce(mirroredType: Type)(using Context): Either[String, MirrorSource] = mirroredType.normalized match
342342
case tp: TypeRef =>
343343
val sym = tp.symbol
344344
if sym.isClass then // direct ref to a class, not an alias

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)