Skip to content

Commit accfa1a

Browse files
Fix #4540: Add hint of probable source of issue
1 parent fabd65d commit accfa1a

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ object Splicer {
140140
try classLoader.loadClass(name.toString)
141141
catch {
142142
case _: ClassNotFoundException =>
143-
val msg = s"Could not find interpreted class $name in classpath"
143+
val msg = s"Could not find macro class $name in classpath $extraMsg"
144144
throw new StopInterpretation(msg, pos)
145145
}
146146
}
@@ -149,17 +149,19 @@ object Splicer {
149149
try clazz.getMethod(name.toString, paramClasses: _*)
150150
catch {
151151
case _: NoSuchMethodException =>
152-
val msg = s"Could not find interpreted method ${clazz.getCanonicalName}.$name with parameters $paramClasses"
152+
val msg = s"Could not find inline macro method ${clazz.getCanonicalName}.$name with parameters $paramClasses $extraMsg"
153153
throw new StopInterpretation(msg, pos)
154154
}
155155
}
156156

157+
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)"
158+
157159
private def stopIfRuntimeException[T](thunk: => T): T = {
158160
try thunk
159161
catch {
160162
case ex: RuntimeException =>
161163
val sw = new StringWriter()
162-
sw.write("A runtime exception occurred while interpreting\n")
164+
sw.write("A runtime exception occurred while executing macro expansion\n")
163165
sw.write(ex.getMessage)
164166
sw.write("\n")
165167
ex.printStackTrace(new PrintWriter(sw))

0 commit comments

Comments
 (0)