Skip to content

Commit f07a4f5

Browse files
committed
Add Symbol.allMembers to reflection API
1 parent 2312258 commit f07a4f5

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

compiler/src/scala/quoted/runtime/impl/QuotesImpl.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2547,6 +2547,13 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler
25472547
def declarations: List[Symbol] =
25482548
self.typeRef.info.decls.toList
25492549

2550+
def allMembers: List[Symbol] =
2551+
lookupPrefix.allMembers.iterator.map(_.symbol).collect {
2552+
case sym if sym.isType => sym.asType
2553+
case sym if isMethod(sym) => sym.asTerm
2554+
case sym if isField(sym) => sym.asTerm
2555+
}.toList
2556+
25502557
def paramSymss: List[List[Symbol]] = self.denot.paramSymss
25512558
def primaryConstructor: Symbol = self.denot.primaryConstructor
25522559
def allOverriddenSymbols: Iterator[Symbol] = self.denot.allOverriddenSymbols

library/src/scala/quoted/Quotes.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3652,6 +3652,9 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching =>
36523652
/** All members directly declared in the class */
36533653
def declarations: List[Symbol]
36543654

3655+
/** All members declared or inherited */
3656+
def allMembers: List[Symbol]
3657+
36553658
/** The symbols of each type parameter list and value parameter list of this
36563659
* method, or Nil if this isn't a method.
36573660
*/

0 commit comments

Comments
 (0)