From 44855dcd3c2e19d5dbaf01b2165ea8dc9fb287d3 Mon Sep 17 00:00:00 2001 From: Som Snytt Date: Sat, 24 May 2014 06:08:17 -0700 Subject: SI-8525 Add -Xlint:-warn-missing-interpolator Turn off lint warnings with negating prefix, and add a lint-only warning for the infamously nagging "Did you forget the interpolator?" That message is made more dignified. Without `-Xlint:false`, there is no mechanism to turn off anonymous linters once `-Xlint` is selected. --- test/files/neg/forgot-interpolator.check | 16 ++++++++-------- test/files/neg/t7848-interp-warn.check | 6 +++--- test/files/neg/t8525.check | 6 ++++++ test/files/neg/t8525.flags | 1 + test/files/neg/t8525.scala | 10 ++++++++++ test/files/neg/t8610-arg.check | 9 ++++++--- test/files/neg/t8610-arg.scala | 5 ++++- test/files/neg/t8610.check | 11 +++++++---- test/files/neg/t8610.scala | 5 ++++- 9 files changed, 49 insertions(+), 20 deletions(-) create mode 100644 test/files/neg/t8525.check create mode 100644 test/files/neg/t8525.flags create mode 100644 test/files/neg/t8525.scala (limited to 'test/files/neg') diff --git a/test/files/neg/forgot-interpolator.check b/test/files/neg/forgot-interpolator.check index 8988458982..8e75350518 100644 --- a/test/files/neg/forgot-interpolator.check +++ b/test/files/neg/forgot-interpolator.check @@ -1,25 +1,25 @@ -forgot-interpolator.scala:4: warning: `$bippy` looks like an interpolated identifier! Did you forget the interpolator? +forgot-interpolator.scala:4: warning: possible missing interpolator: detected interpolated identifier `$bippy` def f = "Put the $bippy in the $bippy!" // warn 1 ^ -forgot-interpolator.scala:14: warning: That looks like an interpolated expression! Did you forget the interpolator? +forgot-interpolator.scala:14: warning: possible missing interpolator: detected an interpolated expression def f = """Put the ${println("bippy")} in the bippy!""" // warn 2 ^ -forgot-interpolator.scala:30: warning: `$beppo` looks like an interpolated identifier! Did you forget the interpolator? +forgot-interpolator.scala:30: warning: possible missing interpolator: detected interpolated identifier `$beppo` def f = "$beppo was a marx bros who saw dollars." // warn 3 ^ -forgot-interpolator.scala:34: warning: `$aleppo` looks like an interpolated identifier! Did you forget the interpolator? +forgot-interpolator.scala:34: warning: possible missing interpolator: detected interpolated identifier `$aleppo` def f = "$aleppo is a pepper and a city." // warn 4 ^ -forgot-interpolator.scala:47: warning: `$hippo` looks like an interpolated identifier! Did you forget the interpolator? +forgot-interpolator.scala:47: warning: possible missing interpolator: detected interpolated identifier `$hippo` def h = "$hippo takes an implicit" // warn 6 ^ -forgot-interpolator.scala:88: warning: `$groucho` looks like an interpolated identifier! Did you forget the interpolator? +forgot-interpolator.scala:88: warning: possible missing interpolator: detected interpolated identifier `$groucho` def f2 = "I salute $groucho" // warn 7 ^ -forgot-interpolator.scala:89: warning: `$dingo` looks like an interpolated identifier! Did you forget the interpolator? +forgot-interpolator.scala:89: warning: possible missing interpolator: detected interpolated identifier `$dingo` def f3 = "I even salute $dingo" // warn 8 ^ -forgot-interpolator.scala:90: warning: `$calico` looks like an interpolated identifier! Did you forget the interpolator? +forgot-interpolator.scala:90: warning: possible missing interpolator: detected interpolated identifier `$calico` def f4 = "I also salute $calico" // warn 9 ^ error: No warnings can be incurred under -Xfatal-warnings. diff --git a/test/files/neg/t7848-interp-warn.check b/test/files/neg/t7848-interp-warn.check index b7df6d8ce2..4cf9d55ffd 100644 --- a/test/files/neg/t7848-interp-warn.check +++ b/test/files/neg/t7848-interp-warn.check @@ -1,10 +1,10 @@ -t7848-interp-warn.scala:8: warning: `$foo` looks like an interpolated identifier! Did you forget the interpolator? +t7848-interp-warn.scala:8: warning: possible missing interpolator: detected interpolated identifier `$foo` "An important $foo message!" ^ -t7848-interp-warn.scala:12: warning: That looks like an interpolated expression! Did you forget the interpolator? +t7848-interp-warn.scala:12: warning: possible missing interpolator: detected an interpolated expression "A doubly important ${foo * 2} message!" ^ -t7848-interp-warn.scala:16: warning: `$bar` looks like an interpolated identifier! Did you forget the interpolator? +t7848-interp-warn.scala:16: warning: possible missing interpolator: detected interpolated identifier `$bar` def j = s"Try using '${ "something like $bar" }' instead." // warn ^ error: No warnings can be incurred under -Xfatal-warnings. diff --git a/test/files/neg/t8525.check b/test/files/neg/t8525.check new file mode 100644 index 0000000000..554ab23253 --- /dev/null +++ b/test/files/neg/t8525.check @@ -0,0 +1,6 @@ +t8525.scala:9: warning: private[this] value name in class X shadows mutable name inherited from class Named. Changes to name will not be visible within class X - you may want to give them distinct names. + override def toString = name // shadowing mutable var name + ^ +error: No warnings can be incurred under -Xfatal-warnings. +one warning found +one error found diff --git a/test/files/neg/t8525.flags b/test/files/neg/t8525.flags new file mode 100644 index 0000000000..f19af1f717 --- /dev/null +++ b/test/files/neg/t8525.flags @@ -0,0 +1 @@ +-Xfatal-warnings -Xlint:-warn-missing-interpolator diff --git a/test/files/neg/t8525.scala b/test/files/neg/t8525.scala new file mode 100644 index 0000000000..7bed04904f --- /dev/null +++ b/test/files/neg/t8525.scala @@ -0,0 +1,10 @@ + +class Named(var name: String) + +class X(name: String) extends Named(name) { + def x = "Hi, $name" // missing interp + def f(p: (Int, Int)): Int = p._1 * p._2 + def g = f(3, 4) // adapted + def u: Unit = () // unitarian universalist + override def toString = name // shadowing mutable var name +} diff --git a/test/files/neg/t8610-arg.check b/test/files/neg/t8610-arg.check index f2879b0d45..4f194ce84a 100644 --- a/test/files/neg/t8610-arg.check +++ b/test/files/neg/t8610-arg.check @@ -1,9 +1,12 @@ -t8610-arg.scala:3: warning: `$name` looks like an interpolated identifier! Did you forget the interpolator? +t8610-arg.scala:5: warning: possible missing interpolator: detected interpolated identifier `$name` def x = "Hi, $name" // missing interp ^ -t8610-arg.scala:6: warning: side-effecting nullary methods are discouraged: suggest defining as `def u()` instead +t8610-arg.scala:9: warning: private[this] value name in class X shadows mutable name inherited from class Named. Changes to name will not be visible within class X - you may want to give them distinct names. + override def toString = name // shadowing mutable var name + ^ +t8610-arg.scala:8: warning: side-effecting nullary methods are discouraged: suggest defining as `def u()` instead def u: Unit = () // unitarian universalist ^ error: No warnings can be incurred under -Xfatal-warnings. -two warnings found +three warnings found one error found diff --git a/test/files/neg/t8610-arg.scala b/test/files/neg/t8610-arg.scala index 494a3354da..7bed04904f 100644 --- a/test/files/neg/t8610-arg.scala +++ b/test/files/neg/t8610-arg.scala @@ -1,7 +1,10 @@ -case class X(name: String) { +class Named(var name: String) + +class X(name: String) extends Named(name) { def x = "Hi, $name" // missing interp def f(p: (Int, Int)): Int = p._1 * p._2 def g = f(3, 4) // adapted def u: Unit = () // unitarian universalist + override def toString = name // shadowing mutable var name } diff --git a/test/files/neg/t8610.check b/test/files/neg/t8610.check index 7a18e55127..334a947549 100644 --- a/test/files/neg/t8610.check +++ b/test/files/neg/t8610.check @@ -1,15 +1,18 @@ -t8610.scala:3: warning: `$name` looks like an interpolated identifier! Did you forget the interpolator? +t8610.scala:5: warning: possible missing interpolator: detected interpolated identifier `$name` def x = "Hi, $name" // missing interp ^ -t8610.scala:5: warning: Adapting argument list by creating a 2-tuple: this may not be what you want. +t8610.scala:7: warning: Adapting argument list by creating a 2-tuple: this may not be what you want. signature: X.f(p: (Int, Int)): Int given arguments: 3, 4 after adaptation: X.f((3, 4): (Int, Int)) def g = f(3, 4) // adapted ^ -t8610.scala:6: warning: side-effecting nullary methods are discouraged: suggest defining as `def u()` instead +t8610.scala:9: warning: private[this] value name in class X shadows mutable name inherited from class Named. Changes to name will not be visible within class X - you may want to give them distinct names. + override def toString = name // shadowing mutable var name + ^ +t8610.scala:8: warning: side-effecting nullary methods are discouraged: suggest defining as `def u()` instead def u: Unit = () // unitarian universalist ^ error: No warnings can be incurred under -Xfatal-warnings. -three warnings found +four warnings found one error found diff --git a/test/files/neg/t8610.scala b/test/files/neg/t8610.scala index 494a3354da..7bed04904f 100644 --- a/test/files/neg/t8610.scala +++ b/test/files/neg/t8610.scala @@ -1,7 +1,10 @@ -case class X(name: String) { +class Named(var name: String) + +class X(name: String) extends Named(name) { def x = "Hi, $name" // missing interp def f(p: (Int, Int)): Int = p._1 * p._2 def g = f(3, 4) // adapted def u: Unit = () // unitarian universalist + override def toString = name // shadowing mutable var name } -- cgit v1.2.3