File tree Expand file tree Collapse file tree 2 files changed +6
-17
lines changed
library/src/scala/deriving Expand file tree Collapse file tree 2 files changed +6
-17
lines changed Original file line number Diff line number Diff line change @@ -53,7 +53,7 @@ object Mirror {
5353 extension [T ](p : ProductOf [T ])
5454 /** Create a new instance of type `T` with elements taken from product `a`. */
5555 @ annotation.experimental
56- def fromProductTyped [A <: scala.Product ](a : A )(using m : ProductOf [A ], ev : p. MirroredElemTypes =:= m. MirroredElemTypes ): T =
56+ def fromProductTyped [A <: scala.Product , Elems <: p. MirroredElemTypes ](a : A )(using m : ProductOf [A ] { type MirroredElemTypes = Elems } ): T =
5757 p.fromProduct(a)
5858
5959 /** Create a new instance of type `T` with elements taken from tuple `t`. */
Original file line number Diff line number Diff line change 1- import deriving . MirrorOf
1+ import reflect . Generic
22
3- sealed trait A
3+ sealed trait A derives Generic // error: cannot take shape, it has anonymous or inaccessible subclasses
44
55object A {
66 def f () = {
@@ -9,28 +9,17 @@ object A {
99 }
1010}
1111
12- def aMirror = summon[Mirror .Of [A ]] // error: cannot take shape, it has anonymous or inaccessible subclasses
13-
14- sealed trait B
12+ sealed trait B derives Generic // error: cannot take shape, its subclass class D is not a case class
1513
1614class D (x : Int , y : String ) extends B
1715
18- def bMirror = summon[Mirror .Of [B ]] // error: cannot take shape, its subclass class D is not a case class
19-
20- class E
21- def eMirror = summon[Mirror .Of [E ]] // error: cannot take shape, it is neither sealed nor a case class
16+ class E derives Generic // error: cannot take shape, it is neither sealed nor a case class
2217
23- sealed trait F
24- def fMirror = summon[Mirror .Of [F ]] // error: cannot take shape, it has anonymous or inaccessible subclasses
18+ sealed trait F derives Generic // error: cannot take shape, it has anonymous or inaccessible subclasses
2519
2620object G {
2721 def f () = {
2822 case class H () extends F
2923 }
3024}
3125
32- case class I (x : Int , y : String )
33- object I :
34- def f = summon[deriving.Mirror .ProductOf [I ]].fromProductTyped((1 , 2 )) // error
35- def g = summon[deriving.Mirror .ProductOf [I ]].fromTuple((1 , 2 )) // error
36-
You can’t perform that action at this time.
0 commit comments