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

override val + super difference between 2.7.0 and 2.7.1 #899

Closed
scabug opened this issue May 13, 2008 · 6 comments
Closed

override val + super difference between 2.7.0 and 2.7.1 #899

scabug opened this issue May 13, 2008 · 6 comments
Assignees
Labels

Comments

@scabug
Copy link

scabug commented May 13, 2008

Take the example:

class Top {
  val o = "Hi there!"
}

class Bot extends Top {
  override val o = "Ha! " + super.o
}

And try compiling it with the different versions:

dietlw@scarab:~/tmp$$ /opt/scala-2.6.1-final/bin/scalac OverrideVal.scala 
dietlw@scarab:~/tmp$$ /opt/scala-2.7.0-final/bin/scalac OverrideVal.scala 
dietlw@scarab:~/tmp$$ /opt/scala-2.7.1.final/bin/scalac OverrideVal.scala 
OverrideVal.scala:6: error: super may be not be used on value o
  override val o = "Ha! " + super.o
                                  ^
one error found

Why is this an error now?
The error message text could be changed to something like
"super may not be used on value o".
I did not see an entry in the change logs that would explain this
change of behavior and guess it's an error introduced in 2.7.1.

@scabug
Copy link
Author

scabug commented May 13, 2008

Imported From: https://issues.scala-lang.org/browse/SI-899?orig=1
Reporter: wdietl

@scabug
Copy link
Author

scabug commented May 13, 2008

Geoffrey Alan Washburn (washburn) said:
This is the intended behavior, and it was changed so that traits could override vals to be more uniform with classes.

I don't know why it didn't make it into the ChangeLog. Probably it was a small item in a larger set of changes someone committed.

@scabug
Copy link
Author

scabug commented May 13, 2008

wdietl said:
The Scala Reference, page 81, has Example 6.5.1, which does not
compile any more under this changed rule.
(Also the example contains superfluous "}" in classes C and D).

@scabug
Copy link
Author

scabug commented May 14, 2008

Geoffrey Alan Washburn (washburn) said:
I am pretty sure Martin made the change, so it would probably be better for him to document it.

@scabug
Copy link
Author

scabug commented May 22, 2008

@odersky said:
I changed the spec to explain.

@scabug
Copy link
Author

scabug commented Jan 14, 2009

@odersky said:
Milestone next_bugfix deleted

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