Skip to content

Fix error message when overriding with a lazy val #6549

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

Merged
merged 1 commit into from
May 22, 2019

Conversation

smarter
Copy link
Member

@smarter smarter commented May 22, 2019

No description provided.

Copy link
Contributor

@anatoliykmetyuk anatoliykmetyuk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't look like the test really tests the fix as it passes even without it. What we want is the -language:Scala2 flag when running the test.

sbt:dotty> repl -language:Scala2
scala> class A {
     |   val x: Int = 1
     | }
     | class B extends A {
     |   override lazy val x: Int = 2 // error
     | }
5 |  override lazy val x: Int = 2 // error
  |                    ^
  |                    may not override a non-lazy value

With the fix:

scala> class A {
     |   val x: Int = 1
     | }
     | class B extends A {
     |   override lazy val x: Int = 2 // error
     | }
5 |  override lazy val x: Int = 2 // error
  |                    ^
  |              error overriding value x in class A of type Int;
  |                lazy value x of type Int may not override a non-lazy value

@anatoliykmetyuk anatoliykmetyuk merged commit 6e9200a into scala:master May 22, 2019
@anatoliykmetyuk anatoliykmetyuk deleted the fix-error-ms branch May 22, 2019 16:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants