summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/reporters
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2012-01-02 06:41:31 -0800
committerPaul Phillips <paulp@improving.org>2012-01-02 14:37:36 -0800
commit451e1dc2da16c1bb5a7a59488865df9294eeaf3e (patch)
treedcbae11619389a16115d005ab2fc9bfdf5c4ba8d /src/compiler/scala/tools/nsc/reporters
parentbeb875187914b12b1b9dbb5621447067e2926c7c (diff)
downloadscala-451e1dc2da16c1bb5a7a59488865df9294eeaf3e.tar.gz
scala-451e1dc2da16c1bb5a7a59488865df9294eeaf3e.tar.bz2
scala-451e1dc2da16c1bb5a7a59488865df9294eeaf3e.zip
Added -Xlog-implicit-conversions.
New command line option prints a message whenever the compiler inserts an implicit conversion. Implicit parameters are not under consideration here, since the primary motivation is to make it easy to inspect your code for unintentional conversions, since they can have dramatic performance implications. class A { def f(xs: Array[Byte]) = xs.size def g(xs: Array[Byte]) = xs.length } % scalac -Xlog-implicit-conversions logImplicits.scala logImplicits.scala:2: applied implicit conversion from xs.type to ?{val size: ?} = implicit def byteArrayOps(xs: Array[Byte]): scala.collection.mutable.ArrayOps[Byte] def f(xs: Array[Byte]) = xs.size ^
Diffstat (limited to 'src/compiler/scala/tools/nsc/reporters')
-rw-r--r--src/compiler/scala/tools/nsc/reporters/Reporter.scala23
-rw-r--r--src/compiler/scala/tools/nsc/reporters/ReporterTimer.scala2
2 files changed, 16 insertions, 9 deletions
diff --git a/src/compiler/scala/tools/nsc/reporters/Reporter.scala b/src/compiler/scala/tools/nsc/reporters/Reporter.scala
index 12306606e4..f19a285d7c 100644
--- a/src/compiler/scala/tools/nsc/reporters/Reporter.scala
+++ b/src/compiler/scala/tools/nsc/reporters/Reporter.scala
@@ -47,14 +47,23 @@ abstract class Reporter {
finally incompleteHandler = saved
}
- var cancelled = false
- def hasErrors = ERROR.count > 0 || cancelled
- def hasWarnings = WARNING.count > 0
+ var cancelled = false
+ def hasErrors = ERROR.count > 0 || cancelled
+ def hasWarnings = WARNING.count > 0
- def info(pos: Position, msg: String, force: Boolean) { info0(pos, msg, INFO, force) }
- def warning(pos: Position, msg: String ) { withoutTruncating(info0(pos, msg, WARNING, false)) }
- def error(pos: Position, msg: String ) { withoutTruncating(info0(pos, msg, ERROR, false)) }
- def incompleteInputError(pos: Position, msg: String ) {
+ /** For sending a message which should not be labeled as a warning/error,
+ * but also shouldn't require -verbose to be visible.
+ */
+ def echo(msg: String): Unit = info(NoPosition, msg, true)
+ def echo(pos: Position, msg: String): Unit = info(pos, msg, true)
+
+ /** Informational messages, suppressed unless -verbose or force=true. */
+ def info(pos: Position, msg: String, force: Boolean): Unit = info0(pos, msg, INFO, force)
+
+ /** Warnings and errors. */
+ def warning(pos: Position, msg: String): Unit = withoutTruncating(info0(pos, msg, WARNING, false))
+ def error(pos: Position, msg: String): Unit = withoutTruncating(info0(pos, msg, ERROR, false))
+ def incompleteInputError(pos: Position, msg: String): Unit = {
if (incompleteHandled) incompleteHandler(pos, msg)
else error(pos, msg)
}
diff --git a/src/compiler/scala/tools/nsc/reporters/ReporterTimer.scala b/src/compiler/scala/tools/nsc/reporters/ReporterTimer.scala
index 800af55861..f55d0684c8 100644
--- a/src/compiler/scala/tools/nsc/reporters/ReporterTimer.scala
+++ b/src/compiler/scala/tools/nsc/reporters/ReporterTimer.scala
@@ -13,8 +13,6 @@ import scala.tools.util.AbstractTimer
* timings.
*/
class ReporterTimer(reporter: Reporter) extends AbstractTimer {
-
def issue(msg: String, duration: Long) =
reporter.info(null, "[" + msg + " in " + duration + "ms]", false)
-
}