Skip to content

Commit 2279afc

Browse files
authored
Merge pull request #13232 from dotty-staging/fix-#13230
Fix docs of Reflect.Symbol.children
2 parents 3aa6e2f + 10d6a8f commit 2279afc

File tree

4 files changed

+15
-1
lines changed

4 files changed

+15
-1
lines changed

library/src/scala/quoted/Quotes.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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
}

tests/run-macros/i13230.check

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
List((A,E), (B,E))
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
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+

tests/run-macros/i13230/Test_2.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@main def Test = println(showEnumChildren)

0 commit comments

Comments
 (0)