diff options
author | Som Snytt <som.snytt@gmail.com> | 2016-03-20 19:35:41 -0700 |
---|---|---|
committer | Som Snytt <som.snytt@gmail.com> | 2016-03-20 19:35:41 -0700 |
commit | 416326ebeaffef29cda3522ea828950e45cedcc0 (patch) | |
tree | dd2fc9261b3d1893c4ba2409808f805b5763802c | |
parent | 99a82be91cbb85239f70508f6695c6b21fd3558c (diff) | |
download | scala-416326ebeaffef29cda3522ea828950e45cedcc0.tar.gz scala-416326ebeaffef29cda3522ea828950e45cedcc0.tar.bz2 scala-416326ebeaffef29cda3522ea828950e45cedcc0.zip |
SI-9314 Don't warn on "$pkg"
Edge cases of things not to warn about
include package names.
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Typers.scala | 2 | ||||
-rw-r--r-- | test/files/neg/t7848-interp-warn.check | 10 | ||||
-rw-r--r-- | test/files/neg/t7848-interp-warn.scala | 16 |
3 files changed, 19 insertions, 9 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 6676a0aeaf..3f0d0e655d 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -5206,7 +5206,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper case MethodType(p :: _, _) => p.isImplicit // implicit method requires no args case _ => true // catches all others including NullaryMethodType } - def isPlausible(m: Symbol) = m.alternatives exists (m => requiresNoArgs(m.info)) + def isPlausible(m: Symbol) = !m.isPackage && m.alternatives.exists(x => requiresNoArgs(x.info)) def maybeWarn(s: String): Unit = { def warn(message: String) = context.warning(lit.pos, s"possible missing interpolator: $message") diff --git a/test/files/neg/t7848-interp-warn.check b/test/files/neg/t7848-interp-warn.check index 637fc8941a..ad66ae1577 100644 --- a/test/files/neg/t7848-interp-warn.check +++ b/test/files/neg/t7848-interp-warn.check @@ -1,13 +1,13 @@ -t7848-interp-warn.scala:8: warning: possible missing interpolator: detected interpolated identifier `$foo` +t7848-interp-warn.scala:18: warning: possible missing interpolator: detected interpolated identifier `$foo` "An important $foo message!" ^ -t7848-interp-warn.scala:12: warning: possible missing interpolator: detected an interpolated expression +t7848-interp-warn.scala:22: warning: possible missing interpolator: detected an interpolated expression "A doubly important ${foo * 2} message!" ^ -t7848-interp-warn.scala:15: warning: possible missing interpolator: detected interpolated identifier `$bar` - def i = s"Try using '${ "$bar" }' instead." // was: no warn on space test +t7848-interp-warn.scala:25: warning: possible missing interpolator: detected interpolated identifier `$bar` + def i = s"Try using '${ "$bar" }' instead." // was: no warn on space test ^ -t7848-interp-warn.scala:16: warning: possible missing interpolator: detected interpolated identifier `$bar` +t7848-interp-warn.scala:26: 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/t7848-interp-warn.scala b/test/files/neg/t7848-interp-warn.scala index a76141041d..6a289b2b71 100644 --- a/test/files/neg/t7848-interp-warn.scala +++ b/test/files/neg/t7848-interp-warn.scala @@ -1,7 +1,17 @@ package test +package pancake { } + object Test { + type NonVal = Int + + def ok = "Don't warn on $nosymbol interpolated." + + def pass = "Don't warn on $pancake package names." + + def types = "Or $NonVal type symbols either." + def bar = "bar" def f = { val foo = "bar" @@ -11,8 +21,8 @@ object Test { val foo = "bar" "A doubly important ${foo * 2} message!" } - def h = s"Try using '$$bar' instead." // no warn - def i = s"Try using '${ "$bar" }' instead." // was: no warn on space test + def h = s"Try using '$$bar' instead." // no warn + def i = s"Try using '${ "$bar" }' instead." // was: no warn on space test def j = s"Try using '${ "something like $bar" }' instead." // warn - def k = f"Try using '$bar' instead." // no warn on other std interps + def k = f"Try using '$bar' instead." // no warn on other std interps } |