Skip to content

Commit c37b408

Browse files
committed
New utility method: hasAttachment
Used to test whether a tree has an attachment of a given key value.
1 parent 8e6d2c3 commit c37b408

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/dotty/tools/dotc/util/Attachment.scala

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,15 @@ object Attachment {
1919
val nx = next
2020
if (nx == null) None
2121
else if (nx.key eq key) Some(nx.value.asInstanceOf[V])
22-
else nx.getAttachment[V](key)
22+
else nx.getAttachment(key)
23+
}
24+
25+
/** Does tree have an attachment corresponding to `key`? */
26+
final def hasAttachment[V](key: Key[V]): Boolean = {
27+
val nx = next
28+
if (nx == null) false
29+
else if (nx.key eq key) true
30+
else nx.hasAttachment(key)
2331
}
2432

2533
/** The attachment corresponding to `key`.

0 commit comments

Comments
 (0)