@@ -47,6 +47,8 @@ object Splicer {
4747 interpretedExpr.fold(tree)(macroClosure => PickledQuotes .quotedExprToTree(macroClosure(QuoteContext ())))
4848 }
4949 catch {
50+ case ex : CompilationUnit .SuspendException =>
51+ throw ex
5052 case ex : StopInterpretation =>
5153 ctx.error(ex.msg, ex.pos)
5254 EmptyTree
@@ -348,19 +350,26 @@ object Splicer {
348350 sw.write(" \n " )
349351 throw new StopInterpretation (sw.toString, pos)
350352 case ex : InvocationTargetException =>
351- val sw = new StringWriter ()
352- sw.write(" Exception occurred while executing macro expansion.\n " )
353- val targetException = ex.getTargetException
354- if (! ctx.settings.Ydebug .value) {
355- val end = targetException.getStackTrace.lastIndexWhere { x =>
356- x.getClassName == method.getDeclaringClass.getCanonicalName && x.getMethodName == method.getName
357- }
358- val shortStackTrace = targetException.getStackTrace.take(end + 1 )
359- targetException.setStackTrace(shortStackTrace)
353+ ex.getTargetException match {
354+ case targetException : NoClassDefFoundError => // FIXME check that the class is beeining compiled now
355+ val className = targetException.getMessage
356+ if (ctx.settings.XprintSuspension .value)
357+ ctx.echo(i " suspension triggered by NoClassDefFoundError( $className) " , pos) // TODO improve message
358+ ctx.compilationUnit.suspend() // this throws a SuspendException
359+ case targetException =>
360+ val sw = new StringWriter ()
361+ sw.write(" Exception occurred while executing macro expansion.\n " )
362+ if (! ctx.settings.Ydebug .value) {
363+ val end = targetException.getStackTrace.lastIndexWhere { x =>
364+ x.getClassName == method.getDeclaringClass.getCanonicalName && x.getMethodName == method.getName
365+ }
366+ val shortStackTrace = targetException.getStackTrace.take(end + 1 )
367+ targetException.setStackTrace(shortStackTrace)
368+ }
369+ targetException.printStackTrace(new PrintWriter (sw))
370+ sw.write(" \n " )
371+ throw new StopInterpretation (sw.toString, pos)
360372 }
361- targetException.printStackTrace(new PrintWriter (sw))
362- sw.write(" \n " )
363- throw new StopInterpretation (sw.toString, pos)
364373 }
365374
366375 /** List of classes of the parameters of the signature of `sym` */
0 commit comments