Skip to content

Commit ff9c07c

Browse files
nicolasstuckiliufengyun
authored andcommitted
Identify classes defined in current run
1 parent 1babee2 commit ff9c07c

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

compiler/src/dotty/tools/dotc/transform/Splicer.scala

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -351,10 +351,9 @@ object Splicer {
351351
throw new StopInterpretation(sw.toString, pos)
352352
case ex: InvocationTargetException =>
353353
ex.getTargetException match {
354-
case targetException: NoClassDefFoundError => // FIXME check that the class is beeining compiled now
355-
val className = targetException.getMessage
354+
case ClassDefinedInCurrentRun(sym) =>
356355
if (ctx.settings.XprintSuspension.value)
357-
ctx.echo(i"suspension triggered by NoClassDefFoundError($className)", pos) // TODO improve message
356+
ctx.echo(i"suspension triggered by a dependency on $sym", pos)
358357
ctx.compilationUnit.suspend() // this throws a SuspendException
359358
case targetException =>
360359
val sw = new StringWriter()
@@ -372,6 +371,14 @@ object Splicer {
372371
}
373372
}
374373

374+
private object ClassDefinedInCurrentRun {
375+
def unapply(targetException: NoClassDefFoundError)(given ctx: Context): Option[Symbol] = {
376+
val className = targetException.getMessage
377+
val sym = ctx.base.staticRef(className.toTypeName).symbol
378+
if (sym.isDefinedInCurrentRun) Some(sym) else None
379+
}
380+
}
381+
375382
/** List of classes of the parameters of the signature of `sym` */
376383
private def paramsSig(sym: Symbol): List[Class[?]] = {
377384
def paramClass(param: Type): Class[?] = {

0 commit comments

Comments
 (0)