Summoning Mirror for ADT defined in trait
See original GitHub issueCompiler 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 https://github.com/lampepfl/dotty/pull/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
import scala.deriving.Mirror
class Scope extends IListDefn {
type Of = Mirror { type MirroredType[X] = IList[X]; type MirroredMonoType = IList[Any] ; type MirroredElemTypes[_] <: Tuple }
val M = summon[Of]
}
trait IListDefn {
sealed trait IList[A]
case class INil[A]() extends IList[A]
case class ICons[A](h: A, t: IList[A]) extends IList[A]
}
Output
[error] -- Error: /private/tmp/scala/Minimization.scala:7:20 ---------------------------
[error] 7 | val M = summon[Of]
[error] | ^
[error] |no implicit argument of type Scope.this.Of was found for parameter x of method summon in object Predef
[error] one error found
Expectation
Compilation should succeed (and does if you move the IList
definition out of the trait and up to top-level)
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:9 (6 by maintainers)
Top Results From Across the Web
Type Class Derivation
Sum types (i.e. sealed class or traits with product children, and enums) have mirrors which are subtypes of Mirror.Sum . For the Tree...
Read more >Type Class Derivation
Product types (i.e. case classes and objects, and enum cases) have mirrors which are subtypes of Mirror.Product . Sum types (i.e. sealed class...
Read more >quotes.reflect.memberType can return ClassInfo #15159
I'm trying to summon a typeclass instance for each child class of a sealed trait. So far I've got the following code (here...
Read more >Automatically Deriving Typeclass Instances in Scala 3
For now, the most important part of the Mirror is the breakdown between Sum and Product . Our BinaryTree is an Algebraic Data...
Read more >circe/circe - Gitter
I'm trying to take a Json circe object in Java and call .as(ObjectDefinedInScalaW@JsonCodeAnnotation) . But obviously Java doesn't have implicit decoders. Is my ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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.
@bishabosha is there any chance we could tweak the accessibility test before 3.1?