summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2010-04-23 13:11:03 +0000
committerMartin Odersky <odersky@gmail.com>2010-04-23 13:11:03 +0000
commit340080290322fc1c24cb6b35a04fbb23497a17f6 (patch)
treee09da767eb9557d400eeb32ad11b958cfbef7bce /src
parent42ebea46c7e27430131cebe8169955d34571e681 (diff)
downloadscala-340080290322fc1c24cb6b35a04fbb23497a17f6.tar.gz
scala-340080290322fc1c24cb6b35a04fbb23497a17f6.tar.bz2
scala-340080290322fc1c24cb6b35a04fbb23497a17f6.zip
Fixed potential duplicate error annotation "Err...
Fixed potential duplicate error annotation "Error occurred in an application involving default arguments."
Diffstat (limited to 'src')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Contexts.scala30
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala3
2 files changed, 18 insertions, 15 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
index a922d2ad68..759457cb70 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
@@ -46,7 +46,7 @@ trait Contexts { self: Analyzer =>
assert(ScalaPackage ne null, "Scala package is null")
imps += ScalaPackage
if (!(treeInfo.isUnitInScala(unit.body, nme.Predef) ||
- treeInfo.isUnitInScala(unit.body, nme.ScalaObject.toTypeName) ||
+ treeInfo.isUnitInScala(unit.body, nme.ScalaObject) ||
treeInfo.containsLeadingPredefImport(List(unit.body))))
imps += PredefModule
}
@@ -256,23 +256,25 @@ trait Contexts { self: Analyzer =>
if (diagnostic.isEmpty) ""
else diagnostic.mkString("\n","\n", "")
- def error(pos: Position, err: Throwable) {
- val msg = err.getMessage() + diagString
- if (reportGeneralErrors)
- unit.error(pos, if (checking) "**** ERROR DURING INTERNAL CHECKING ****\n" + msg else msg)
- else
- throw err
+ private def addDiagString(msg: String) = {
+ val ds = diagString
+ if (msg endsWith ds) msg else msg + ds
}
- def error(pos: Position, msg: String) {
- val msg1 = msg + diagString
- if (reportGeneralErrors)
- unit.error(pos, if (checking) "**** ERROR DURING INTERNAL CHECKING ****\n" + msg1 else msg1)
- else
- throw new TypeError(pos, msg1)
+ private def unitError(pos: Position, msg: String) =
+ unit.error(pos, if (checking) "**** ERROR DURING INTERNAL CHECKING ****\n" + msg else msg)
+
+ def error(pos: Position, err: Throwable) =
+ if (reportGeneralErrors) unitError(pos, addDiagString(err.getMessage()))
+ else throw err
+
+ def error(pos: Position, msg: String) = {
+ val msg1 = addDiagString(msg)
+ if (reportGeneralErrors) unitError(pos, msg1)
+ else throw new TypeError(pos, msg1)
}
- def warning(pos: Position, msg: String) {
+ def warning(pos: Position, msg: String) = {
if (reportGeneralErrors) unit.warning(pos, msg)
}
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index 1a3f270c9a..879592c444 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -2313,7 +2313,8 @@ trait Typers { self: Analyzer =>
val (allArgs, missing) = addDefaults(args, qual, targs, previousArgss, params, fun.pos.focus, context)
if (allArgs.length == formals.length) {
// useful when a default doesn't match parameter type, e.g. def f[T](x:T="a"); f[Int]()
- context.diagnostic = "Error occurred in an application involving default arguments." :: context.diagnostic
+ val note = "Error occurred in an application involving default arguments."
+ if (!(context.diagnostic contains note)) context.diagnostic = note :: context.diagnostic
doTypedApply(tree, if (blockIsEmpty) fun else fun1, allArgs, mode, pt)
} else {
tryTupleApply.getOrElse {