Symbol.newClass
seems to automatically add a Symbol for a parameter-less primary constructor and there doesn’t seem to be a way to change it.
The best I could come up with is to use the compiler types directly:
val ctorMethodType = MethodType(paramNames)(paramInfosExp, _ => cls.typeRef)
val ctorSym = Symbol.newMethod(cls, ctorName, ctorMethodType, Flags.Synthetic, Symbol.noSymbol)
cls.asInstanceOf[dotty.tools.dotc.core.Symbols.ClassSymbol]
.replace(
cls.primaryConstructor.asInstanceOf[dotty.tools.dotc.core.Symbols.Symbol],
ctorSym.asInstanceOf[dotty.tools.dotc.core.Symbols.Symbol]
)
Is this an oversight or was it left out intentionally?