Skip to content

Commit

Permalink
Fix #16438: Ignore erroneous parent call in init check
Browse files Browse the repository at this point in the history
  • Loading branch information
liufengyun committed Nov 30, 2022
1 parent 72c4ffd commit 73a8a6e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
10 changes: 7 additions & 3 deletions compiler/src/dotty/tools/dotc/transform/init/Semantic.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions tests/neg/i16438.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// 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

0 comments on commit 73a8a6e

Please sign in to comment.