Skip to content

Commit bf14f5b

Browse files
committed
Refactor: reuse newClass
1 parent 8721213 commit bf14f5b

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

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

+12-13
Original file line numberDiff line numberDiff line change
@@ -2656,21 +2656,20 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler
26562656
conParamNames: List[String],
26572657
conParamTypes: List[TypeRepr],
26582658
): Symbol =
2659-
checkValidFlags(clsFlags, Flags.validClassFlags)
2660-
assert(conParamNames.length == conParamTypes.length, "paramNames and paramTypes must have the same length")
2661-
assert(!clsPrivateWithin.exists || clsPrivateWithin.isType, "clsPrivateWithin must be a type symbol or `Symbol.noSymbol`")
2662-
val cls = dotc.core.Symbols.newNormalizedClassSymbolUsingClassSymbolinParents(
2659+
assert(conParamNames.length == conParamTypes.length, "Lengths of conParamNames and conParamTypes must be equal")
2660+
newClass(
26632661
owner,
2664-
name.toTypeName,
2665-
clsFlags,
2662+
name,
26662663
parents,
2667-
selfType.getOrElse(Types.NoType),
2668-
clsPrivateWithin)
2669-
cls.enter(dotc.core.Symbols.newConstructor(cls, dotc.core.Flags.Synthetic, conParamNames.map(_.toTermName), conParamTypes))
2670-
for (name, tpe) <- conParamNames.zip(conParamTypes) do
2671-
cls.enter(dotc.core.Symbols.newSymbol(cls, name.toTermName, Flags.ParamAccessor, tpe, Symbol.noSymbol))
2672-
for sym <- decls(cls) do cls.enter(sym)
2673-
cls
2664+
decls,
2665+
selfType,
2666+
clsFlags,
2667+
clsPrivateWithin,
2668+
conMethodType = res => MethodType(conParamNames)(_ => conParamTypes, _ => res),
2669+
conFlags = Flags.EmptyFlags,
2670+
conPrivateWithin = Symbol.noSymbol,
2671+
conParamFlags = List(for i <- conParamNames yield Flags.EmptyFlags)
2672+
)
26742673

26752674
def newClass(
26762675
owner: Symbol,

0 commit comments

Comments
 (0)