diff --git a/library/src/scala/quoted/Quotes.scala b/library/src/scala/quoted/Quotes.scala index e3a4075e6821..4a0b2eae3817 100644 --- a/library/src/scala/quoted/Quotes.scala +++ b/library/src/scala/quoted/Quotes.scala @@ -3690,7 +3690,7 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching => /** The symbol of the companion module */ def companionModule: Symbol - /** Case class or case object children of a sealed trait */ + /** Case class or case object children of a sealed trait or cases of an `enum`. */ def children: List[Symbol] end extension } diff --git a/tests/run-macros/i13230.check b/tests/run-macros/i13230.check new file mode 100644 index 000000000000..01b246fb33f6 --- /dev/null +++ b/tests/run-macros/i13230.check @@ -0,0 +1 @@ +List((A,E), (B,E)) diff --git a/tests/run-macros/i13230/Macros_1.scala b/tests/run-macros/i13230/Macros_1.scala new file mode 100644 index 000000000000..424358e83b1a --- /dev/null +++ b/tests/run-macros/i13230/Macros_1.scala @@ -0,0 +1,12 @@ +import scala.quoted.* + +enum E: + case A, B + +inline def showEnumChildren = ${ showEnumChildrenExpr } + +def showEnumChildrenExpr(using Quotes) = + import quotes.reflect.* + val repr = TypeRepr.of[E] + Expr(TypeRepr.of[E].classSymbol.get.children.map(sym => (sym.name, repr.memberType(sym).show))) + diff --git a/tests/run-macros/i13230/Test_2.scala b/tests/run-macros/i13230/Test_2.scala new file mode 100644 index 000000000000..23f582ac9c94 --- /dev/null +++ b/tests/run-macros/i13230/Test_2.scala @@ -0,0 +1 @@ +@main def Test = println(showEnumChildren)