sum mirror is available when mirror for child can't be summoned
See original GitHub issueThe fix for https://github.com/lampepfl/dotty/pull/14986 does not consider when a sum type has a child for which the mirror can not be summoned.
Compiler version
3.2.0-RC1-bin-20220517-e5abec0-NIGHTLY
First bad commit d6e17a23e65e8efa0dea608eb5dbfc490a977bd1 in #15008
Minimized code
import scala.deriving.Mirror
package lib {
sealed trait Foo
object Foo // Mirror.Of[Foo] cached in companion
case class Bar private[lib] () extends Foo
case object Bar // force mirror for Bar to be anonymous.
}
package app {
val mFoo = summon[Mirror.SumOf[lib.Foo]]
val mBar = summon[Mirror.ProductOf[lib.Bar]] // error
}
Output
-- Error: test.scala:11:49 -------------------------------------------------------------
11 | val mBar = summon[Mirror.ProductOf[lib.Bar]] // error
| ^
|No given instance of type deriving.Mirror.ProductOf[lib.Bar] was found for parameter x of method summon in object Predef. Failed to synthesize an instance of type deriving.Mirror.ProductOf[lib.Bar]: class Bar is not a generic product because the constructor of class Bar is innaccessible from the calling scope.
Expectation
summon[Mirror.SumOf[lib.Foo]]
should also fail because in the calling scope, the child of Foo, i.e. Bar
can not have a mirror - this affects signatures of Foo, because object Foo should not cache the mirror.
Issue Analytics
- State:
- Created a year ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
How do Mirrors Work? + more videos - YouTube
Physics Videos. How do Mirrors Work? + more videos | # aumsum # kids #science #education # children. 1.1M views 1 year ago....
Read more >What is the Color of a Mirror? + more videos | #aumsum #kids ...
This is called specular reflection. Thus, it creates an image of whatever is in front of it. Now, mirrors best reflect light at...
Read more >Laws of Reflection | #aumsum #kids #science ... - YouTube
Our topic for today is Laws of Reflection.Consider this ray of light which strikes a mirror.This ray of light is called the incident...
Read more >Why is your reflection upside down on a spoon ... - YouTube
Concave Mirror - Why is your reflection upside down on a spoon? | # aumsum # kids #science.
Read more >Kids (and Animals) Who Fail Classic Mirror Tests May Still ...
The classic mirror test of self-recognition starts with a mark placed on a subject's body, somewhere he or she can't see it without ......
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 FreeTop 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
Top GitHub Comments
mirrors are meant to represent an algebraic data type, and that all parts mentioned by the mirror should be reachable. The mirror for
Foo
will mentionBar
in itsMirroredElemTypes
. the user should then be able to iterate throughMirroredElemTypes
(with inline method or macro) to summon the mirror forBar
programatically. This operation is meant to be totalHmm I didn’t know that - what is the reason for this limitation?