From d3da3ef83293c0e174e07aba643b3a1f46c110c5 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Sat, 3 Nov 2012 06:23:56 -0700 Subject: 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. --- test/files/neg/warn-unused-privates.scala | 53 +++++++++++++++++++++++++++++-- 1 file changed, 50 insertions(+), 3 deletions(-) (limited to 'test/files/neg/warn-unused-privates.scala') 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 + } +} -- cgit v1.2.3