summaryrefslogtreecommitdiff
path: root/test/files/neg/warn-unused-implicits.scala
diff options
context:
space:
mode:
authorSom Snytt <som.snytt@gmail.com>2016-09-19 00:46:17 -0700
committerSom Snytt <som.snytt@gmail.com>2017-03-11 23:38:08 -0800
commit22f98d5189b61200aaf11cec7a0a96d5cfa86a5e (patch)
treeaa90424f6dd21609090ae8fbffb5410ca80f4edf /test/files/neg/warn-unused-implicits.scala
parent94b938bb290a231694e5721368023bd6693bb2ed (diff)
downloadscala-22f98d5189b61200aaf11cec7a0a96d5cfa86a5e.tar.gz
scala-22f98d5189b61200aaf11cec7a0a96d5cfa86a5e.tar.bz2
scala-22f98d5189b61200aaf11cec7a0a96d5cfa86a5e.zip
SI-8040 Warn unused parameters
One can `-Ywarn-unused:params` or more narrowly warn only for unused implicit parameters with `-Ywarn-unused:implicits`. Params includes constructor parameters. The settings for privates and locals are not yet distinguished. ``` $ skalac -Ywarn-unused:help Enable or disable specific `unused' warnings imports Warn if an import selector is not referenced. patvars Warn if a variable bound in a pattern is unused. privates Warn if a private member is unused. locals Warn if a local definition is unused. params Warn if a value parameter is unused. implicits Warn if an implicit parameter is unused. ```
Diffstat (limited to 'test/files/neg/warn-unused-implicits.scala')
-rw-r--r--test/files/neg/warn-unused-implicits.scala32
1 files changed, 32 insertions, 0 deletions
diff --git a/test/files/neg/warn-unused-implicits.scala b/test/files/neg/warn-unused-implicits.scala
new file mode 100644
index 0000000000..54f924eac0
--- /dev/null
+++ b/test/files/neg/warn-unused-implicits.scala
@@ -0,0 +1,32 @@
+
+trait InterFace {
+ /** Call something. */
+ def call(a: Int, b: String, c: Double)(implicit s: String): Int
+}
+
+trait BadAPI extends InterFace {
+ def f(a: Int,
+ b: String,
+ c: Double
+ )(implicit s: String): Int = { // warn
+ println(b + c)
+ a
+ }
+ @deprecated ("no warn in deprecated API", since="yesterday")
+ def g(a: Int,
+ b: String,
+ c: Double
+ )(implicit s: String): Int = { // no warn
+ println(b + c)
+ a
+ }
+ override def call(a: Int,
+ b: String,
+ c: Double
+ )(implicit s: String): Int = { // no warn, required by superclass
+ println(b + c)
+ a
+ }
+
+ def i(implicit s: String, t: Int) = t // yes, warn
+}