-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Compiler crash when deriving typeclass for a sum type defined inside a def #12328
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
Comments
We might have to disable mirror generation for local classes |
I think the cause of this bug is just that the generated Mirror type does not preserve prefixes when the summoned type is path dependent - i.e given this example of an inner class sealed hierarchy: class Outer {
sealed trait Item
object Item {
case class A() extends Item
case class B() extends Item
}
}
@main def hello: Unit = {
val o = new Outer()
val mItem = summon[Mirror.Of[o.Item]] // summon path dependent Mirror
}
val mItem:
(
deriving.Mirror{
MirroredType = o.Item; MirroredMonoType = o.Item;
MirroredElemTypes <: Tuple
}
&
scala.deriving.Mirror.Sum{
MirroredMonoType = o.Item; MirroredType = o.Item;
MirroredLabel = ("Item" : String)
}
){
MirroredElemTypes = (Outer.Item.A, Outer.Item.B);
MirroredElemLabels = (("A" : String), ("B" : String))
}
=
o.Item.$asInstanceOf[...] so when we project on the @main def hello: Unit = {
val o = new Outer()
val mItem = summon[Mirror.Of[o.Item]]
type oItemA = Tuple.Head[mItem.MirroredElemTypes]
val mA = summon[Mirror.Of[oItemA]]
} generates: @main def hello: Unit = {
...
type oItemA = Outer.Item.A
val mA: (...) =
Outer.this.Item.this.A.$asInstanceOf[...] // note the outer accessor here
} the |
We worked through a load of similar issues in shapeless 2 on Scala 2, and in the end people came to expect that shapeless's |
I'm currently trying a fix to splice the right prefix in |
add a new method healPrefix which converts ThisTypes wrapping a Module into a TermRef and subsitutes ThisType of enclosing classes with matching parts of the prefix of the summoned mirror fixes scala#12328 fixes scala#11174
add a new method healPrefix which converts ThisTypes wrapping a Module into a TermRef and subsitutes ThisType of enclosing classes with matching parts of the prefix of the summoned mirror fixes scala#12328 fixes scala#11174
add a new method healPrefix which converts ThisTypes wrapping a Module into a TermRef and subsitutes ThisType of enclosing classes with matching parts of the prefix of the summoned mirror fixes scala#12328 fixes scala#11174
add a new method healPrefix which converts ThisTypes wrapping a Module into a TermRef and subsitutes ThisType of enclosing classes with matching parts of the prefix of the summoned mirror fixes scala#12328 fixes scala#11174
add a new method healPrefix which converts ThisTypes wrapping a Module into a TermRef and subsitutes ThisType of enclosing classes with matching parts of the prefix of the summoned mirror fixes scala#12328 fixes scala#11174
add a new method healPrefix which converts ThisTypes wrapping a Module into a TermRef and subsitutes ThisType of enclosing classes with matching parts of the prefix of the summoned mirror fixes scala#12328 fixes scala#11174
add a new method healPrefix which converts ThisTypes wrapping a Module into a TermRef and subsitutes ThisType of enclosing classes with matching parts of the prefix of the summoned mirror fixes scala#12328 fixes scala#11174 use do not force symbols add safety for unknown type experiment with TypeOps.refineUsingParent support hk types rebase fixes disable for scala2x generic product nonstatic simplify a bit add more tests find common prefix of and/or types refine implementation based on runtime tests experiment with supertypes remove prefix splice in companionref
mirror synthesis has worked with local case classes since |
I don't know. Probably not. But somebody will have to fix the issues otherwise. |
ill see where I get |
Compiler version
3.0.0-RC3
Minimized code
The problem disappears if I move the sealed trait definition outside of the def. It also disappears if I have a given for A and B in scope.
Output (click arrow to expand)
The text was updated successfully, but these errors were encountered: