File tree Expand file tree Collapse file tree 3 files changed +12
-1
lines changed
compiler/src/dotty/tools/dotc/typer Expand file tree Collapse file tree 3 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -388,7 +388,7 @@ object RefChecks {
388
388
} else if (member.is(ModuleVal ) && ! other.isRealMethod && ! other.is(Deferred | Lazy )) {
389
389
overrideError(" may not override a concrete non-lazy value" )
390
390
} else if (member.is(Lazy , butNot = Module ) && ! other.isRealMethod && ! other.is(Lazy ) &&
391
- ! ctx.testScala2Mode(" may not override a non-lazy value" , member.sourcePos)) {
391
+ ! ctx.testScala2Mode(overrideErrorMsg( " may not override a non-lazy value" ) , member.sourcePos)) {
392
392
overrideError(" may not override a non-lazy value" )
393
393
} else if (other.is(Lazy ) && ! other.isRealMethod && ! member.is(Lazy )) {
394
394
overrideError(" must be declared lazy to override a lazy value" )
Original file line number Diff line number Diff line change
1
+ -- Error: tests/neg/ovlazy.scala:5:20 ----------------------------------------------------------------------------------
2
+ 5 | override lazy val x: Int = 2 // error
3
+ | ^
4
+ | error overriding value x in class A of type Int;
5
+ | lazy value x of type Int may not override a non-lazy value
Original file line number Diff line number Diff line change
1
+ class A {
2
+ val x : Int = 1
3
+ }
4
+ class B extends A {
5
+ override lazy val x : Int = 2 // error
6
+ }
You can’t perform that action at this time.
0 commit comments