Skip to content

Commit 30982b1

Browse files
committed
Add a paragraph about Mirrors for hierarchical sum types
1 parent 31f3083 commit 30982b1

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

blog/_posts/2021-10-19-scala-3.1.0-released.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,20 @@ For the sake of compatibility with Scala 2, the Scala 3 compiler now generates g
7070

7171
that were true in Scala 2, will also remain true when compiled with Scala 3.
7272

73+
### Mirrors for Hierarchical Sealed Types
74+
75+
Consider the following sealed hierarchy:
76+
77+
```scala
78+
sealed trait Top
79+
case class Middle() extends Top with Bottom
80+
sealed trait Bottom extends Top
81+
```
82+
83+
Previously you would not be able to summon an instance of `scala.deriving.Mirror.SumOf` for `Top`, as its child `Bottom` is also sealed. In Scala 3.1 this is now possible, enabling compiletime reflection over nested hierarchies of sealed types.
84+
85+
The only change necessary for users is that you should now consider that one of the `MirroredElemTypes` for a `Mirror.SumOf could also be a sum type, not just product types.
86+
7387
### Other changes
7488

7589
- Scastie was integrated into Scaladoc to make snippets interactive.

0 commit comments

Comments
 (0)