diff options
author | Eugene Burmako <xeno.by@gmail.com> | 2014-06-28 19:12:48 +0200 |
---|---|---|
committer | Eugene Burmako <xeno.by@gmail.com> | 2014-07-10 11:49:09 +0300 |
commit | 70afd0544e86456515caee62a3eaac41882d892f (patch) | |
tree | 25b2bde31186a95202e94d57769c515c976f89f2 /test/files/pos | |
parent | fbfce33cb03bc2b41dd0f46fa9f4630036b4f2ca (diff) | |
download | scala-70afd0544e86456515caee62a3eaac41882d892f.tar.gz scala-70afd0544e86456515caee62a3eaac41882d892f.tar.bz2 scala-70afd0544e86456515caee62a3eaac41882d892f.zip |
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.
Diffstat (limited to 'test/files/pos')
-rw-r--r-- | test/files/pos/macro-attachments/Macros_1.scala | 19 | ||||
-rw-r--r-- | test/files/pos/macro-attachments/Test_2.scala | 3 |
2 files changed, 22 insertions, 0 deletions
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 diff --git a/test/files/pos/macro-attachments/Test_2.scala b/test/files/pos/macro-attachments/Test_2.scala new file mode 100644 index 0000000000..acfddae942 --- /dev/null +++ b/test/files/pos/macro-attachments/Test_2.scala @@ -0,0 +1,3 @@ +object Test extends App { + Macros.foo +}
\ No newline at end of file |