question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

sum mirror is available when mirror for child can't be summoned

See original GitHub issue

The 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:closed
  • Created a year ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
bishaboshacommented, May 23, 2022

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 mention Bar in its MirroredElemTypes. the user should then be able to iterate through MirroredElemTypes (with inline method or macro) to summon the mirror for Bar programatically. This operation is meant to be total

0reactions
joroKr21commented, May 23, 2022

Hmm I didn’t know that - what is the reason for this limitation?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found