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

method cannot override immutable value #9840

Closed
scabug opened this issue Jun 30, 2016 · 5 comments
Closed

method cannot override immutable value #9840

scabug opened this issue Jun 30, 2016 · 5 comments
Assignees
Labels
Milestone

Comments

@scabug
Copy link

scabug commented Jun 30, 2016

The following code compiles with 2.12 (but it shouldn't) and doesn't compile with plain 2.11

abstract class Node(name: String) {
  var value: Option[Boolean] = None
}

case class Group(name: String, nodes: Node*) extends Node(name) {
  override def value = ???

  override def value_=(b: Option[Boolean]) = ???

}
@scabug
Copy link
Author

scabug commented Jun 30, 2016

Imported From: https://issues.scala-lang.org/browse/SI-9840?orig=1
Reporter: Svyatoslav Ilinskiy (ilinum)
Affected Versions: 2.12.0-M4

@scabug
Copy link
Author

scabug commented Jul 4, 2016

@soc said:
Hi Svyatoslav,

maybe I'm not getting the title of this bug report ... what did you have in mind when you wrote "immutable"?

@scabug
Copy link
Author

scabug commented Jul 4, 2016

Svyatoslav Ilinskiy (ilinum) said:
Hi Simon,

That's the error message you get in 2.11 when trying to compile the code.
Feel free to change the title if it makes it easier for people to understand

@scabug
Copy link
Author

scabug commented Aug 9, 2016

@adriaanm said:
Fails as follows in 2.12.0-{M4,M5} for me. Expected to have a different failure mode when compiling under -Xexperimental due to -Yoverride-vars having been included (until recently).

/Users/adriaan/Library/Preferences/IdeaIC2016.2/scratches/scratch_7.scala:6: error: overriding variable value in class Node of type Option[Boolean];
 method value cannot override a mutable variable
  override def value = ???
               ^
/Users/adriaan/Library/Preferences/IdeaIC2016.2/scratches/scratch_7.scala:8: error: overriding variable value in class Node of type Option[Boolean];
 method value_= cannot override a mutable variable
  override def value_=(b: Option[Boolean]) = ???
               ^
two errors found

@scabug scabug closed this as completed Aug 9, 2016
@scabug
Copy link
Author

scabug commented Aug 13, 2016

Svyatoslav Ilinskiy (ilinum) said:
What do you mean by different failure mode? The code compiles for me with -Xexperimental and 2.11.8. Is this the case for you?

Tried it again with 2-12-M5, it does not compile indeed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants