-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Summoning Mirror for ADT defined in trait #13332
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
workaround is to give a companion object to |
Thanks @bishabosha! Unfortunately this is ultimately for https://github.com/typelevel/kittens where we summon |
@bishabosha is there any chance we could tweak the accessibility test before 3.1? |
if we tweak the accessibility rules to allow this case, then changing class Scope2 extends ZListDefn {
type Of = Mirror { type MirroredType = ZList; type MirroredMonoType = ZList ; type MirroredElemTypes <: Tuple }
val M = summon[Of]
}
class ZListDefn {
sealed trait ZList
case class ZNil() extends ZList
case class ZCons(h: Boolean, t: ZList) extends ZList
} with the same cause as #12328, summarised by my comment here #12328 (comment), the fix is more involved as it requires substituting the correct prefix into the types of the sealed children |
Yes, for the moment this is simply out of spec. We generate mirrors only for statically accessible classes. I would advise to go slowly here and make absolutely sure that each generalization step can be made without negative consequences. |
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
Not sure how that's related to accessibility - it sounds like incorrect handling of prefixes when generating a mirror. In general I think Scala users expect nesting to just work in most cases. Restricting certain features to only statically accessible symbols sounds very hard to explain. |
I think if we look for a mirror of |
I am trying this is #13502, I still need to test in more cases |
We can dig out some test cases from Shapeless 2 or Magnolia for Scala 2 |
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
Test scala#13332 with a classpath dependency
Uh oh!
There was an error while loading. Please reload this page.
Compiler version
scala-3.1.0-RC1-bin-20210817-f27c250-NIGHTLY (I tried to use the most recent I could find as I thought there's a chance that #11686 might have fixed this as it's in a similar area. Not entirely sure if that made it into this nightly or not)
Minimized code
Output
Expectation
Compilation should succeed (and does if you move the
IList
definition out of the trait and up to top-level)The text was updated successfully, but these errors were encountered: