diff options
author | Paul Phillips <paulp@improving.org> | 2013-03-12 07:39:54 -0700 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2013-03-12 09:31:25 -0700 |
commit | 089cad8f436e1bc0935218937590897f5b9cbae4 (patch) | |
tree | 1d43901950f88f918a9d76b17f1c64ec2d49c677 /test/files/neg/constructor-init-order.scala | |
parent | a41c79bb5b2f16d8f37e253737f67171e5764bb9 (diff) | |
download | scala-089cad8f436e1bc0935218937590897f5b9cbae4.tar.gz scala-089cad8f436e1bc0935218937590897f5b9cbae4.tar.bz2 scala-089cad8f436e1bc0935218937590897f5b9cbae4.zip |
Warn about locally identifiable init order issues.
This warns about a subset of initialization order issues which
can easily be identified by inspection, such as
val x = y
val y = 5
The likelihood of this formulation being intentional is miniscule.
Diffstat (limited to 'test/files/neg/constructor-init-order.scala')
-rw-r--r-- | test/files/neg/constructor-init-order.scala | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/test/files/neg/constructor-init-order.scala b/test/files/neg/constructor-init-order.scala new file mode 100644 index 0000000000..fe8fec87ad --- /dev/null +++ b/test/files/neg/constructor-init-order.scala @@ -0,0 +1,23 @@ +trait Foo0 { + val quux1: String + val quux2 = quux1 // warning here is "future work" +} + +class Foo1 extends Foo0 { + val bar1 = baz // warn + val bar2 = lazybaz // no warn + val bar3 = defbaz // no warn + val baz = "oops" + lazy val lazybaz = "ok" + def defbaz = "ok" + val quux1 = "oops" +} + +class Foo2 { + var bar1 = baz // warn + var bar2 = lazybaz // no warn + var bar3 = defbaz // no warn + var baz = "oops" + lazy val lazybaz = "ok" + def defbaz = "ok" +} |