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
Copy file name to clipboardExpand all lines: test/expr/closure/closures.swift
+25-3Lines changed: 25 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -1229,7 +1229,7 @@ class TestGithubIssue70089 {
1229
1229
x +=1 // expected-error {{reference to property 'x' in closure requires explicit use of 'self' to make capture semantics explicit}} expected-note {{reference 'self.' explicitly}}
1230
1230
}
1231
1231
1232
-
doVoidStuff{[self=TestGithubIssue70089()] in // expected-note {{variable other than 'self' captured here under the name 'self' does not enable implicit 'self'}} expected-note {{variable other than 'self' captured here under the name 'self' does not enable implicit 'self'}} expected-note{{variable other than 'self' captured here under the name 'self' does not enable implicit 'self'}}
1232
+
doVoidStuff{[self=TestGithubIssue70089()] in // expected-note {{variable other than 'self' captured here under the name 'self' does not enable implicit 'self'}} expected-note {{variable other than 'self' captured here under the name 'self' does not enable implicit 'self'}} expected-note{{variable other than 'self' captured here under the name 'self' does not enable implicit 'self'}}
1233
1233
x +=1 // expected-error{{reference to property 'x' in closure requires explicit use of 'self' to make capture semantics explicit}}
1234
1234
self.x +=1
1235
1235
@@ -1347,6 +1347,14 @@ class TestGithubIssue69911 {
1347
1347
self.x +=1
1348
1348
}
1349
1349
}
1350
+
1351
+
doVoidStuffNonEscaping{[weak self]in
1352
+
doVoidStuffNonEscaping{ // expected-note{{capture 'self' explicitly to enable implicit 'self' in this closure}}
1353
+
guardlet self else{return}
1354
+
x +=1 // expected-error{{reference to property 'x' in closure requires explicit use of 'self' to make capture semantics explicit}} expected-note{{reference 'self.' explicitly}}
1355
+
self.x +=1
1356
+
}
1357
+
}
1350
1358
1351
1359
doVoidStuffNonEscaping{[self=TestGithubIssue69911()] in // expected-note {{variable other than 'self' captured here under the name 'self' does not enable implicit 'self'}} expected-note {{variable other than 'self' captured here under the name 'self' does not enable implicit 'self'}} expected-note {{variable other than 'self' captured here under the name 'self' does not enable implicit 'self'}}
1352
1360
x +=1 // expected-error{{reference to property 'x' in closure requires explicit use of 'self' to make capture semantics explicit}}
@@ -1441,7 +1449,7 @@ final class AutoclosureTests {
1441
1449
withEscapingAutoclosure(bar()) // expected-warning {{call to method 'bar' in closure requires explicit use of 'self' to make capture semantics explicit}} expected-note {{reference 'self.' explicitly}}
1442
1450
1443
1451
doVoidStuff{ // expected-note {{capture 'self' explicitly to enable implicit 'self' in this closure}}
1444
-
withNonEscapingAutoclosure(bar()) // expected-error {{call to method 'bar' in closure requires explicit use of 'self' to make capture semantics explicit}} expected-note {{reference 'self.' explicitly}}
1452
+
withNonEscapingAutoclosure(bar()) // expected-warning {{call to method 'bar' in closure requires explicit use of 'self' to make capture semantics explicit}} expected-note {{reference 'self.' explicitly}}
1445
1453
}
1446
1454
1447
1455
doVoidStuff{[self]in
@@ -1457,7 +1465,7 @@ final class AutoclosureTests {
1457
1465
}
1458
1466
1459
1467
doVoidStuff{
1460
-
withEscapingAutoclosure(bar()) // expected-error {{call to method 'bar' in closure requires explicit use of 'self' to make capture semantics explicit}} expected-note {{reference 'self.' explicitly}}
1468
+
withEscapingAutoclosure(bar()) // expected-warning {{call to method 'bar' in closure requires explicit use of 'self' to make capture semantics explicit}} expected-note {{reference 'self.' explicitly}}
1461
1469
}
1462
1470
1463
1471
doVoidStuffNonEscaping{
@@ -1607,6 +1615,20 @@ class TestInvalidRebindingOutsideOfClosure {
1607
1615
guardlet self else{return}
1608
1616
method() // expected-warning{{call to method 'method' in closure requires explicit use of 'self' to make capture semantics explicit; this is an error in the Swift 6 language mode}}
1609
1617
}
1618
+
1619
+
doVoidStuff{[weak self]in
1620
+
guardlet self =selfelse{return}
1621
+
doVoidStuff{[self]in
1622
+
method() // expected-error {{call to method 'method' in closure requires explicit use of 'self' to make capture semantics explicit}}
1623
+
}
1624
+
}
1625
+
1626
+
doVoidStuffNonEscaping{[weak self]in
1627
+
guardlet self =selfelse{return}
1628
+
doVoidStuffNonEscaping{[self]in
1629
+
method() // expected-warning {{call to method 'method' in closure requires explicit use of 'self' to make capture semantics explicit; this is an error in the Swift 6 language mode}}
Copy file name to clipboardExpand all lines: test/expr/closure/closures_swift6.swift
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -368,7 +368,7 @@ class TestGithubIssue70089 {
368
368
x +=1 // expected-error {{reference to property 'x' in closure requires explicit use of 'self' to make capture semantics explicit}} expected-note {{reference 'self.' explicitly}}
369
369
}
370
370
371
-
doVoidStuff{[self=TestGithubIssue70089()] in // expected-note{{variable other than 'self' captured here under the name 'self' does not enable implicit 'self'}} expected-note{{variable other than 'self' captured here under the name 'self' does not enable implicit 'self'}} expected-note{{variable other than 'self' captured here under the name 'self' does not enable implicit 'self'}}
371
+
doVoidStuff{[self=TestGithubIssue70089()] in // expected-note{{variable other than 'self' captured here under the name 'self' does not enable implicit 'self'}} expected-note{{variable other than 'self' captured here under the name 'self' does not enable implicit 'self'}} expected-note{{variable other than 'self' captured here under the name 'self' does not enable implicit 'self'}}
372
372
x +=1 // expected-error{{reference to property 'x' in closure requires explicit use of 'self' to make capture semantics explicit}}
373
373
self.x +=1
374
374
@@ -477,7 +477,7 @@ class TestGithubIssue69911 {
477
477
}
478
478
}
479
479
480
-
doVoidStuffNonEscaping{[self=TestGithubIssue69911()] in // expected-note {{variable other than 'self' captured here under the name 'self' does not enable implicit 'self'}} expected-note{{variable other than 'self' captured here under the name 'self' does not enable implicit 'self'}} expected-note{{variable other than 'self' captured here under the name 'self' does not enable implicit 'self'}}
480
+
doVoidStuffNonEscaping{[self=TestGithubIssue69911()] in // expected-note {{variable other than 'self' captured here under the name 'self' does not enable implicit 'self'}} expected-note{{variable other than 'self' captured here under the name 'self' does not enable implicit 'self'}} expected-note{{variable other than 'self' captured here under the name 'self' does not enable implicit 'self'}}
481
481
x +=1 // expected-error{{reference to property 'x' in closure requires explicit use of 'self' to make capture semantics explicit}}
0 commit comments