bug icon indicating copy to clipboard operation
bug copied to clipboard

objects should override lazy values

Open scabug opened this issue 14 years ago • 3 comments

Title says it all. Right now you cannot override a lazy val with an object. But I think you should be able to do this, or else you will be locked in forever in lazy vals.

scabug avatar Nov 14 '11 14:11 scabug

Imported From: https://issues.scala-lang.org/browse/SI-5187?orig=1 Reporter: @odersky

scabug avatar Nov 14 '11 14:11 scabug

@paulp said: Since we have objects overriding objects in -Xexperimental, then to complete the circuit one should also be able to override an object with a lazy val.

scabug avatar Nov 15 '11 04:11 scabug

Scala 3.6.3:

scala> class C { lazy val x: AnyRef = new AnyRef }
// defined class C
                                                                                                    
scala> class D extends C { override object x }
// defined class D

SethTisue avatar Feb 18 '25 00:02 SethTisue