8000 add -Ydebug-error option · scala/scala@70459f8 · GitHub
[go: up one dir, main page]

Skip to content

Commit 70459f8

Browse files
author
peng
committed
add -Ydebug-error option
add a test to ensure that it works remove an obsolete option
1 parent ad8bceb commit 70459f8

File tree

5 files changed

+265
-5
lines changed

5 files changed

+265
-5
lines changed

project/ScalaOptionParser.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ object ScalaOptionParser {
8686
"-Xno-forwarders", "-Xno-patmat-analysis", "-Xnon-strict-patmat-analysis", "-Xprint-pos", "-Xprint-types", "-Xprompt", "-Xresident", "-Xshow-phases", "-Xverify", "-Y",
8787
"-Ybreak-cycles", "-Ydebug", "-Ycompact-trees", "-YdisableFlatCpCaching", "-Ydoc-debug",
8888
"-Yide-debug",
89-
"-Yissue-debug", "-Ylog-classpath", "-Ymacro-debug-lite", "-Ymacro-debug-verbose", "-Ymacro-no-expand",
89+
"-Ylog-classpath", "-Ymacro-debug-lite", "-Ymacro-debug-verbose", "-Ymacro-no-expand",
9090
"-Yno-completion", "-Yno-generic-signatures", "-Yno-imports", "-Yno-predef", "-Ymacro-annotations",
9191
"-Ypatmat-debug", "-Yno-adapted-args", "-Ypos-debug", "-Ypresentation-debug",
9292
"-Ypresentation-strict", "-Ypresentation-verbose", "-Yquasiquote-debug", "-Yrangepos", "-Yreify-copypaste", "-Yreify-debug", "-Yrepl-class-based",

src/compiler/scala/tools/nsc/settings/ScalaSettings.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,9 +455,10 @@ trait ScalaSettings extends StandardScalaSettings with Warnings { _: MutableSett
455455
val browse = PhasesSetting("-Vbrowse", "Browse the abstract syntax tree after") withAbbreviation "-Ybrowse"
456456
val debug = BooleanSetting("-Vdebug", "Increase the quantity of debugging output.") withAbbreviation "-Ydebug" withPostSetHook (s => if (s.value) StatisticsStatics.enableDebugAndDeoptimize())
457457
val YdebugTasty = BooleanSetting("-Vdebug-tasty", "Increase the quantity of debugging output when unpickling tasty.") withAbbreviation "-Ydebug-tasty"
458+
val YdebugError = BooleanSetting("-Ydebug-error", "Print the stack trace when any error is caught.")
458459
val Ydocdebug = BooleanSetting("-Vdoc", "Trace scaladoc activity.") withAbbreviation "-Ydoc-debug"
459460
val Yidedebug = BooleanSetting("-Vide", "Generate, validate and output trees using the interactive compiler.") withAbbreviation "-Yide-debug"
460-
val Yissuedebug = BooleanSetting("-Vissue", "Print stack traces when a context issues an error.") withAbbreviation "-Yissue-debug"
461+
// val Yissuedebug = BooleanSetting("-Vissue", "Print stack traces when a context issues an error.") withAbbreviation "-Yissue-debug"
461462
val log = PhasesSetting("-Vlog", "Log operations during") withAbbreviation "-Ylog"
462463
val Ylogcp = BooleanSetting("-Vclasspath", "Output information about what classpath is being applied.") withAbbreviation "-Ylog-classpath"
463464
val YmacrodebugLite = BooleanSetting("-Vmacro-lite", "Trace macro activities with less output.") withAbbreviation "-Ymacro-debug-lite"

src/compiler/scala/tools/nsc/typechecker/Contexts.scala

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -808,7 +808,7 @@ trait Contexts { self: Analyzer =>
808808
/** Issue/buffer/throw the given implicit ambiguity error according to the current mode for error reporting. */
809809
private[typechecker] def issueAmbiguousError(err: AbsAmbiguousTypeError) = reporter.issueAmbiguousError(err)(this)
810810
/** Issue/throw the given error message according to the current mode for error reporting. */
811-
def error(pos: Position, msg: String) = reporter.error(fixPosition(pos), msg)
811+
def error(pos: Position, msg: String) = reporter.errorAndDump(fixPosition(pos), msg)
812812
/** Issue/throw the given error message according to the current mode for error reporting. */
813813
def warning(pos: Position, msg: String, category: WarningCategory) = reporter.warning(fixPosition(pos), msg, category, owner)
814814
def warning(pos: Position, msg: String, category: WarningCategory, site: Symbol) = reporter.warning(fixPosition(pos), msg, category, site)
@@ -1643,7 +1643,7 @@ trait Contexts { self: Analyzer =>
16431643
type Error = AbsTypeError
16441644
type Warning = (Position, String, WarningCategory, Symbol)
16451645

1646-
def issue(err: AbsTypeError)(implicit context: Context): Unit = error(context.fixPosition(err.errPos), addDiagString(err.errMsg))
1646+
def issue(err: AbsTypeError)(implicit context: Context): Unit = errorAndDump(context.fixPosition(err.errPos), addDiagString(err.errMsg))
16471647

16481648
def echo(msg: String): Unit = echo(NoPosition, msg)
16491649

@@ -1655,6 +1655,13 @@ trait Contexts { self: Analyzer =>
16551655

16561656
def error(pos: Position, msg: String): Unit
16571657

1658+
final def errorAndDump(pos: Position, msg: String): Unit = {
1659+
error(pos, msg)
1660+
if (settings.YdebugError.value) {
1661+
Thread.dumpStack()
1662+
}
1663+
}
1664+
16581665
protected def handleSuppressedAmbiguous(err: AbsAmbiguousTypeError): Unit = ()
16591666

16601667
def makeImmediate: ContextReporter = this
@@ -1686,7 +1693,7 @@ trait Contexts { self: Analyzer =>
16861693
if (target.isBuffering) {
16871694
target ++= errors
16881695
} else {
1689-
errors.foreach(e => target.error(e.errPos, e.errMsg))
1696+
errors.foreach(e => target.errorAndDump(e.errPos, e.errMsg))
16901697
}
16911698
// TODO: is clearAllErrors necessary? (no tests failed when dropping it)
16921699
// NOTE: even though `this ne target`, it may still be that `target.errorBuffer eq _errorBuffer`,

0 commit comments

Comments
 (0)
0