Skip to content

Fix #4540: Add hint of probable source of issue #4554

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 22, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions compiler/src/dotty/tools/dotc/transform/Splicer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand All @@ -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))
Expand Down