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 =>
36903690 /** The symbol of the companion module */
36913691 def companionModule : Symbol
36923692
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`. */
36943694 def children : List [Symbol ]
36953695 end extension
36963696 }
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