File tree 2 files changed +7
-4
lines changed
compiler/src/dotty/tools/dotc/util
2 files changed +7
-4
lines changed Original file line number Diff line number Diff line change 1
1
package dotty .tools .dotc .util
2
2
3
+ import dotty .tools .dotc .core .Contexts .Context
4
+
3
5
/** A class inheriting from Attachment.Container supports
4
6
* adding, removing and lookup of attachments. Attachments are typed key/value pairs.
5
7
*
@@ -103,19 +105,19 @@ object Attachment {
103
105
final def withAttachmentsFrom (container : Container ): this .type = {
104
106
var current : Link [? ] = container.next
105
107
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)
107
109
current = current.next
108
110
}
109
111
this
110
112
}
111
113
112
114
def withAttachment [V ](key : Key [V ], value : V ): this .type = {
113
- pushAttachment (key, value)
115
+ putAttachment (key, value)
114
116
this
115
117
}
116
118
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" )
119
121
next = new Link (key, value, next)
120
122
}
121
123
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