File tree Expand file tree Collapse file tree 2 files changed +42
-4
lines changed
lib/ASTGen/Sources/ASTGen Expand file tree Collapse file tree 2 files changed +42
-4
lines changed Original file line number Diff line number Diff line change @@ -1246,12 +1246,19 @@ extension ASTGenVisitor {
1246
1246
// E.g. 'named(foo())', use the callee to generate the name.
1247
1247
arg = call. calledExpression
1248
1248
}
1249
- guard let arg = arg. as ( DeclReferenceExprSyntax . self) else {
1250
- // TODO: Diagnose.
1251
- return nil
1249
+
1250
+ if let arg = arg. as ( DeclReferenceExprSyntax . self) {
1251
+ name = self . generateDeclNameRef ( declReferenceExpr: arg) . name
1252
+ } else if arg. is ( DiscardAssignmentExprSyntax . self) {
1253
+ name = BridgedDeclNameRef . createParsed ( . createIdentifier( self . ctx. getIdentifier ( " _ " ) ) )
1254
+ } else {
1255
+ // TODO: Diagnose
1256
+ fatalError ( " expected name " )
1257
+ //return nil
1252
1258
}
1253
- name = self . generateDeclNameRef ( declReferenceExpr : arg ) . name
1259
+
1254
1260
if arguments. count >= 2 {
1261
+ fatalError ( " unexpected arguments " )
1255
1262
// TODO: Diagnose.
1256
1263
}
1257
1264
Original file line number Diff line number Diff line change @@ -115,3 +115,34 @@ func f(a: Int, b: String) async throws -> String
115
115
struct TestArbitrary {
116
116
#bitwidthNumberedStructs( " MyIntOne" )
117
117
}
118
+
119
+ // Stored properties generated by a peer macro
120
+ @attached(accessor)
121
+ @attached(peer, names: prefixed(_))
122
+ macro myPropertyWrapper() =
123
+ #externalMacro(module: " MacroDefinition" , type: " PropertyWrapperMacro" )
124
+
125
+ struct MyWrapperThingy<T> {
126
+ var storage: T
127
+
128
+ var wrappedValue: T {
129
+ get {
130
+ print( " Getting value \( storage) " )
131
+ return storage
132
+ }
133
+
134
+ set {
135
+ print( " Setting value \( newValue) " )
136
+ storage = newValue
137
+ }
138
+ }
139
+ }
140
+
141
+ struct S3 {
142
+ @myPropertyWrapper
143
+ var x: Int = 0
144
+
145
+ init(x: Int) {
146
+ self._x = MyWrapperThingy(storage: x)
147
+ }
148
+ }
You can’t perform that action at this time.
0 commit comments