Skip to content

Commit 73a8a6e

Browse files
committed
Fix #16438: Ignore erroneous parent call in init check
1 parent 72c4ffd commit 73a8a6e

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

compiler/src/dotty/tools/dotc/transform/init/Semantic.scala

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1663,9 +1663,13 @@ object Semantic:
16631663
// term arguments to B. That can only be done in a concrete class.
16641664
val tref = typeRefOf(klass.typeRef.baseType(mixin).typeConstructor)
16651665
val ctor = tref.classSymbol.primaryConstructor
1666-
if ctor.exists then extendTrace(superParent) {
1667-
superCall(tref, ctor, Nil, tasks)
1668-
}
1666+
if ctor.exists && ctor.paramSymss.isEmpty then
1667+
// The parameter check of traits comes late in the mixin phase.
1668+
// To avoid crash we ignore the initialization check for erroneous
1669+
// parent call code. See tests/neg/i16438.scala.
1670+
extendTrace(superParent) {
1671+
superCall(tref, ctor, args = Nil, tasks)
1672+
}
16691673
}
16701674

16711675
// initialize super classes after outers are set

tests/neg/i16438.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// scalac: -Ysafe-init
2+
trait ATrait(val string: String, val int: Int)
3+
trait AnotherTrait( override val string: String, override val int: Int) extends ATrait
4+
case class ACaseClass(override val string: String) extends AnotherTrait(string, 3) // error

0 commit comments

Comments
 (0)