summaryrefslogtreecommitdiff
path: root/src/reflect
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2012-11-14 15:39:09 -0800
committerPaul Phillips <paulp@improving.org>2012-11-16 15:15:16 -0800
commit7936ce55315c40886fad508df8e56f78a8efea8f (patch)
tree18792a80327e7b33f24d184874deed0341283546 /src/reflect
parent6645fec23ab3ee7d12f5cfc7c474a42f0eb7ec15 (diff)
downloadscala-7936ce55315c40886fad508df8e56f78a8efea8f.tar.gz
scala-7936ce55315c40886fad508df8e56f78a8efea8f.tar.bz2
scala-7936ce55315c40886fad508df8e56f78a8efea8f.zip
Added -Xdev setting... you know, for devs
A setting we developers can give all the time and expect to hear useful things without being buried in debugging output. As the comment says: This is for WARNINGS which should reach the ears of scala developers whenever they occur, but are not useful for normal users. They should be precise, explanatory, and infrequent. Please don't use this as a logging mechanism. !!! is prefixed to all messages issued via this route to make them visually distinct. This is what I always intended for "debugwarn", the method I have deprecated in favor of the more accurate: def devWarning(msg: => String): Unit In this VERY SAME COMMIT, I performed the CLOSELY RELATED task of quieting down an -Xlint warning which had become too noisy thanks to implicit classes tickling it. I tightened that warn condition to include both -Xlint and -Xdev.
Diffstat (limited to 'src/reflect')
-rw-r--r--src/reflect/scala/reflect/internal/Scopes.scala2
-rw-r--r--src/reflect/scala/reflect/internal/SymbolTable.scala7
-rw-r--r--src/reflect/scala/reflect/internal/Symbols.scala6
-rw-r--r--src/reflect/scala/reflect/internal/TreeInfo.scala9
-rw-r--r--src/reflect/scala/reflect/internal/Types.scala12
-rw-r--r--src/reflect/scala/reflect/internal/transform/Erasure.scala2
6 files changed, 20 insertions, 18 deletions
diff --git a/src/reflect/scala/reflect/internal/Scopes.scala b/src/reflect/scala/reflect/internal/Scopes.scala
index 950e30dbc5..5b5097bcc2 100644
--- a/src/reflect/scala/reflect/internal/Scopes.scala
+++ b/src/reflect/scala/reflect/internal/Scopes.scala
@@ -243,7 +243,7 @@ trait Scopes extends api.Scopes { self: SymbolTable =>
// in package objects.)
val alts = lookupAll(name).toList
def alts_s = alts map (s => s.defString) mkString " <and> "
- log(s"!!! scope lookup of $name found multiple symbols: $alts_s")
+ devWarning(s"scope lookup of $name found multiple symbols: $alts_s")
// FIXME - how is one supposed to create an overloaded symbol without
// knowing the correct owner? Using the symbol owner is not correct;
// say for instance this is List's scope and the symbols are its three
diff --git a/src/reflect/scala/reflect/internal/SymbolTable.scala b/src/reflect/scala/reflect/internal/SymbolTable.scala
index fb1bf9ed9d..a3f814000f 100644
--- a/src/reflect/scala/reflect/internal/SymbolTable.scala
+++ b/src/reflect/scala/reflect/internal/SymbolTable.scala
@@ -54,13 +54,16 @@ abstract class SymbolTable extends macros.Universe
@deprecated("Give us a reason", "2.10.0")
def abort(): Nothing = abort("unknown error")
+ @deprecated("Use devWarning if this is really a warning; otherwise use log", "2.11.0")
+ def debugwarn(msg: => String): Unit = devWarning(msg)
+
/** Override with final implementation for inlining. */
def debuglog(msg: => String): Unit = if (settings.debug.value) log(msg)
- def debugwarn(msg: => String): Unit = if (settings.debug.value) Console.err.println(msg)
+ def devWarning(msg: => String): Unit = if (settings.debug.value) Console.err.println(msg)
def throwableAsString(t: Throwable): String = "" + t
/** Prints a stack trace if -Ydebug or equivalent was given, otherwise does nothing. */
- def debugStack(t: Throwable): Unit = debugwarn(throwableAsString(t))
+ def debugStack(t: Throwable): Unit = devWarning(throwableAsString(t))
/** Overridden when we know more about what was happening during a failure. */
def supplementErrorMessage(msg: String): String = msg
diff --git a/src/reflect/scala/reflect/internal/Symbols.scala b/src/reflect/scala/reflect/internal/Symbols.scala
index 0ad0275fba..7ae98c85af 100644
--- a/src/reflect/scala/reflect/internal/Symbols.scala
+++ b/src/reflect/scala/reflect/internal/Symbols.scala
@@ -1272,13 +1272,13 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
cnt += 1
// allow for two completions:
// one: sourceCompleter to LazyType, two: LazyType to completed type
- if (cnt == 3) abort("no progress in completing " + this + ":" + tp)
+ if (cnt == 3) abort(s"no progress in completing $this: $tp")
}
rawInfo
}
catch {
case ex: CyclicReference =>
- debugwarn("... hit cycle trying to complete " + this.fullLocationString)
+ devWarning("... hit cycle trying to complete " + this.fullLocationString)
throw ex
}
@@ -3157,7 +3157,7 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
override def companionSymbol = fail(NoSymbol)
locally {
- debugwarn("creating stub symbol for " + stubWarning)
+ devWarning("creating stub symbol for " + stubWarning)
}
}
class StubClassSymbol(owner0: Symbol, name0: TypeName) extends ClassSymbol(owner0, owner0.pos, name0) with StubSymbol
diff --git a/src/reflect/scala/reflect/internal/TreeInfo.scala b/src/reflect/scala/reflect/internal/TreeInfo.scala
index 7ae7cf1821..18f685549d 100644
--- a/src/reflect/scala/reflect/internal/TreeInfo.scala
+++ b/src/reflect/scala/reflect/internal/TreeInfo.scala
@@ -147,11 +147,10 @@ abstract class TreeInfo {
val plen = params.length
val alen = args.length
def fail() = {
- global.debugwarn(
- "Mismatch trying to zip method parameters and argument list:\n" +
- " params = " + params + "\n" +
- " args = " + args + "\n"
- )
+ global.devWarning(
+ s"""|Mismatch trying to zip method parameters and argument list:
+ | params = $params
+ | args = $args""".stripMargin)
false
}
diff --git a/src/reflect/scala/reflect/internal/Types.scala b/src/reflect/scala/reflect/internal/Types.scala
index 42a9d9e456..bdf23a2b41 100644
--- a/src/reflect/scala/reflect/internal/Types.scala
+++ b/src/reflect/scala/reflect/internal/Types.scala
@@ -1969,7 +1969,7 @@ trait Types extends api.Types { self: SymbolTable =>
case tr @ TypeRef(_, sym, args) if args.nonEmpty =>
val tparams = tr.initializedTypeParams
if (settings.debug.value && !sameLength(tparams, args))
- debugwarn("Mismatched zip in computeRefs(): " + sym.info.typeParams + ", " + args)
+ devWarning(s"Mismatched zip in computeRefs(): ${sym.info.typeParams}, $args")
foreach2(tparams, args) { (tparam1, arg) =>
if (arg contains tparam) {
@@ -2102,7 +2102,7 @@ trait Types extends api.Types { self: SymbolTable =>
// it later turns out not to have kind *. See SI-4070. Only
// logging it for now.
if (sym.typeParams.size != args.size)
- log("!!! %s.transform(%s), but tparams.isEmpty and args=".format(this, tp, args))
+ devWarning(s"$this.transform($tp), but tparams.isEmpty and args=$args")
asSeenFromOwner(tp).instantiateTypeParams(sym.typeParams, args)
}
@@ -3691,7 +3691,7 @@ trait Types extends api.Types { self: SymbolTable =>
tycon match {
case TypeRef(pre, sym @ (NothingClass|AnyClass), _) => copyTypeRef(tycon, pre, sym, Nil) //@M drop type args to Any/Nothing
case TypeRef(pre, sym, Nil) => copyTypeRef(tycon, pre, sym, args)
- case TypeRef(pre, sym, bogons) => debugwarn(s"Dropping $bogons from $tycon in appliedType.") ; copyTypeRef(tycon, pre, sym, args)
+ case TypeRef(pre, sym, bogons) => devWarning(s"Dropping $bogons from $tycon in appliedType.") ; copyTypeRef(tycon, pre, sym, args)
case PolyType(tparams, restpe) => restpe.instantiateTypeParams(tparams, args)
case ExistentialType(tparams, restpe) => newExistentialType(tparams, appliedType(restpe, args))
case st: SingletonType => appliedType(st.widen, args) // @M TODO: what to do? see bug1
@@ -5036,7 +5036,7 @@ trait Types extends api.Types { self: SymbolTable =>
else {
var rebind0 = pre.findMember(sym.name, BRIDGE, 0, true) orElse {
if (sym.isAliasType) throw missingAliasException
- debugwarn(pre+"."+sym+" does no longer exist, phase = "+phase)
+ devWarning(s"$pre.$sym no longer exist at phase $phase")
throw new MissingTypeControl // For build manager and presentation compiler purposes
}
/** The two symbols have the same fully qualified name */
@@ -5094,7 +5094,7 @@ trait Types extends api.Types { self: SymbolTable =>
if ((pre1 eq pre) && (sym1 eq sym) && (args1 eq args)/* && sym.isExternal*/) {
tp
} else if (sym1 == NoSymbol) {
- debugwarn("adapt fail: "+pre+" "+pre1+" "+sym)
+ devWarning(s"adapt to new run failed: pre=$pre pre1=$pre1 sym=$sym")
tp
} else {
copyTypeRef(tp, pre1, sym1, args1)
@@ -7283,7 +7283,7 @@ trait Types extends api.Types { self: SymbolTable =>
protected def typeToString(tpe: Type): String =
if (tostringRecursions >= maxTostringRecursions) {
- debugwarn("Exceeded recursion depth attempting to print type.")
+ devWarning("Exceeded recursion depth attempting to print " + util.shortClassOfInstance(tpe))
if (settings.debug.value)
(new Throwable).printStackTrace
diff --git a/src/reflect/scala/reflect/internal/transform/Erasure.scala b/src/reflect/scala/reflect/internal/transform/Erasure.scala
index a84f01031a..59bf51d638 100644
--- a/src/reflect/scala/reflect/internal/transform/Erasure.scala
+++ b/src/reflect/scala/reflect/internal/transform/Erasure.scala
@@ -233,7 +233,7 @@ trait Erasure {
// It seems there is a deeper problem here, which needs
// following up to. But we will not risk regressions
// in 2.10 because of it.
- log(s"!!! unexpected constructor erasure $tp for $clazz")
+ devWarning(s"unexpected constructor erasure $tp for $clazz")
specialScalaErasure(tp)
}
}