Closed
Description
Hey guys! Not sure how hard this would be to fix, but I thought I would bring it up.
//produces compiler warning
class C1 {
val x = y
val y = 1
}
//no warning :(
class C2 {
val x = getY
val y = 1
def getY = y
}
//no warning either :(
trait T {
val y: Int
val x: Int = y
}
class C3 extends T {
val y = 1
}
This is a really easy thing to do accidentally if you're moving things around and it can lead to a class that throws a NullPointerException whenever it is instantiated.
Related - #221
IMO it would be better to produce an error than a warning in general, especially since classes/strings/collections/misc non-Int values default to null, which seems to run very counter to the spirit of Scala. ¯\_ (ツ) _/¯
Metadata
Metadata
Assignees
Labels
No labels