From 70afd0544e86456515caee62a3eaac41882d892f Mon Sep 17 00:00:00 2001 From: Eugene Burmako Date: Sat, 28 Jun 2014 19:12:48 +0200 Subject: relaxes attachment-matching rules It came as a surprise recently, but attachments.contains/get/update/remove require the class of the payload to match the provided tag exactly, not taking subclassing into account. This commit fixes the oversight. --- test/files/pos/macro-attachments/Macros_1.scala | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 test/files/pos/macro-attachments/Macros_1.scala (limited to 'test/files/pos/macro-attachments/Macros_1.scala') diff --git a/test/files/pos/macro-attachments/Macros_1.scala b/test/files/pos/macro-attachments/Macros_1.scala new file mode 100644 index 0000000000..38d05d5b85 --- /dev/null +++ b/test/files/pos/macro-attachments/Macros_1.scala @@ -0,0 +1,19 @@ +import scala.language.experimental.macros +import scala.reflect.macros.whitebox.Context + +trait Base +class Att extends Base + +object Macros { + def impl(c: Context) = { + import c.universe._ + import c.internal._ + import decorators._ + val dummy = q"x" + dummy.updateAttachment(new Att) + if (dummy.attachments.get[Base].isEmpty) c.abort(c.enclosingPosition, "that's not good") + q"()" + } + + def foo: Any = macro impl +} \ No newline at end of file -- cgit v1.2.3