diff options
author | Eugene Burmako <xeno.by@gmail.com> | 2014-03-07 14:52:23 +0100 |
---|---|---|
committer | Eugene Burmako <xeno.by@gmail.com> | 2014-03-07 18:56:35 +0100 |
commit | b10f45a78217b002f8ac6e2051ff932a1ac2e029 (patch) | |
tree | fe781db5f7290794ddbec794aa53f2e399f12af8 /src | |
parent | 2dddb03b267770afcd0249ad700e55d53019e637 (diff) | |
download | scala-b10f45a78217b002f8ac6e2051ff932a1ac2e029.tar.gz scala-b10f45a78217b002f8ac6e2051ff932a1ac2e029.tar.bz2 scala-b10f45a78217b002f8ac6e2051ff932a1ac2e029.zip |
SI-8375 saner binary incompat errors for macros
Inspired by Brian McKenna's RC1 migration experience, this commit improves
macro impl binding validation in order to provide more helpful diagnostic
for this quite frequent class of errors.
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala | 5 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Macros.scala | 4 |
2 files changed, 5 insertions, 4 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala b/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala index 2043eb5d5d..156f9d4f4a 100644 --- a/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala +++ b/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala @@ -725,8 +725,9 @@ trait ContextErrors { NormalTypeError(expandee, "too many argument lists for " + fun) } - def MacroIncompatibleEngineError(macroEngine: String) = { - val message = s"macro cannot be expanded, because it was compiled by an incompatible macro engine $macroEngine" + def MacroIncompatibleEngineError(diagnostic: String) = { + var message = s"macro cannot be expanded, because it was compiled by an incompatible macro engine" + if (macroDebugLite || macroDebugVerbose) message += s" (internal diagnostic: $diagnostic)" issueNormalTypeError(lastTreeToTyper, message) } diff --git a/src/compiler/scala/tools/nsc/typechecker/Macros.scala b/src/compiler/scala/tools/nsc/typechecker/Macros.scala index 677c94e063..f1dd00d4cd 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Macros.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Macros.scala @@ -224,7 +224,7 @@ trait Macros extends FastTrack with MacroRuntimes with Traces with Helpers { val Apply(_, pickledPayload) = wrapped val payload = pickledPayload.map{ case Assign(k, v) => (unpickleAtom(k), unpickleAtom(v)) }.toMap - def fail(msg: String) = abort(s"bad macro impl binding: $msg") + def fail(msg: String) = typer.TyperErrorGen.MacroIncompatibleEngineError(msg) def unpickle[T](field: String, clazz: Class[T]): T = { def failField(msg: String) = fail(s"$field $msg") if (!payload.contains(field)) failField("is supposed to be there") @@ -237,7 +237,7 @@ trait Macros extends FastTrack with MacroRuntimes with Traces with Helpers { } val macroEngine = unpickle("macroEngine", classOf[String]) - if (self.macroEngine != macroEngine) typer.TyperErrorGen.MacroIncompatibleEngineError(macroEngine) + if (self.macroEngine != macroEngine) typer.TyperErrorGen.MacroIncompatibleEngineError(s"expected = ${self.macroEngine}, actual = $macroEngine") val isBundle = unpickle("isBundle", classOf[Boolean]) val isBlackbox = unpickle("isBlackbox", classOf[Boolean]) |