diff options
author | Som Snytt <som.snytt@gmail.com> | 2016-09-14 23:55:16 -0700 |
---|---|---|
committer | Som Snytt <som.snytt@gmail.com> | 2017-03-11 23:38:08 -0800 |
commit | f672aff3f3b92506741b62d8f7eae6d1e0dc36a7 (patch) | |
tree | 7bfacf173c601643e83a91bb5eb53fce9e0caf5e /src/repl | |
parent | 9d9abffc94b28785e54bc2179b495d81f29b1e7f (diff) | |
download | scala-f672aff3f3b92506741b62d8f7eae6d1e0dc36a7.tar.gz scala-f672aff3f3b92506741b62d8f7eae6d1e0dc36a7.tar.bz2 scala-f672aff3f3b92506741b62d8f7eae6d1e0dc36a7.zip |
SI-8040 Warn unused pattern vars
Warn for unused `case X(x) =>` but, as an escape hatch,
not for `case X(x @ _) =>`. The latter form is deemed
documentary. (Named args could serve a similar purpose,
`case X(x = _) =>`.)
An attachment is used to mark the bound var, and the
symbol position is used to correlate the identifier
with the variable that is introduced. This mechanism
doesn't work yet when only a single var is defined.
Diffstat (limited to 'src/repl')
-rw-r--r-- | src/repl/scala/tools/nsc/interpreter/ILoop.scala | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/repl/scala/tools/nsc/interpreter/ILoop.scala b/src/repl/scala/tools/nsc/interpreter/ILoop.scala index 9635f320fe..cd263a26f6 100644 --- a/src/repl/scala/tools/nsc/interpreter/ILoop.scala +++ b/src/repl/scala/tools/nsc/interpreter/ILoop.scala @@ -958,17 +958,19 @@ class ILoop(in0: Option[BufferedReader], protected val out: JPrintWriter) def withSuppressedSettings[A](body: => A): A = { val ss = this.settings import ss._ - val noisy = List(Xprint, Ytyperdebug) + val noisy = List(Xprint, Ytyperdebug, browse) val noisesome = noisy.exists(!_.isDefault) - val current = (Xprint.value, Ytyperdebug.value) + val current = (Xprint.value, Ytyperdebug.value, browse.value) if (isReplDebug || !noisesome) body else { this.settings.Xprint.value = List.empty + this.settings.browse.value = List.empty this.settings.Ytyperdebug.value = false try body finally { Xprint.value = current._1 Ytyperdebug.value = current._2 + browse.value = current._3 intp.global.printTypings = current._2 } } |