Skip to content

Commit 11df014

Browse files
committed
Hide stack traces behind -Ydebug
They're not very useful for end users and some tests like tests/neg/selfreq.scala always print these exceptions which makes it harder to read the test logs, Also use Thread.dumpStack() instead of creating an Exception and calling printStackTrace() on it.
1 parent 9d8c92d commit 11df014

File tree

5 files changed

+6
-6
lines changed

5 files changed

+6
-6
lines changed

src/dotty/tools/dotc/core/Types.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3386,7 +3386,7 @@ object Types {
33863386
class MissingType(pre: Type, name: Name)(implicit ctx: Context) extends TypeError(
33873387
i"""cannot resolve reference to type $pre.$name
33883388
|the classfile defining the type might be missing from the classpath${otherReason(pre)}""".stripMargin) {
3389-
printStackTrace()
3389+
if (ctx.debug) printStackTrace()
33903390
}
33913391

33923392
private def otherReason(pre: Type)(implicit ctx: Context): String = pre match {

src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ class Scala2Unpickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClas
186186
val ex = new BadSignature(
187187
sm"""error reading Scala signature of $classRoot from $source:
188188
|error occurred at position $readIndex: $msg""")
189-
/*if (debug)*/ original.getOrElse(ex).printStackTrace() // !!! DEBUG
189+
if (ctx.debug) original.getOrElse(ex).printStackTrace()
190190
throw ex
191191
}
192192

@@ -423,7 +423,7 @@ class Scala2Unpickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClas
423423
owner.info.decls.checkConsistent()
424424
if (slowSearch(name).exists)
425425
System.err.println(i"**** slow search found: ${slowSearch(name)}")
426-
new Exception().printStackTrace()
426+
if (ctx.debug) Thread.dumpStack()
427427
ctx.newStubSymbol(owner, name, source)
428428
}
429429
}

src/dotty/tools/dotc/printing/PlainPrinter.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class PlainPrinter(_ctx: Context) extends Printer {
3232

3333
protected def recursionLimitExceeded() = {
3434
ctx.warning("Exceeded recursion depth attempting to print.")
35-
(new Throwable).printStackTrace
35+
if (ctx.debug) Thread.dumpStack()
3636
}
3737

3838
/** If true, tweak output so it is the same before and after pickling */

src/dotty/tools/dotc/reporting/ConsoleReporter.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class ConsoleReporter(
6363
if (reader != null) {
6464
val response = reader.read().asInstanceOf[Char].toLower
6565
if (response == 'a' || response == 's') {
66-
(new Exception).printStackTrace()
66+
Thread.dumpStack()
6767
if (response == 'a')
6868
sys.exit(1)
6969
}

src/dotty/tools/dotc/transform/PatternMatcher.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ class PatternMatcher extends MiniPhaseTransform with DenotTransformer {thisTrans
327327
private[TreeMakers] def incorporateOuterRebinding(outerSubst: Rebindings): Unit = {
328328
if (currSub ne null) {
329329
ctx.debuglog("BUG: incorporateOuterRebinding called more than once for " + ((this, currSub, outerSubst)))
330-
Thread.dumpStack()
330+
if (ctx.debug) Thread.dumpStack()
331331
}
332332
else currSub = outerSubst >> rebindings
333333
}

0 commit comments

Comments
 (0)