diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2014-11-07 11:10:15 +1000 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2014-11-07 11:10:15 +1000 |
commit | 7830b4689a5f9962011f117c9b866a939795e58a (patch) | |
tree | cc3e0a2bbf67d350775d44dbe648ea2e37451c1c /src | |
parent | 000de44e3b1f1c0c4bc30eda8ef155548714a6af (diff) | |
parent | 17992f672f7d5663654a1ea365dfd1dad7061410 (diff) | |
download | scala-7830b4689a5f9962011f117c9b866a939795e58a.tar.gz scala-7830b4689a5f9962011f117c9b866a939795e58a.tar.bz2 scala-7830b4689a5f9962011f117c9b866a939795e58a.zip |
Merge pull request #4083 from retronym/ticket/8947
SI-8947 Avoid cross talk between tag materializers and reify
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/reflect/reify/Taggers.scala | 3 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/StdAttachments.scala | 2 | ||||
-rw-r--r-- | src/reflect/scala/reflect/internal/Trees.scala | 8 |
3 files changed, 10 insertions, 3 deletions
diff --git a/src/compiler/scala/reflect/reify/Taggers.scala b/src/compiler/scala/reflect/reify/Taggers.scala index 093c2bee22..0863ee38f9 100644 --- a/src/compiler/scala/reflect/reify/Taggers.scala +++ b/src/compiler/scala/reflect/reify/Taggers.scala @@ -79,8 +79,7 @@ abstract class Taggers { try materializer catch { case ReificationException(pos, msg) => - c.error(pos.asInstanceOf[c.Position], msg) // this cast is a very small price for the sanity of exception handling - EmptyTree + c.abort(pos.asInstanceOf[c.Position], msg) // this cast is a very small price for the sanity of exception handling case UnexpectedReificationException(pos, err, cause) if cause != null => throw cause } diff --git a/src/compiler/scala/tools/nsc/typechecker/StdAttachments.scala b/src/compiler/scala/tools/nsc/typechecker/StdAttachments.scala index 57f27a05fd..ea44b9dc39 100644 --- a/src/compiler/scala/tools/nsc/typechecker/StdAttachments.scala +++ b/src/compiler/scala/tools/nsc/typechecker/StdAttachments.scala @@ -61,7 +61,7 @@ trait StdAttachments { val metadata = MacroExpansionAttachment(expandee, expanded) expandee updateAttachment metadata expanded match { - case expanded: Tree => expanded updateAttachment metadata + case expanded: Tree if !expanded.isEmpty => expanded updateAttachment metadata case _ => // do nothing } } diff --git a/src/reflect/scala/reflect/internal/Trees.scala b/src/reflect/scala/reflect/internal/Trees.scala index 2f07cef315..35de3adff6 100644 --- a/src/reflect/scala/reflect/internal/Trees.scala +++ b/src/reflect/scala/reflect/internal/Trees.scala @@ -9,6 +9,7 @@ package internal import Flags._ import scala.collection.{ mutable, immutable } +import scala.reflect.macros.Attachments import util.Statistics trait Trees extends api.Trees { @@ -1074,6 +1075,13 @@ trait Trees extends api.Trees { override def setType(t: Type) = { requireLegal(t, NoType, "tpe"); this } override def tpe_=(t: Type) = setType(t) + // We silently ignore attempts to add attachments to `EmptyTree`. See SI-8947 for an + // example of a bug in macro expansion that this solves. + override def setAttachments(attachments: Attachments {type Pos = Position}): this.type = attachmentWarning() + override def updateAttachment[T: ClassTag](attachment: T): this.type = attachmentWarning() + override def removeAttachment[T: ClassTag]: this.type = attachmentWarning() + private def attachmentWarning(): this.type = {devWarning(s"Attempt to mutate attachments on $self ignored"); this} + private def requireLegal(value: Any, allowed: Any, what: String) = ( if (value != allowed) { log(s"can't set $what for $self to value other than $allowed") |