Skip to content

Commit 34c4107

Browse files
committed
Add a flag to disable handleRecursive
1 parent 5ef9263 commit 34c4107

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

compiler/src/dotty/tools/dotc/config/ScalaSettings.scala

+1
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ class ScalaSettings extends Settings.SettingGroup {
146146
val Xlink = BooleanSetting("-Xlink", "Recompile library code with the application.")
147147
val YoptPhases = PhasesSetting("-Yopt-phases", "Restrict the optimisation phases to execute under -optimise.")
148148
val YoptFuel = IntSetting("-Yopt-fuel", "Maximum number of optimisations performed under -optimise.", -1)
149+
val YnoDecodeStacktraces = BooleanSetting("-Yno-decode-stacktraces", "Show operations that triggered StackOverflows instead of printing the raw stacktraces.")
149150

150151
/** Dottydoc specific settings */
151152
val siteRoot = StringSetting(

compiler/src/dotty/tools/dotc/core/TypeErrors.scala

+14-8
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,20 @@ class RecursionOverflow(val op: String, details: => String, previous: Throwable,
8181
// Beware: Since this object is only used when handling a StackOverflow, this code
8282
// cannot consume significant amounts of stack.
8383
object handleRecursive {
84-
def apply(op: String, details: => String, exc: Throwable, weight: Int = 1): Nothing = exc match {
85-
case _: RecursionOverflow =>
86-
throw new RecursionOverflow(op, details, exc, weight)
87-
case _ =>
88-
var e = exc
89-
while (e != null && !e.isInstanceOf[StackOverflowError]) e = e.getCause
90-
if (e != null) throw new RecursionOverflow(op, details, e, weight)
91-
else throw exc
84+
def apply(op: String, details: => String, exc: Throwable, weight: Int = 1)(implicit ctx: Context): Nothing = {
85+
if (ctx.settings.YnoDecodeStacktraces.value) {
86+
throw exc
87+
} else {
88+
exc match {
89+
case _: RecursionOverflow =>
90+
throw new RecursionOverflow(op, details, exc, weight)
91+
case _ =>
92+
var e = exc
93+
while (e != null && !e.isInstanceOf[StackOverflowError]) e = e.getCause
94+
if (e != null) throw new RecursionOverflow(op, details, e, weight)
95+
else throw exc
96+
}
97+
}
9298
}
9399
}
94100

0 commit comments

Comments
 (0)