Closed
Description
The fix for #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 d6e17a2 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.