@@ -228,6 +228,10 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler
228
228
end ClassDefTypeTest
229
229
230
230
object ClassDef extends ClassDefModule :
231
+ def apply (cls : Symbol , parents : List [Tree ], body : List [Statement ]): ClassDef =
232
+ val constr = ctx.typeAssigner.assignType(untpd.DefDef (nme.CONSTRUCTOR , Nil , tpd.TypeTree (dotc.core.Symbols .defn.UnitClass .typeRef), untpd.EmptyTree ), cls.primaryConstructor)
233
+ tpd.ClassDefWithParents (cls.asClass, constr, parents, body)
234
+
231
235
def copy (original : Tree )(name : String , constr : DefDef , parents : List [Tree ], selfOpt : Option [ValDef ], body : List [Statement ]): ClassDef = {
232
236
val dotc .ast.Trees .TypeDef (_, originalImpl : tpd.Template ) = original
233
237
tpd.cpy.TypeDef (original)(name.toTypeName, tpd.cpy.Template (originalImpl)(constr, parents, derived = Nil , selfOpt.getOrElse(tpd.EmptyValDef ), body))
@@ -260,6 +264,7 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler
260
264
261
265
object DefDef extends DefDefModule :
262
266
def apply (symbol : Symbol , rhsFn : List [List [Tree ]] => Option [Term ]): DefDef =
267
+ assert(symbol.isTerm, s " expected a term symbol but received $symbol" )
263
268
withDefaultPos(tpd.DefDef (symbol.asTerm, prefss =>
264
269
xCheckMacroedOwners(xCheckMacroValidExpr(rhsFn(prefss)), symbol).getOrElse(tpd.EmptyTree )
265
270
))
@@ -1804,7 +1809,7 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler
1804
1809
(x.prefix, x.name.toString)
1805
1810
end TermRef
1806
1811
1807
- type TypeRef = dotc.core.Types .NamedType
1812
+ type TypeRef = dotc.core.Types .TypeRef
1808
1813
1809
1814
object TypeRefTypeTest extends TypeTest [TypeRepr , TypeRef ]:
1810
1815
def unapply (x : TypeRepr ): Option [TypeRef & x.type ] = x match
@@ -2454,6 +2459,20 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler
2454
2459
def requiredModule (path : String ): Symbol = dotc.core.Symbols .requiredModule(path)
2455
2460
def requiredMethod (path : String ): Symbol = dotc.core.Symbols .requiredMethod(path)
2456
2461
def classSymbol (fullName : String ): Symbol = dotc.core.Symbols .requiredClass(fullName)
2462
+
2463
+ def newClass (owner : Symbol , name : String , parents : List [TypeRepr ], decls : Symbol => List [Symbol ], selfInfo : Option [TypeRepr ]): Symbol =
2464
+ val cls = dotc.core.Symbols .newNormalizedClassSymbol(
2465
+ owner,
2466
+ name.toTypeName,
2467
+ Flags .EmptyFlags ,
2468
+ parents,
2469
+ dotc.core.Scopes .newScope, // TODO remove from parameters of newNormalizedClassSymbol
2470
+ selfInfo.getOrElse(Types .NoType ),
2471
+ dotc.core.Symbols .NoSymbol )
2472
+ cls.enter(dotc.core.Symbols .newConstructor(cls, dotc.core.Flags .Synthetic , Nil , Nil ))
2473
+ for sym <- decls(cls) do cls.enter(sym)
2474
+ cls
2475
+
2457
2476
def newMethod (owner : Symbol , name : String , tpe : TypeRepr ): Symbol =
2458
2477
newMethod(owner, name, tpe, Flags .EmptyFlags , noSymbol)
2459
2478
def newMethod (owner : Symbol , name : String , tpe : TypeRepr , flags : Flags , privateWithin : Symbol ): Symbol =
0 commit comments