Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MatchType not normalised for mirror synthesis when aliased #19198

Closed
EugeneFlesselle opened this issue Dec 5, 2023 · 0 comments · Fixed by #19199
Closed

MatchType not normalised for mirror synthesis when aliased #19198

EugeneFlesselle opened this issue Dec 5, 2023 · 0 comments · Fixed by #19199
Assignees
Labels
area:metaprogramming:reflection Issues related to the quotes reflection API itype:bug

Comments

@EugeneFlesselle
Copy link
Contributor

Minimized code

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

Output

13 |  check2[Option[Int] *: EmptyTuple] // Error: FromType is widened to Any in Syntheziser
   |  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |No given instance of type scala.deriving.Mirror.Of[FromType] was found. Failed to synthesize an instance of type scala.deriving.Mirror.Of[FromType]:
   |    * class Any is not a generic product because it is not a case class
   |    * class Any is not a generic sum because it is not a sealed class
   |--------------------------------------------------------------------------------------------------------------------

Expectation

FromType alias should make no difference.

@EugeneFlesselle EugeneFlesselle added itype:bug area:metaprogramming:reflection Issues related to the quotes reflection API labels Dec 5, 2023
@EugeneFlesselle EugeneFlesselle self-assigned this Dec 5, 2023
bishabosha added a commit that referenced this issue Dec 12, 2023
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:metaprogramming:reflection Issues related to the quotes reflection API itype:bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant