Skip to content

Fix synthesis of mirrors for GADT with dependent type parameters#26080

Open
eejbyfeldt wants to merge 1 commit into
scala:mainfrom
eejbyfeldt:i23774
Open

Fix synthesis of mirrors for GADT with dependent type parameters#26080
eejbyfeldt wants to merge 1 commit into
scala:mainfrom
eejbyfeldt:i23774

Conversation

@eejbyfeldt
Copy link
Copy Markdown
Contributor

@eejbyfeldt eejbyfeldt commented May 18, 2026

This extends the current logic in Synthesizer.scala to instead of doing
a single replacement do it until a fixed point is reached.

Fixes #23774

How much have you relied on LLM-based tools in this contribution?

Extensively, for exploring the code base and determining where the issue was.

How was the solution tested?

New automated tests

@bishabosha
Copy link
Copy Markdown
Member

not really sure about these types, is a wildcard more appropriate?

@eejbyfeldt
Copy link
Copy Markdown
Contributor Author

eejbyfeldt commented May 18, 2026

not really sure about these types, is a wildcard more appropriate?

But that sounds like a different change? To me it seems this MR is not really changing that logic, just applying the current logic in a way that handles more cases.

You will get similar (at least in my understanding) types if you do

scala> enum E[T] {
     |   case A[T2]() extends E[Int]
     | }
// defined class E
                                                                                               
scala> summon[scala.deriving.Mirror.SumOf[E[Int]]]
val res0:
  scala.deriving.Mirror.Sum{
    type MirroredMonoType = E[Int]; type MirroredType = E[Int]; type MirroredLabel = "E";
      type MirroredElemTypes = E.A[Any] *: EmptyTuple.type;
      type MirroredElemLabels = "A" *: EmptyTuple.type
  } = E$@102fd71d

@eejbyfeldt eejbyfeldt marked this pull request as ready for review May 18, 2026 10:51
@bishabosha
Copy link
Copy Markdown
Member

yeah, i guess its fine then, i guess it might be worth having a type class derivation example test case as well.

@eejbyfeldt
Copy link
Copy Markdown
Contributor Author

@bishabosha Added a type class derivation example, let me know if you feel is is motivating enough.

This extends the current logic in Synthesizer.scala to instead of doing
a single replacement do it until a fixed point is reached.

Fixes: scala#23774
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GADT with dependent type parameters causes pickler crash orphan parameter reference when using Mirror

2 participants