You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Sema] Downgrade implicit self diag to warning for macro args
We previously missed diagnosing this for macro
args, fixing it turned out to be a bit more source
breaking than initially thought though, so downgrade
to a warning until Swift 7.
rdar://141963700
// rdar://141963700 - Downgrade these to a warning for the macro argument,
148
+
// but is still an error in the expansion.
135
149
_ ={
136
150
_ = #trailingClosure{
137
151
foo()
138
152
// CHECK-DIAG: @__swiftmacro_6Client0017Clientswift_yEEFcfMX[[@LINE-3]]{{.*}}trailingClosurefMf_.swift:2:9: error: call to method 'foo' in closure requires explicit use of 'self' to make capture semantics explicit
139
-
// CHECK-DIAG: Client.swift:[[@LINE-2]]:9: error: call to method 'foo' in closure requires explicit use of 'self' to make capture semantics explicit
153
+
// CHECK-DIAG: Client.swift:[[@LINE-2]]:9: warning: call to method 'foo' in closure requires explicit use of 'self' to make capture semantics explicit; this will be an error in a future Swift language mode
140
154
}
155
+
// Use an attribute to force a MacroExpansionDecl (otherwise we parse a
156
+
// MacroExpansionExpr)
157
+
@discardableResult
158
+
#makeFunc(foo())
159
+
// CHECK-DIAG: Client.swift:[[@LINE-1]]:17: warning: call to method 'foo' in closure requires explicit use of 'self' to make capture semantics explicit; this will be an error in a future Swift language mode
// rdar://141963700 - This is downgraded to a warning for Swift 6 in the
35
+
// expansion, and Swift 7 for the argument.
36
+
_ ={[self]in
37
+
_ = #trailingClosure {
38
+
foo()
39
+
// CHECK-DIAG: @__swiftmacro_6Client0017Clientswift_yEEFcfMX[[@LINE-3]]{{.*}}trailingClosurefMf_.swift:2:9: warning: call to method 'foo' in closure requires explicit use of 'self' to make capture semantics explicit; this is an error in the Swift 6 language mode
40
+
// CHECK-DIAG: Client.swift:[[@LINE-2]]:9: warning: call to method 'foo' in closure requires explicit use of 'self' to make capture semantics explicit; this will be an error in a future Swift language mode
// rdar://141963700 - In Swift 7 these are errors.
48
+
_ ={
49
+
_ = #trailingClosure{
50
+
foo()
51
+
// CHECK-DIAG: @__swiftmacro_6Client0017Clientswift_yEEFcfMX[[@LINE-3]]{{.*}}trailingClosurefMf_.swift:2:9: error: call to method 'foo' in closure requires explicit use of 'self' to make capture semantics explicit
52
+
// CHECK-DIAG: Client.swift:[[@LINE-2]]:9: error: call to method 'foo' in closure requires explicit use of 'self' to make capture semantics explicit
53
+
}
54
+
// Use an attribute to force a MacroExpansionDecl (otherwise we parse a
55
+
// MacroExpansionExpr)
56
+
@discardableResult
57
+
#makeFunc(foo())
58
+
// CHECK-DIAG: Client.swift:[[@LINE-1]]:17: error: call to method 'foo' in closure requires explicit use of 'self' to make capture semantics explicit
0 commit comments