diff options
author | Paul Phillips <paulp@improving.org> | 2012-11-03 06:23:56 -0700 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2012-11-03 06:36:48 -0700 |
commit | d3da3ef83293c0e174e07aba643b3a1f46c110c5 (patch) | |
tree | 2de2664f2a6479e6b27a46476d503b59fa116f3d /test/files/neg/warn-unused-privates.scala | |
parent | 0475fbd6e0cad15460d87eda52c9487f7ff171d3 (diff) | |
download | scala-d3da3ef83293c0e174e07aba643b3a1f46c110c5.tar.gz scala-d3da3ef83293c0e174e07aba643b3a1f46c110c5.tar.bz2 scala-d3da3ef83293c0e174e07aba643b3a1f46c110c5.zip |
Expanded unused warnings.
Now warns on unused private and local terms and types.
In addition it warns when a local var is read-only past
the point of its creation - something I never would have
guessed would be such a gold mine. Over 100 vars in trunk
turn into vals.
Diffstat (limited to 'test/files/neg/warn-unused-privates.scala')
-rw-r--r-- | test/files/neg/warn-unused-privates.scala | 53 |
1 files changed, 50 insertions, 3 deletions
diff --git a/test/files/neg/warn-unused-privates.scala b/test/files/neg/warn-unused-privates.scala index 1ac272357f..cb6e946a34 100644 --- a/test/files/neg/warn-unused-privates.scala +++ b/test/files/neg/warn-unused-privates.scala @@ -18,8 +18,10 @@ class B1(msg: String) extends A(msg) class B2(msg0: String) extends A(msg0) class B3(msg0: String) extends A("msg") -/*** Early defs full of noise due to SI-6595. ***/ -/*** +/*** Early defs warnings disabled primarily due to SI-6595. + * The test case is here to assure we aren't issuing false positives; + * the ones labeled "warn" don't warn. + ***/ class Boppy extends { private val hmm: String = "abc" // no warn, used in early defs private val hom: String = "def" // no warn, used in body @@ -35,7 +37,6 @@ class Boppy extends { private final val bum = "ghi" // no warn, might have been (was) inlined final val bum2 = "ghi" // no warn, same } -***/ trait Accessors { private var v1: Int = 0 // warn @@ -56,3 +57,49 @@ trait DefaultArgs { def boppy() = bippy(5, 100, 200) } + +class Outer { + class Inner +} + +trait Locals { + def f0 = { + var x = 1 // warn + var y = 2 + y = 3 + y + y + } + def f1 = { + val a = new Outer // no warn + val b = new Outer // warn + new a.Inner + } + def f2 = { + var x = 100 // warn about it being a var + x + } +} + +object Types { + private object Dongo { def f = this } // warn + private class Bar1 // warn + private class Bar2 // no warn + private type Alias1 = String // warn + private type Alias2 = String // no warn + def bippo = (new Bar2).toString + + def f(x: Alias2) = x.length + + def l1() = { + object HiObject { def f = this } // warn + class Hi { // warn + def f1: Hi = new Hi + def f2(x: Hi) = x + } + class DingDongDoobie // warn + class Bippy // no warn + type Something = Bippy // no warn + type OtherThing = String // warn + (new Bippy): Something + } +} |