Skip to content

Commit

Permalink
Add ability to debug misfiring SuspendException
Browse files Browse the repository at this point in the history
It should never reach the user, but if it does because of a bug like in scala#18517,
we should have a flag to find out where it came from.
  • Loading branch information
smarter committed Sep 26, 2024
1 parent bac8781 commit 9367900
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/CompilationUnit.scala
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class CompilationUnit protected (val source: SourceFile, val info: CompilationUn

object CompilationUnit {

class SuspendException extends Exception with NoStackTrace
class SuspendException(using Context) extends Exception with StackTraceOnDebug

/** Make a compilation unit for top class `clsd` with the contents of the `unpickled` tree */
def apply(clsd: ClassDenotation, unpickled: Tree, forceTrees: Boolean)(using Context): CompilationUnit =
Expand Down
5 changes: 3 additions & 2 deletions compiler/src/dotty/tools/dotc/core/TypeErrors.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ import collection.mutable

import scala.annotation.constructorOnly

abstract class TypeError(using creationContext: Context) extends Exception(""):

trait StackTraceOnDebug(using Context) extends Throwable:
/** Will the stack trace of this exception be filled in?
* This is expensive and only useful for debugging purposes.
*/
Expand All @@ -35,6 +34,8 @@ abstract class TypeError(using creationContext: Context) extends Exception(""):
if computeStackTrace then super.fillInStackTrace().nn
else this

abstract class TypeError(using creationContext: Context) extends Exception("") with StackTraceOnDebug:

/** Convert to message. This takes an additional Context, so that we
* use the context when the message is first produced, i.e. when the TypeError
* is handled. This makes a difference for CyclicErrors since we need to know
Expand Down

0 comments on commit 9367900

Please sign in to comment.