diff --git a/compiler/src/dotty/tools/dotc/transform/init/Semantic.scala b/compiler/src/dotty/tools/dotc/transform/init/Semantic.scala index a48aa77fe79f..10eb28943770 100644 --- a/compiler/src/dotty/tools/dotc/transform/init/Semantic.scala +++ b/compiler/src/dotty/tools/dotc/transform/init/Semantic.scala @@ -1663,9 +1663,13 @@ object Semantic: // term arguments to B. That can only be done in a concrete class. val tref = typeRefOf(klass.typeRef.baseType(mixin).typeConstructor) val ctor = tref.classSymbol.primaryConstructor - if ctor.exists then extendTrace(superParent) { - superCall(tref, ctor, Nil, tasks) - } + if ctor.exists && ctor.paramSymss.isEmpty then + // The parameter check of traits comes late in the mixin phase. + // To avoid crash we ignore the initialization check for erroneous + // parent call code. See tests/neg/i16438.scala. + extendTrace(superParent) { + superCall(tref, ctor, args = Nil, tasks) + } } // initialize super classes after outers are set diff --git a/tests/neg/i16438.scala b/tests/neg/i16438.scala new file mode 100644 index 000000000000..e37e25782cdf --- /dev/null +++ b/tests/neg/i16438.scala @@ -0,0 +1,5 @@ + +// // scalac: -Ysafe-init +trait ATrait(val string: String, val int: Int) +trait AnotherTrait( override val string: String, override val int: Int) extends ATrait +case class ACaseClass(override val string: String) extends AnotherTrait(string, 3) // error