Skip to content

Commit d3174a1

Browse files
Normalize mirrorType before reducing to mirrorSource
1 parent a3854cb commit d3174a1

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
@@ -339,7 +339,7 @@ class Synthesizer(typer: Typer)(using @constructorOnly c: Context):
339339
* or a TermRef to a singleton value. These are
340340
* the base elements required to generate a mirror.
341341
*/
342-
def reduce(mirroredType: Type)(using Context): Either[String, MirrorSource] = mirroredType match
342+
def reduce(mirroredType: Type)(using Context): Either[String, MirrorSource] = mirroredType.normalized match
343343
case tp: TypeRef =>
344344
val sym = tp.symbol
345345
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)