Closed
Description
Compiler version
3.1.3-RC3
, 3.2.0-RC1-bin-20220517-e5abec0-NIGHTLY
(compiles correctly on 3.1.2
, 3.0.2
, and 2.13.8
)
Minimized code
//> using scala "3.1.3-RC3"
// //> using scala "3.1.2" // works
// //> using scala "3.0.2" // works
// //> using scala "2.13.8" // works
abstract trait A {
var value: Int
}
abstract trait B {
def value: Int = ???
}
class C extends A with B {
override def value: Int = ???
def value_=(newValue: Int): Unit = ???
}
Output
[error] ./main.scala:14:16: error overriding variable value in trait A of type Int;
[error] method value of type => Int cannot override a mutable variable
[error] override def value: Int = ???
[error] ^
Expectation
Compile correctly
Additional info
This is most likely related to issue #14722 and PR that fixed it #14724
Also, note that the following code throws an error too
abstract trait A {
var value: Int
}
class C extends A {
override def value: Int = ???
override def value_=(newValue: Int): Unit = ???
}
namely
[error] ./main.scala:11:16: error overriding variable value in trait A of type Int;
[error] method value of type => Int cannot override a mutable variable
[error] override def value: Int = ???
[error] ^
[error] ./main.scala:12:16: error overriding variable value in trait A of type Int;
[error] method value_= of type (newValue: Int): Unit cannot override a mutable variable
[error] override def value_=(newValue: Int): Unit = ???
[error] ^