diff options
author | Paul Phillips <paulp@improving.org> | 2012-10-12 22:24:32 -0700 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2012-10-13 07:28:30 -0700 |
commit | 02909f2be30db5c0f79f961cad17e2dc2f026ff4 (patch) | |
tree | 7a47e916ec196d4c8e34832eebacc21b76c4b997 /test/files/neg/unit-returns-value.scala | |
parent | 8a984fa0e351de532497450c9c80ddd2f975d32e (diff) | |
download | scala-02909f2be30db5c0f79f961cad17e2dc2f026ff4.tar.gz scala-02909f2be30db5c0f79f961cad17e2dc2f026ff4.tar.bz2 scala-02909f2be30db5c0f79f961cad17e2dc2f026ff4.zip |
Warn about more misplaced expressions.
An identifier being used in statement position is not likely
what was meant when it is a non-lazy getter.
Diffstat (limited to 'test/files/neg/unit-returns-value.scala')
-rw-r--r-- | test/files/neg/unit-returns-value.scala | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/test/files/neg/unit-returns-value.scala b/test/files/neg/unit-returns-value.scala index ecc981f217..fc5a37069f 100644 --- a/test/files/neg/unit-returns-value.scala +++ b/test/files/neg/unit-returns-value.scala @@ -3,9 +3,30 @@ object Test { var b = false if (b) return 5 } - + // no warning def g { return println("hello") } } + +class UnusedValues { + var i1 = 2 + val i2 = 2 + lazy val i3 = 2 + object i4 { } + def i5 = 2 + final def i6 = 2 + + def x = { + i1 // warn + i2 // warn + i3 // no warn + i4 // no warn + i5 // no warn + i6 // could warn someday, if i6 returned 2.type instead of Int + + 5 + } +} + |