Skip to content

Commit 270d8b6

Browse files
committed
Add reflect ClassDef.apply
1 parent b472e26 commit 270d8b6

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,9 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler
228228
end ClassDefTypeTest
229229

230230
object ClassDef extends ClassDefModule:
231+
def apply(cls: Symbol, constr: DefDef, parents: List[Tree], body: List[Statement]): ClassDef =
232+
tpd.ClassDefWithParents(cls, constr, parents, body)
233+
231234
def copy(original: Tree)(name: String, constr: DefDef, parents: List[Tree], selfOpt: Option[ValDef], body: List[Statement]): ClassDef = {
232235
val dotc.ast.Trees.TypeDef(_, originalImpl: tpd.Template) = original
233236
tpd.cpy.TypeDef(original)(name.toTypeName, tpd.cpy.Template(originalImpl)(constr, parents, derived = Nil, selfOpt.getOrElse(tpd.EmptyValDef), body))

library/src/scala/quoted/Quotes.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,7 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching =>
464464

465465
/** Methods of the module object `val ClassDef` */
466466
trait ClassDefModule { this: ClassDef.type =>
467+
@experimental def apply(cls: Symbol, constr: DefDef, parents: List[Tree /* Term | TypeTree */], body: List[Statement]): ClassDef
467468
def copy(original: Tree)(name: String, constr: DefDef, parents: List[Tree /* Term | TypeTree */], selfOpt: Option[ValDef], body: List[Statement]): ClassDef
468469
def unapply(cdef: ClassDef): (String, DefDef, List[Tree /* Term | TypeTree */], Option[ValDef], List[Statement])
469470
}

0 commit comments

Comments
 (0)