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
+43-9Lines changed: 43 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -1234,7 +1234,7 @@ class TestGithubIssue70089 {
1234
1234
self.x +=1
1235
1235
1236
1236
doVoidStuff{
1237
-
x +=1 // expected-error {{reference to property 'x' in closure requires explicit use of 'self' to make capture semantics explicit}}
1237
+
x +=1 // expected-warning {{reference to property 'x' in closure requires explicit use of 'self' to make capture semantics explicit}}
1238
1238
self.x +=1
1239
1239
}
1240
1240
@@ -1300,7 +1300,7 @@ class TestGithubIssue70089 {
1300
1300
}
1301
1301
1302
1302
doVoidStuffNonEscaping{
1303
-
x +=1 // expected-error {{reference to property 'x' in closure requires explicit use of 'self' to make capture semantics explicit}}
1303
+
x +=1 // expected-warning {{reference to property 'x' in closure requires explicit use of 'self' to make capture semantics explicit}}
1304
1304
self.x +=1
1305
1305
}
1306
1306
}
@@ -1311,6 +1311,24 @@ class TestGithubIssue70089 {
1311
1311
self.x +=1
1312
1312
}
1313
1313
}
1314
+
1315
+
doVoidStuff{[self]in
1316
+
doVoidStuff{ // expected-note {{capture 'self' explicitly to enable implicit 'self' in this closure}}
1317
+
doVoidStuff{
1318
+
x +=1 // expected-warning {{reference to property 'x' in closure requires explicit use of 'self' to make capture semantics explicit}} expected-note {{reference 'self.' explicitly}}
1319
+
self.x +=1
1320
+
}
1321
+
}
1322
+
}
1323
+
1324
+
doVoidStuffNonEscaping{[self]in
1325
+
doVoidStuffNonEscaping{
1326
+
doVoidStuffNonEscaping{
1327
+
x +=1
1328
+
self.x +=1
1329
+
}
1330
+
}
1331
+
}
1314
1332
}
1315
1333
}
1316
1334
@@ -1357,7 +1375,7 @@ class TestGithubIssue69911 {
1357
1375
}
1358
1376
1359
1377
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'}}
1360
-
x +=1 // expected-error{{reference to property 'x' in closure requires explicit use of 'self' to make capture semantics explicit}}
1378
+
x +=1 // expected-warning {{reference to property 'x' in closure requires explicit use of 'self' to make capture semantics explicit}}
1361
1379
self.x +=1
1362
1380
1363
1381
doVoidStuff{[self]in
@@ -1366,7 +1384,7 @@ class TestGithubIssue69911 {
1366
1384
}
1367
1385
1368
1386
doVoidStuffNonEscaping{
1369
-
x +=1 // expected-error{{reference to property 'x' in closure requires explicit use of 'self' to make capture semantics explicit}}
1387
+
x +=1 // expected-warning{{reference to property 'x' in closure requires explicit use of 'self' to make capture semantics explicit}}
1370
1388
self.x +=1
1371
1389
}
1372
1390
}
@@ -1382,33 +1400,33 @@ class TestGithubIssue69911 {
x +=1 // expected-error{{reference to property 'x' in closure requires explicit use of 'self' to make capture semantics explicit}}
1403
+
x +=1 // expected-warning{{reference to property 'x' in closure requires explicit use of 'self' to make capture semantics explicit}}
1386
1404
self.x +=1
1387
1405
}
1388
1406
1389
1407
doVoidStuffNonEscaping{
1390
1408
doVoidStuffNonEscaping{
1391
-
x +=1 // expected-error{{reference to property 'x' in closure requires explicit use of 'self' to make capture semantics explicit}}
1409
+
x +=1 // expected-warning{{reference to property 'x' in closure requires explicit use of 'self' to make capture semantics explicit}}
1392
1410
self.x +=1
1393
1411
}
1394
1412
}
1395
1413
1396
1414
doVoidStuff{[self]in
1397
1415
doVoidStuffNonEscaping{
1398
-
x +=1 // expected-error{{reference to property 'x' in closure requires explicit use of 'self' to make capture semantics explicit}}
1416
+
x +=1 // expected-warning{{reference to property 'x' in closure requires explicit use of 'self' to make capture semantics explicit}}
1399
1417
self.x +=1
1400
1418
}
1401
1419
}
1402
1420
1403
1421
doVoidStuffNonEscaping{[self]in
1404
1422
doVoidStuffNonEscaping{[self]in
1405
-
x +=1 // expected-error{{reference to property 'x' in closure requires explicit use of 'self' to make capture semantics explicit}}
1423
+
x +=1 // expected-warning{{reference to property 'x' in closure requires explicit use of 'self' to make capture semantics explicit}}
1406
1424
self.x +=1
1407
1425
}
1408
1426
}
1409
1427
1410
1428
doVoidStuffNonEscaping{[self=TestGithubIssue69911()] in // expected-note {{variable other than 'self' captured here under the name 'self' does not enable implicit 'self'}}
1411
-
x +=1 // expected-error{{reference to property 'x' in closure requires explicit use of 'self' to make capture semantics explicit}}
1429
+
x +=1 // expected-warning{{reference to property 'x' in closure requires explicit use of 'self' to make capture semantics explicit}}
1412
1430
self.x +=1
1413
1431
}
1414
1432
@@ -1417,6 +1435,13 @@ class TestGithubIssue69911 {
1417
1435
self?.x +=1
1418
1436
}
1419
1437
1438
+
doVoidStuffNonEscaping{[self=TestGithubIssue69911()] in // expected-note {{variable other than 'self' captured here under the name 'self' does not enable implicit 'self'}}
1439
+
doVoidStuffNonEscaping{[self]in
1440
+
x +=1 // expected-warning {{reference to property 'x' in closure requires explicit use of 'self' to make capture semantics explicit}}
0 commit comments