Closed
Description
Compiler version
3.0.2
3.1.0-RC2
running on Java 17
Minimized code
I get this error when running the command line with 3.0.2 but also when compiling my project
in SBT with 3.1.0-RC2.
$ scala -version 127 ↵
Scala compiler version 3.0.2 -- Copyright 2002-2021, LAMP/EPFL
$ scala -Yexplicit-nulls 127 ↵
scala> import scala.util.control.NoStackTrace
scala> case class ParseException(line: Int, character: Int, message: String) extends NoStackTrace
-- Error:
1 |case class ParseException(line: Int, character: Int, message: String) extends NoStackTrace
| ^
|class ParseException cannot be defined due to a conflict between its parents when
|implementing a super-accessor for fillInStackTrace in trait NoStackTrace:
|
|1. One of its parent (NoStackTrace) contains a call super.fillInStackTrace in its body,
| and when a super-call in a trait is written without an explicit parent
| listed in brackets, it is implemented by a generated super-accessor in
| the class that extends this trait based on the linearization order of
| the class.
|2. Because Throwable comes before NoStackTrace in the linearization
| order of ParseException, and because Throwable overrides fillInStackTrace,
| the super-accessor in ParseException is implemented as a call to
| super[Throwable].fillInStackTrace.
|3. However,
| (): Throwable | Null (the type of super[Throwable].fillInStackTrace in ParseException)
| is not a subtype of
| (): Throwable (the type of fillInStackTrace in trait NoStackTrace).
| Hence, the super-accessor that needs to be generated in ParseException
| is illegal.
|
|Here are two possible ways to resolve this:
|
|1. Change the linearization order of ParseException such that
| NoStackTrace comes before Throwable.
|2. Alternatively, replace super.fillInStackTrace in the body of trait NoStackTrace by a
| super-call to a specific parent, e.g. super[Throwable].fillInStackTrace
Output
// TODO add output here