diff options
author | Lukas Rytz <lukas.rytz@typesafe.com> | 2015-09-18 14:51:34 +0200 |
---|---|---|
committer | Lukas Rytz <lukas.rytz@typesafe.com> | 2015-09-18 14:51:34 +0200 |
commit | c287df96cf42084828d9528353d5c7ad5c0e4b3a (patch) | |
tree | e5c6eb4daf0ff1920b648001e84aab9603986396 /src | |
parent | 2e1f78b01c31d675ea182e7c95c78c2458897a67 (diff) | |
parent | 32da6dce10586f9ac54877ba776447b353293851 (diff) | |
download | scala-c287df96cf42084828d9528353d5c7ad5c0e4b3a.tar.gz scala-c287df96cf42084828d9528353d5c7ad5c0e4b3a.tar.bz2 scala-c287df96cf42084828d9528353d5c7ad5c0e4b3a.zip |
Merge pull request #4724 from retronym/topic/positioned-errors
Try harder to avoid reporting unpositioned errors
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Contexts.scala | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala index 43f2655311..c46bc7444a 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala @@ -574,19 +574,23 @@ trait Contexts { self: Analyzer => /** Issue/buffer/throw the given implicit ambiguity error according to the current mode for error reporting. */ private[typechecker] def issueAmbiguousError(err: AbsAmbiguousTypeError) = reporter.issueAmbiguousError(err)(this) /** Issue/throw the given error message according to the current mode for error reporting. */ - def error(pos: Position, msg: String) = reporter.error(pos, msg) + def error(pos: Position, msg: String) = reporter.error(fixPosition(pos), msg) /** Issue/throw the given error message according to the current mode for error reporting. */ - def warning(pos: Position, msg: String) = reporter.warning(pos, msg) - def echo(pos: Position, msg: String) = reporter.echo(pos, msg) + def warning(pos: Position, msg: String) = reporter.warning(fixPosition(pos), msg) + def echo(pos: Position, msg: String) = reporter.echo(fixPosition(pos), msg) + def fixPosition(pos: Position): Position = pos match { + case NoPosition => nextEnclosing(_.tree.pos != NoPosition).tree.pos + case _ => pos + } def deprecationWarning(pos: Position, sym: Symbol, msg: String): Unit = - currentRun.reporting.deprecationWarning(pos, sym, msg) + currentRun.reporting.deprecationWarning(fixPosition(pos), sym, msg) def deprecationWarning(pos: Position, sym: Symbol): Unit = - currentRun.reporting.deprecationWarning(pos, sym) // TODO: allow this to escalate to an error, and implicit search will ignore deprecated implicits + currentRun.reporting.deprecationWarning(fixPosition(pos), sym) // TODO: allow this to escalate to an error, and implicit search will ignore deprecated implicits def featureWarning(pos: Position, featureName: String, featureDesc: String, featureTrait: Symbol, construct: => String = "", required: Boolean): Unit = - currentRun.reporting.featureWarning(pos, featureName, featureDesc, featureTrait, construct, required) + currentRun.reporting.featureWarning(fixPosition(pos), featureName, featureDesc, featureTrait, construct, required) // nextOuter determines which context is searched next for implicits @@ -1239,7 +1243,7 @@ trait Contexts { self: Analyzer => type Error = AbsTypeError type Warning = (Position, String) - def issue(err: AbsTypeError)(implicit context: Context): Unit = handleError(err.errPos, addDiagString(err.errMsg)) + def issue(err: AbsTypeError)(implicit context: Context): Unit = handleError(context.fixPosition(err.errPos), addDiagString(err.errMsg)) protected def handleError(pos: Position, msg: String): Unit protected def handleSuppressedAmbiguous(err: AbsAmbiguousTypeError): Unit = () @@ -1256,7 +1260,7 @@ trait Contexts { self: Analyzer => * - else, let this context reporter decide */ final def issueAmbiguousError(err: AbsAmbiguousTypeError)(implicit context: Context): Unit = - if (context.ambiguousErrors) reporter.error(err.errPos, addDiagString(err.errMsg)) // force reporting... see TODO above + if (context.ambiguousErrors) reporter.error(context.fixPosition(err.errPos), addDiagString(err.errMsg)) // force reporting... see TODO above else handleSuppressedAmbiguous(err) @inline final def withFreshErrorBuffer[T](expr: => T): T = { |