File tree Expand file tree Collapse file tree 4 files changed +15
-1
lines changed Expand file tree Collapse file tree 4 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -3690,7 +3690,7 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching =>
3690
3690
/** The symbol of the companion module */
3691
3691
def companionModule : Symbol
3692
3692
3693
- /** Case class or case object children of a sealed trait */
3693
+ /** Case class or case object children of a sealed trait or cases of an `enum`. */
3694
3694
def children : List [Symbol ]
3695
3695
end extension
3696
3696
}
Original file line number Diff line number Diff line change
1
+ List((A,E), (B,E))
Original file line number Diff line number Diff line change
1
+ import scala .quoted .*
2
+
3
+ enum E :
4
+ case A , B
5
+
6
+ inline def showEnumChildren = $ { showEnumChildrenExpr }
7
+
8
+ def showEnumChildrenExpr (using Quotes ) =
9
+ import quotes .reflect .*
10
+ val repr = TypeRepr .of[E ]
11
+ Expr (TypeRepr .of[E ].classSymbol.get.children.map(sym => (sym.name, repr.memberType(sym).show)))
12
+
Original file line number Diff line number Diff line change
1
+ @ main def Test = println(showEnumChildren)
You can’t perform that action at this time.
0 commit comments