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. --- src/reflect/scala/reflect/macros/Attachments.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/reflect/scala/reflect/macros') diff --git a/src/reflect/scala/reflect/macros/Attachments.scala b/src/reflect/scala/reflect/macros/Attachments.scala index 5ccdc15a03..b5c340645a 100644 --- a/src/reflect/scala/reflect/macros/Attachments.scala +++ b/src/reflect/scala/reflect/macros/Attachments.scala @@ -35,7 +35,7 @@ abstract class Attachments { self => def all: Set[Any] = Set.empty private def matchesTag[T: ClassTag](datum: Any) = - classTag[T].runtimeClass == datum.getClass + classTag[T].runtimeClass.isInstance(datum) /** An underlying payload of the given class type `T`. */ def get[T: ClassTag]: Option[T] = -- cgit v1.2.3