File tree Expand file tree Collapse file tree 2 files changed +7
-4
lines changed
compiler/src/dotty/tools/dotc/util Expand file tree Collapse file tree 2 files changed +7
-4
lines changed Original file line number Diff line number Diff line change 11package dotty .tools .dotc .util
22
3+ import dotty .tools .dotc .core .Contexts .Context
4+
35/** A class inheriting from Attachment.Container supports
46 * adding, removing and lookup of attachments. Attachments are typed key/value pairs.
57 *
@@ -103,19 +105,19 @@ object Attachment {
103105 final def withAttachmentsFrom (container : Container ): this .type = {
104106 var current : Link [? ] = container.next
105107 while (current != null ) {
106- if (current.key.isInstanceOf [StickyKey [? ]]) pushAttachment (current.key, current.value)
108+ if (current.key.isInstanceOf [StickyKey [? ]]) putAttachment (current.key, current.value)
107109 current = current.next
108110 }
109111 this
110112 }
111113
112114 def withAttachment [V ](key : Key [V ], value : V ): this .type = {
113- pushAttachment (key, value)
115+ putAttachment (key, value)
114116 this
115117 }
116118
117- final def pushAttachment [V ](key : Key [V ], value : V ): Unit = {
118- assert(! hasAttachment(key), s " duplicate attachment for key $key" )
119+ final def pushAttachment [V ](key : Key [V ], value : V )( using ctx : Context ) : Unit = {
120+ assert(! hasAttachment(key) || ctx.reporter.errorsReported , s " duplicate attachment for key $key" )
119121 next = new Link (key, value, next)
120122 }
121123
Original file line number Diff line number Diff line change 1+ @ foo class foo [X ] // error // error
You can’t perform that action at this time.
0 commit comments