Skip to content

Commit 0bee7b1

Browse files
committed
Add ClassDef.supertypes to reflection API
1 parent daeed81 commit 0bee7b1

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,11 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler
246246
optional(self.rhs.asInstanceOf[tpd.Template].self)
247247
def body: List[Statement] =
248248
self.rhs.asInstanceOf[tpd.Template].body
249+
def supertypes: List[TypeRepr] = self.symbol match
250+
case cls: dotc.core.Symbols.ClassSymbol =>
251+
val ref = cls.classDenot.classInfo.appliedRef
252+
ref.baseClasses.map(ref.baseType(_))
253+
case _ => List()
249254
end extension
250255
end ClassDefMethods
251256

library/src/scala/quoted/Quotes.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,10 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching =>
490490
* @syntax markdown
491491
*/
492492
def body: List[Statement]
493+
494+
/** Supertypes of the class */
495+
def supertypes: List[TypeRepr]
496+
493497
end extension
494498
end ClassDefMethods
495499

0 commit comments

Comments
 (0)