Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible regression in refchecks when overriding a mutable variable #15232

Closed
KacperFKorban opened this issue May 19, 2022 · 1 comment
Closed
Labels
itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label

Comments

@KacperFKorban
Copy link
Member

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]                ^
@KacperFKorban KacperFKorban added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels May 19, 2022
@smarter
Copy link
Member

smarter commented May 19, 2022

Duplicate of #13019.

@smarter smarter closed this as completed May 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label
Projects
None yet
Development

No branches or pull requests

2 participants