diff --git a/compiler/src/dotty/tools/dotc/transform/Splicer.scala b/compiler/src/dotty/tools/dotc/transform/Splicer.scala index 986fc6b6ca10..51f89b10e821 100644 --- a/compiler/src/dotty/tools/dotc/transform/Splicer.scala +++ b/compiler/src/dotty/tools/dotc/transform/Splicer.scala @@ -140,7 +140,7 @@ object Splicer { try classLoader.loadClass(name.toString) catch { case _: ClassNotFoundException => - val msg = s"Could not find interpreted class $name in classpath" + val msg = s"Could not find macro class $name in classpath$extraMsg" throw new StopInterpretation(msg, pos) } } @@ -149,17 +149,19 @@ object Splicer { try clazz.getMethod(name.toString, paramClasses: _*) catch { case _: NoSuchMethodException => - val msg = s"Could not find interpreted method ${clazz.getCanonicalName}.$name with parameters $paramClasses" + val msg = s"Could not find inline macro method ${clazz.getCanonicalName}.$name with parameters $paramClasses$extraMsg" throw new StopInterpretation(msg, pos) } } + private def extraMsg = ". The most common reason for that is that you cannot use inline macro implementations in the same compilation run that defines them" + private def stopIfRuntimeException[T](thunk: => T): T = { try thunk catch { case ex: RuntimeException => val sw = new StringWriter() - sw.write("A runtime exception occurred while interpreting\n") + sw.write("A runtime exception occurred while executing macro expansion\n") sw.write(ex.getMessage) sw.write("\n") ex.printStackTrace(new PrintWriter(sw))