Skip to content

Commit 5e03451

Browse files
committed
Revert "Fix #4291: Copy sticky attachments in TreeCopier"
This reverts commit 4062073.
1 parent ca71bd8 commit 5e03451

File tree

4 files changed

+5
-89
lines changed

4 files changed

+5
-89
lines changed

compiler/src/dotty/tools/dotc/ast/Trees.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ object Trees {
3131
@sharable var ntrees = 0
3232

3333
/** Property key for trees with documentation strings attached */
34-
val DocComment = new Property.StickyKey[Comment]
34+
val DocComment = new Property.Key[Comment]
3535

3636
@sharable private[this] var nextId = 0 // for debugging
3737

@@ -910,10 +910,10 @@ object Trees {
910910
def postProcess(tree: Tree, copied: untpd.MemberDef): copied.ThisTree[T]
911911

912912
def finalize(tree: Tree, copied: untpd.Tree): copied.ThisTree[T] =
913-
postProcess(tree, copied.withPos(tree.pos).withAttachmentsFrom(tree))
913+
postProcess(tree, copied withPos tree.pos)
914914

915915
def finalize(tree: Tree, copied: untpd.MemberDef): copied.ThisTree[T] =
916-
postProcess(tree, copied.withPos(tree.pos).withAttachmentsFrom(tree))
916+
postProcess(tree, copied withPos tree.pos)
917917

918918
def Ident(tree: Tree)(name: Name): Ident = tree match {
919919
case tree: BackquotedIdent =>

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

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,9 @@ package dotty.tools.dotc.util
22

33
/** A class inheriting from Attachment.Container supports
44
* adding, removing and lookup of attachments. Attachments are typed key/value pairs.
5-
*
6-
* Attachments whose key is an instance of `StickyKey` will be kept when the attachments
7-
* are copied using `withAttachmentsFrom`.
85
*/
96
object Attachment {
10-
import Property.{Key, StickyKey}
7+
import Property.Key
118

129
/** An implementation trait for attachments.
1310
* Clients should inherit from Container instead.
@@ -91,16 +88,6 @@ object Attachment {
9188
trait Container extends LinkSource {
9289
private[Attachment] var next: Link[_] = null
9390

94-
/** Copy the sticky attachments from `container` to this container. */
95-
final def withAttachmentsFrom(container: Container): this.type = {
96-
var current: Link[_] = container.next
97-
while (current != null) {
98-
if (current.key.isInstanceOf[StickyKey[_]]) pushAttachment(current.key, current.value)
99-
current = current.next
100-
}
101-
this
102-
}
103-
10491
final def pushAttachment[V](key: Key[V], value: V): Unit = {
10592
assert(!getAttachment(key).isDefined, s"duplicate attachment for key $key")
10693
next = new Link(key, value, next)

compiler/src/dotty/tools/dotc/util/Property.scala

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,4 @@ object Property {
77

88
/** The class of keys for properties of type V */
99
class Key[+V]
10-
11-
/**
12-
* The class of keys for sticky properties of type V
13-
*
14-
* Sticky properties are properties that should be copied over when their container
15-
* is copied.
16-
*/
17-
class StickyKey[+V] extends Key[V]
18-
}
10+
}

compiler/test/dotty/tools/dotc/ast/AttachmentsTest.scala

Lines changed: 0 additions & 63 deletions
This file was deleted.

0 commit comments

Comments
 (0)