File: attr_objc.swift

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (2692 lines) | stat: -rw-r--r-- 125,897 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
// RUN: %empty-directory(%t)
// RUN: %{python} %S/Inputs/access-note-gen.py %s %t/attr_objc_access_note.swift %t/attr_objc_access_note.accessnotes

// Test with @objc attrs, without access notes
// RUN: %target-swift-frontend -disable-objc-attr-requires-foundation-module -typecheck -verify -verify-ignore-unknown %s -swift-version 4 -enable-source-import -I %S/Inputs
// RUN: %target-swift-ide-test -skip-deinit=false -print-ast-typechecked -source-filename %s -function-definitions=true -prefer-type-repr=false -print-implicit-attrs=true -explode-pattern-binding-decls=true -disable-objc-attr-requires-foundation-module -swift-version 4 -enable-source-import -I %S/Inputs | %FileCheck %s
// RUN: not %target-swift-frontend -typecheck -dump-ast -disable-objc-attr-requires-foundation-module %s -swift-version 4 -enable-source-import -I %S/Inputs > %t/attr_objc.ast
// RUN: %FileCheck -check-prefix CHECK-DUMP %s < %t/attr_objc.ast

// Test without @objc attrs, with access notes
// RUN: %target-swift-frontend -disable-objc-attr-requires-foundation-module -typecheck -verify -verify-ignore-unknown %t/attr_objc_access_note.swift -access-notes-path %t/attr_objc_access_note.accessnotes -swift-version 4 -enable-source-import -I %S/Inputs
// RUN: %target-swift-ide-test -skip-deinit=false -print-ast-typechecked -source-filename %t/attr_objc_access_note.swift -access-notes-path %t/attr_objc_access_note.accessnotes -function-definitions=true -prefer-type-repr=false -print-implicit-attrs=true -explode-pattern-binding-decls=true -disable-objc-attr-requires-foundation-module -swift-version 4 -enable-source-import -I %S/Inputs | %FileCheck %t/attr_objc_access_note.swift
// RUN: not %target-swift-frontend -typecheck -dump-ast -disable-objc-attr-requires-foundation-module %t/attr_objc_access_note.swift -access-notes-path %t/attr_objc_access_note.accessnotes -swift-version 4 -enable-source-import -I %S/Inputs > %t/attr_objc_access_note.ast
// RUN: %FileCheck -check-prefix CHECK-DUMP %t/attr_objc_access_note.swift < %t/attr_objc_access_note.ast

// Test with both @objc attrs and access notes
// RUN: %target-swift-frontend -disable-objc-attr-requires-foundation-module -typecheck -verify -verify-ignore-unknown %s -access-notes-path %t/attr_objc_access_note.accessnotes -swift-version 4 -enable-source-import -I %S/Inputs
// RUN: %target-swift-ide-test -skip-deinit=false -print-ast-typechecked -source-filename %s -access-notes-path %t/attr_objc_access_note.accessnotes -function-definitions=true -prefer-type-repr=false -print-implicit-attrs=true -explode-pattern-binding-decls=true -disable-objc-attr-requires-foundation-module -swift-version 4 -enable-source-import -I %S/Inputs | %FileCheck %s
// RUN: not %target-swift-frontend -typecheck -dump-ast -disable-objc-attr-requires-foundation-module %s -access-notes-path %t/attr_objc_access_note.accessnotes -swift-version 4 -enable-source-import -I %S/Inputs > %t/attr_objc_2.ast
// RUN: %FileCheck -check-prefix CHECK-DUMP %s < %t/attr_objc_2.ast

// REQUIRES: objc_interop

// HOW TO WORK ON THIS TEST
//
// This file is primarily used to test '@objc' in source files, but it is also
// processed to produce test files for access notes, which can annotate
// declarations with '@objc' based on a sidecar file. This processing produces
// a source file with most of the '@objc' annotations removed, plus an access
// note file which adds back the removed '@objc' annotations. The three files
// are then tested in various combinations.
//
// The processing step uses the following special commands, which must appear
// at the beginning of a line comment to be recognized:
//
// * `access-note-adjust @±offset` (where the offset is optional) modifies the
//   rest of the line comment to:
//
//   1. Change expected errors to expected remarks
//   2. Adjust the line offsets of all expected diagnostics by the offset
//   3. Change the phrase "marked @objc" to "marked @objc by an access note"
//   4. Change all expected fix-its to "{{none}}"
//
// * `access-note-move @±offset {{name}}` (where the offset is optional) can
//   only appear immediately after an `@objc` or `@objc(someName)` attribute.
//   It removes the attribute from the source code, adds a corresponding
//   access note for `name` to the access note file, and does the same
//   processing to the rest of the line as access-note-adjust. Note that in this
//   case, the offset is @+1, not @+0, unless something else is specified.
//
// Note that, in some cases, we need additional access notes to be added that
// don't directly correspond to any attribute in the source code (usually
// because one @objc attribute covers several declarations). When this happens,
// we write a commented-out @objc attribute and use the `access-note-move`
// command.


import Foundation

class PlainClass {}
struct PlainStruct {}
enum PlainEnum {}
protocol PlainProtocol {} // expected-note {{protocol 'PlainProtocol' declared here}}

enum ErrorEnum : Error {
  case failed
}

@objc // access-note-move{{Class_ObjC1}}
class Class_ObjC1 {}

protocol Protocol_Class1 : class {} // expected-note {{protocol 'Protocol_Class1' declared here}}

protocol Protocol_Class2 : class {}

@objc // access-note-move{{Protocol_ObjC1}}
protocol Protocol_ObjC1 {}

@objc // access-note-move{{Protocol_ObjC2}}
protocol Protocol_ObjC2 {}




//===--- Subjects of @objc attribute.

@objc // expected-error{{'@objc' can only be applied to an extension of a class}}{{1-7=}}
extension PlainStruct { }

class FáncyName {}

@objc(FancyName)
extension FáncyName {}

@objc // bad-access-note-move{{subject_globalVar}} expected-error {{@objc can only be used with members of classes, @objc protocols, and concrete extensions of classes}}
var subject_globalVar: Int

var subject_getterSetter: Int {
  @objc // bad-access-note-move{{getter:subject_getterSetter()}} expected-error {{@objc can only be used with members of classes, @objc protocols, and concrete extensions of classes}} {{3-9=}}
  get {
    return 0
  }
  @objc // bad-access-note-move{{setter:subject_getterSetter()}} expected-error {{@objc can only be used with members of classes, @objc protocols, and concrete extensions of classes}} {{3-9=}}
  set {
  }
}

var subject_global_observingAccessorsVar1: Int = 0 {
  @objc // expected-error {{@objc can only be used with members of classes, @objc protocols, and concrete extensions of classes}} {{3-9=}}
  willSet {
  }
  @objc // expected-error {{@objc can only be used with members of classes, @objc protocols, and concrete extensions of classes}} {{3-9=}}
  didSet {
  }
}

class subject_getterSetter1 {
  var instanceVar1: Int {
    @objc // bad-access-note-move{{getter:subject_getterSetter1.instanceVar1()}} expected-error {{'@objc' getter for non-'@objc' property}} {{5-11=}}
    get {
      return 0
    }
  }

  var instanceVar2: Int {
    get {
      return 0
    }
    @objc // bad-access-note-move{{setter:subject_getterSetter1.instanceVar2()}} expected-error {{'@objc' setter for non-'@objc' property}} {{5-11=}}
    set {
    }
  }

  var instanceVar3: Int {
    @objc // bad-access-note-move{{getter:subject_getterSetter1.instanceVar3()}} expected-error {{'@objc' getter for non-'@objc' property}} {{5-11=}}
    get {
      return 0
    }
    @objc // bad-access-note-move{{setter:subject_getterSetter1.instanceVar3()}} expected-error {{'@objc' setter for non-'@objc' property}} {{5-11=}}
    set {
    }
  }

  var observingAccessorsVar1: Int = 0 {
    @objc // expected-error {{observing accessors are not allowed to be marked @objc}} {{5-11=}}
    willSet {
    }
    @objc // expected-error {{observing accessors are not allowed to be marked @objc}} {{5-11=}}
    didSet {
    }
  }
}

class subject_staticVar1 {
  @objc // access-note-move{{subject_staticVar1.staticVar1}}
  class var staticVar1: Int = 42 // expected-error {{class stored properties not supported}}

  @objc // access-note-move{{subject_staticVar1.staticVar2}}
  class var staticVar2: Int { return 42 }
}

@objc // bad-access-note-move{{subject_freeFunc()}} expected-error {{@objc can only be used with members of classes, @objc protocols, and concrete extensions of classes}} {{1-7=}}
func subject_freeFunc() {
  @objc // expected-error {{@objc can only be used with members of classes, @objc protocols, and concrete extensions of classes}} {{3-9=}}
  var subject_localVar: Int
  // expected-warning@-1 {{variable 'subject_localVar' was never used; consider replacing with '_' or removing it}}

  @objc // expected-error {{@objc can only be used with members of classes, @objc protocols, and concrete extensions of classes}} {{3-9=}}
  func subject_nestedFreeFunc() {
  }
}

@objc // bad-access-note-move{{subject_genericFunc(t:)}} expected-error {{@objc can only be used with members of classes, @objc protocols, and concrete extensions of classes}} {{1-7=}}
func subject_genericFunc<T>(t: T) {
  @objc // expected-error {{@objc can only be used with members of classes, @objc protocols, and concrete extensions of classes}} {{3-9=}}
  var subject_localVar: Int
  // expected-warning@-1 {{variable 'subject_localVar' was never used; consider replacing with '_' or removing it}}

  @objc // expected-error {{@objc can only be used with members of classes, @objc protocols, and concrete extensions of classes}} {{3-9=}}
  func subject_instanceFunc() {}
}

func subject_funcParam(a: @objc Int) { // expected-error {{attribute can only be applied to declarations, not types}} {{1-1=@objc }} {{27-33=}}
}

@objc // bad-access-note-move{{subject_struct}} expected-error {{'@objc' attribute cannot be applied to this declaration}} {{1-7=}}
struct subject_struct {
  @objc // bad-access-note-move{{subject_struct.subject_instanceVar}} expected-error {{@objc can only be used with members of classes, @objc protocols, and concrete extensions of classes}} {{3-9=}}
  var subject_instanceVar: Int

  @objc // bad-access-note-move{{subject_struct.init()}} expected-error {{@objc can only be used with members of classes, @objc protocols, and concrete extensions of classes}} {{3-9=}}
  init() {}

  @objc // bad-access-note-move{{subject_struct.subject_instanceFunc()}} expected-error {{@objc can only be used with members of classes, @objc protocols, and concrete extensions of classes}} {{3-9=}}
  func subject_instanceFunc() {}
}

@objc // bad-access-note-move{{subject_genericStruct}} expected-error {{'@objc' attribute cannot be applied to this declaration}} {{1-7=}}
struct subject_genericStruct<T> {
  @objc // bad-access-note-move{{subject_genericStruct.subject_instanceVar}} expected-error {{@objc can only be used with members of classes, @objc protocols, and concrete extensions of classes}} {{3-9=}}
  var subject_instanceVar: Int

  @objc // bad-access-note-move{{subject_genericStruct.init()}} expected-error {{@objc can only be used with members of classes, @objc protocols, and concrete extensions of classes}} {{3-9=}}
  init() {}

  @objc // bad-access-note-move{{subject_genericStruct.subject_instanceFunc()}} expected-error {{@objc can only be used with members of classes, @objc protocols, and concrete extensions of classes}} {{3-9=}}
  func subject_instanceFunc() {}
}

@objc // access-note-move{{subject_class1}}
class subject_class1 { // no-error
  @objc // access-note-move{{subject_class1.subject_instanceVar}}
  var subject_instanceVar: Int // no-error

  @objc // access-note-move{{subject_class1.init()}}
  init() {} // no-error

  @objc // access-note-move{{subject_class1.subject_instanceFunc()}}
  func subject_instanceFunc() {} // no-error
  
  
}

@objc // access-note-move{{subject_class2}}
class subject_class2 : Protocol_Class1, PlainProtocol { // no-error
}

@objc // bad-access-note-move{{subject_genericClass}} expected-error{{generic subclasses of '@objc' classes cannot have an explicit '@objc' because they are not directly visible from Objective-C}} {{1-7=}}
class subject_genericClass<T> {
  @objc // access-note-move{{subject_genericClass.subject_instanceVar}}
  var subject_instanceVar: Int // no-error

  @objc // access-note-move{{subject_genericClass.init()}}
  init() {} // no-error

  @objc // access-note-move{{subject_genericClass.subject_instanceFunc()}}
  func subject_instanceFunc() {} // no_error
}

@objc // bad-access-note-move{{subject_genericClass2}} expected-error{{generic subclasses of '@objc' classes cannot have an explicit '@objc' because they are not directly visible from Objective-C}} {{1-7=}}
class subject_genericClass2<T> : Class_ObjC1 {
  @objc // access-note-move{{subject_genericClass2.subject_instanceVar}}
  var subject_instanceVar: Int // no-error

  @objc // access-note-move{{subject_genericClass2.init(foo:)}}
  init(foo: Int) {} // no-error

  @objc // access-note-move{{subject_genericClass2.subject_instanceFunc()}}
  func subject_instanceFunc() {} // no_error
}

extension subject_genericClass where T : Hashable {
  @objc // bad-access-note-move{{subject_genericClass.prop}}
  var prop: Int { return 0 } // access-note-adjust{{@objc}} expected-error{{members of constrained extensions cannot be declared @objc}}
}

extension subject_genericClass {
  @objc // bad-access-note-move{{subject_genericClass.extProp}}
  var extProp: Int { return 0 } // access-note-adjust{{@objc}} expected-error{{extensions of generic classes cannot contain '@objc' members}}
  
  @objc // bad-access-note-move{{subject_genericClass.extFoo()}}
  func extFoo() {} // access-note-adjust{{@objc}} expected-error{{extensions of generic classes cannot contain '@objc' members}}
}

@objc // access-note-move{{subject_enum}}
enum subject_enum: Int {
  @objc // bad-access-note-move{{subject_enum.subject_enumElement1}} expected-error {{attribute has no effect; cases within an '@objc' enum are already exposed to Objective-C}} {{3-9=}}
  case subject_enumElement1

  @objc(subject_enumElement2) // access-note-move{{subject_enum.subject_enumElement2}}
  case subject_enumElement2

  // Fake for access notes: @objc(subject_enumElement3) // bad-access-note-move@+2{{subject_enum.subject_enumElement4}}
  @objc(subject_enumElement3) // bad-access-note-move{{subject_enum.subject_enumElement3}} expected-error {{'@objc' enum case declaration defines multiple enum cases with the same Objective-C name}}{{3-31=}}
  case subject_enumElement3, subject_enumElement4
  // Because of the fake access-note-move above, we expect to see extra diagnostics when we run this test with both explicit @objc attributes *and* access notes:
  // expected-remark@-2 * {{'@objc' enum case declaration defines multiple enum cases with the same Objective-C name}} expected-note@-2 *{{attribute 'objc' was added by access note for fancy tests}}

  // Fake for access notes: @objc // bad-access-note-move@+2{{subject_enum.subject_enumElement6}}
  @objc // bad-access-note-move{{subject_enum.subject_enumElement5}} expected-error {{attribute has no effect; cases within an '@objc' enum are already exposed to Objective-C}} {{3-9=}}
  case subject_enumElement5, subject_enumElement6
  // Because of the fake access-note-move above, we expect to see extra diagnostics when we run this test with both explicit @objc attributes *and* access notes:
  // expected-remark@-2 * {{attribute has no effect; cases within an '@objc' enum are already exposed to Objective-C}} expected-note@-2 *{{attribute 'objc' was added by access note for fancy tests}}

  @nonobjc // expected-error {{'@nonobjc' attribute cannot be applied to this declaration}}
  case subject_enumElement7

  @objc // bad-access-note-move{{subject_enum.init()}} expected-error {{@objc can only be used with members of classes, @objc protocols, and concrete extensions of classes}} {{3-9=}}
  init() {}

  @objc // bad-access-note-move{{subject_enum.subject_instanceFunc()}} expected-error {{@objc can only be used with members of classes, @objc protocols, and concrete extensions of classes}} {{3-9=}}
  func subject_instanceFunc() {}
}

enum subject_enum2 {
  @objc(subject_enum2Element1) // bad-access-note-move{{subject_enum2.subject_enumElement1}} expected-error{{'@objc' enum case is not allowed outside of an '@objc' enum}}{{3-32=}}
  case subject_enumElement1
}

@objc // access-note-move{{subject_protocol1}}
protocol subject_protocol1 {
  @objc // access-note-move{{subject_protocol1.subject_instanceVar}}
  var subject_instanceVar: Int { get }

  @objc // access-note-move{{subject_protocol1.subject_instanceFunc()}}
  func subject_instanceFunc()
}

@objc // access-note-move{{subject_protocol2}} // no-error
protocol subject_protocol2 {}
// CHECK-LABEL: @objc protocol subject_protocol2 {

@objc // access-note-move{{subject_protocol3}} // no-error
protocol subject_protocol3 {}
// CHECK-LABEL: @objc protocol subject_protocol3 {

@objc // access-note-move{{subject_protocol4}}
protocol subject_protocol4 : PlainProtocol {} // expected-error {{@objc protocol 'subject_protocol4' cannot refine non-@objc protocol 'PlainProtocol'}}

@objc // access-note-move{{subject_protocol5}}
protocol subject_protocol5 : Protocol_Class1 {} // expected-error {{@objc protocol 'subject_protocol5' cannot refine non-@objc protocol 'Protocol_Class1'}}

@objc // access-note-move{{subject_protocol6}}
protocol subject_protocol6 : Protocol_ObjC1 {}

protocol subject_containerProtocol1 {
  @objc // bad-access-note-move{{subject_containerProtocol1.subject_instanceVar}} expected-error {{@objc can only be used with members of classes, @objc protocols, and concrete extensions of classes}}
  var subject_instanceVar: Int { get }

  @objc // bad-access-note-move{{subject_containerProtocol1.subject_instanceFunc()}} expected-error {{@objc can only be used with members of classes, @objc protocols, and concrete extensions of classes}}
  func subject_instanceFunc()

  @objc // bad-access-note-move{{subject_containerProtocol1.subject_staticFunc()}} expected-error {{@objc can only be used with members of classes, @objc protocols, and concrete extensions of classes}}
  static func subject_staticFunc()
}

@objc // access-note-move{{subject_containerObjCProtocol1}}
protocol subject_containerObjCProtocol1 {
  func func_FunctionReturn1() -> PlainStruct
  // expected-error@-1 {{method cannot be a member of an @objc protocol because its result type cannot be represented in Objective-C}}
  // expected-note@-2 {{Swift structs cannot be represented in Objective-C}}
  // expected-note@-3 {{inferring '@objc' because the declaration is a member of an '@objc' protocol}}

  func func_FunctionParam1(a: PlainStruct)
  // expected-error@-1 {{method cannot be a member of an @objc protocol because the type of the parameter cannot be represented in Objective-C}}
  // expected-note@-2 {{Swift structs cannot be represented in Objective-C}}
  // expected-note@-3 {{inferring '@objc' because the declaration is a member of an '@objc' protocol}}

  func func_Variadic(_: AnyObject...)
  // expected-error @-1{{method cannot be a member of an @objc protocol because it has a variadic parameter}}
  // expected-note @-2{{inferring '@objc' because the declaration is a member of an '@objc' protocol}}

  subscript(a: PlainStruct) -> Int { get }
  // expected-error@-1 {{subscript cannot be a member of an @objc protocol because its type cannot be represented in Objective-C}}
  // expected-note@-2 {{Swift structs cannot be represented in Objective-C}}
  // expected-note@-3 {{inferring '@objc' because the declaration is a member of an '@objc' protocol}}

  var varNonObjC1: PlainStruct { get }
  // expected-error@-1 {{property cannot be a member of an @objc protocol because its type cannot be represented in Objective-C}}
  // expected-note@-2 {{Swift structs cannot be represented in Objective-C}}
  // expected-note@-3 {{inferring '@objc' because the declaration is a member of an '@objc' protocol}}
}

@objc // access-note-move{{subject_containerObjCProtocol2}}
protocol subject_containerObjCProtocol2 {
  init(a: Int)
  // expected-note@-1 {{'init(a:)' previously declared here}}

  @objc // FIXME: Access notes can't distinguish between init(a:) overloads
  init(a: Double)
  // expected-warning@-1 {{initializer 'init(a:)' with Objective-C selector 'initWithA:' conflicts with previous declaration with the same Objective-C selector; this is an error in the Swift 6 language mode}}

  func func1() -> Int
  @objc // access-note-move{{subject_containerObjCProtocol2.func1_()}}
  func func1_() -> Int

  var instanceVar1: Int { get set }
  @objc // access-note-move{{subject_containerObjCProtocol2.instanceVar1_}}
  var instanceVar1_: Int { get set }

  subscript(i: Int) -> Int { get set }

  @objc // FIXME: Access notes can't distinguish between subscript(_:) overloads
  subscript(i: String) -> Int { get set}
}

protocol nonObjCProtocol {
  @objc // bad-access-note-move{{nonObjCProtocol.objcRequirement()}} expected-error{{@objc can only be used with members of classes, @objc protocols, and concrete extensions of classes}}
  func objcRequirement()
}

func concreteContext1() {
  @objc
  class subject_inConcreteContext {}
}

class ConcreteContext2 {
  @objc // access-note-move{{ConcreteContext2.subject_inConcreteContext}}
  class subject_inConcreteContext {}
}

class ConcreteContext3 {

  func dynamicSelf1() -> Self { return self }

  @objc // access-note-move{{ConcreteContext3.dynamicSelf1_()}}
  func dynamicSelf1_() -> Self { return self }

  @objc // bad-access-note-move{{ConcreteContext3.genericParams()}}
  func genericParams<T: NSObject>() -> [T] { return [] } // access-note-adjust{{@objc}} expected-error{{instance method cannot be marked @objc because it has generic parameters}}

  @objc // bad-access-note-move{{ConcreteContext3.returnObjCProtocolMetatype()}}
  func returnObjCProtocolMetatype() -> NSCoding.Protocol { return NSCoding.self } // access-note-adjust{{@objc}} expected-error{{method cannot be marked @objc because its result type cannot be represented in Objective-C}}

  typealias AnotherNSCoding = NSCoding
  typealias MetaNSCoding1 = NSCoding.Protocol
  typealias MetaNSCoding2 = AnotherNSCoding.Protocol

  @objc // bad-access-note-move{{ConcreteContext3.returnObjCAliasProtocolMetatype1()}}
  func returnObjCAliasProtocolMetatype1() -> AnotherNSCoding.Protocol { return NSCoding.self } // access-note-adjust{{@objc}} expected-error{{method cannot be marked @objc because its result type cannot be represented in Objective-C}}

  @objc // bad-access-note-move{{ConcreteContext3.returnObjCAliasProtocolMetatype2()}}
  func returnObjCAliasProtocolMetatype2() -> MetaNSCoding1 { return NSCoding.self } // access-note-adjust{{@objc}} expected-error{{method cannot be marked @objc because its result type cannot be represented in Objective-C}}

  @objc // bad-access-note-move{{ConcreteContext3.returnObjCAliasProtocolMetatype3()}}
  func returnObjCAliasProtocolMetatype3() -> MetaNSCoding2 { return NSCoding.self } // access-note-adjust{{@objc}} expected-error{{method cannot be marked @objc because its result type cannot be represented in Objective-C}}

  typealias Composition = NSCopying & NSCoding

  @objc // bad-access-note-move{{ConcreteContext3.returnCompositionMetatype1()}}
  func returnCompositionMetatype1() -> Composition.Protocol { return Composition.self } // access-note-adjust{{@objc}} expected-error{{method cannot be marked @objc because its result type cannot be represented in Objective-C}}

  @objc // bad-access-note-move{{ConcreteContext3.returnCompositionMetatype2()}}
  func returnCompositionMetatype2() -> (NSCopying & NSCoding).Protocol { return (NSCopying & NSCoding).self } // access-note-adjust{{@objc}} expected-error{{method cannot be marked @objc because its result type cannot be represented in Objective-C}}

  typealias NSCodingExistential = NSCoding.Type

  @objc // bad-access-note-move{{ConcreteContext3.inoutFunc(a:)}}
  func inoutFunc(a: inout Int) {} // access-note-adjust{{@objc}} expected-error{{method cannot be marked @objc because inout parameters cannot be represented in Objective-C}}

  @objc // bad-access-note-move{{ConcreteContext3.metatypeOfExistentialMetatypePram1(a:)}}
  func metatypeOfExistentialMetatypePram1(a: NSCodingExistential.Protocol) {} // access-note-adjust{{@objc}} expected-error{{method cannot be marked @objc because the type of the parameter cannot be represented in Objective-C}}

  @objc // bad-access-note-move{{ConcreteContext3.metatypeOfExistentialMetatypePram2(a:)}}
  func metatypeOfExistentialMetatypePram2(a: NSCoding.Type.Protocol) {} // access-note-adjust{{@objc}} expected-error{{method cannot be marked @objc because the type of the parameter cannot be represented in Objective-C}}
}

func genericContext1<T>(_: T) {
  @objc // expected-error {{generic subclasses of '@objc' classes cannot have an explicit '@objc' because they are not directly visible from Objective-C}} {{3-9=}}
  class subject_inGenericContext {} // expected-error {{type 'subject_inGenericContext' cannot be nested in generic function 'genericContext1'}}

  @objc // expected-error {{generic subclasses of '@objc' classes cannot have an explicit '@objc'}} {{3-9=}}
  class subject_inGenericContext2 : Class_ObjC1 {} // expected-error {{type 'subject_inGenericContext2' cannot be nested in generic function 'genericContext1'}}

  class subject_constructor_inGenericContext { // expected-error {{type 'subject_constructor_inGenericContext' cannot be nested in generic function 'genericContext1'}}
    @objc
    init() {} // no-error
  }

  class subject_var_inGenericContext { // expected-error {{type 'subject_var_inGenericContext' cannot be nested in generic function 'genericContext1'}}
    @objc
    var subject_instanceVar: Int = 0 // no-error
  }

  class subject_func_inGenericContext { // expected-error {{type 'subject_func_inGenericContext' cannot be nested in generic function 'genericContext1'}}
    @objc
    func f() {} // no-error
  }
}

class GenericContext2<T> {
  @objc // bad-access-note-move{{GenericContext2.subject_inGenericContext}} expected-error{{generic subclasses of '@objc' classes cannot have an explicit '@objc' because they are not directly visible from Objective-C}} {{3-9=}}
  class subject_inGenericContext {}

  @objc // bad-access-note-move{{GenericContext2.subject_inGenericContext2}} expected-error{{generic subclasses of '@objc' classes cannot have an explicit '@objc' because they are not directly visible from Objective-C}} {{3-9=}}
  class subject_inGenericContext2 : Class_ObjC1 {}

  @objc // access-note-move{{GenericContext2.f()}}
  func f() {} // no-error
}

class GenericContext3<T> {
  class MoreNested {
    @objc // bad-access-note-move{{GenericContext3.MoreNested.subject_inGenericContext}} expected-error{{generic subclasses of '@objc' classes cannot have an explicit '@objc' because they are not directly visible from Objective-C}} {{5-11=}}
    class subject_inGenericContext {}

    @objc // bad-access-note-move{{GenericContext3.MoreNested.subject_inGenericContext2}} expected-error{{generic subclasses of '@objc' classes cannot have an explicit '@objc' because they are not directly visible from Objective-C}} {{5-11=}}
    class subject_inGenericContext2 : Class_ObjC1 {}

    @objc // access-note-move{{GenericContext3.MoreNested.f()}}
    func f() {} // no-error
  }
}

class GenericContext4<T> {
  @objc // bad-access-note-move{{GenericContext4.foo()}}
  func foo() where T: Hashable { } // access-note-adjust{{@objc}} expected-error {{instance method cannot be marked @objc because it has a 'where' clause}}
}

@objc // bad-access-note-move{{ConcreteSubclassOfGeneric}} expected-error{{generic subclasses of '@objc' classes cannot have an explicit '@objc' because they are not directly visible from Objective-C}} {{1-7=}}
class ConcreteSubclassOfGeneric : GenericContext3<Int> {}

extension ConcreteSubclassOfGeneric {
  @objc // access-note-move{{ConcreteSubclassOfGeneric.foo()}}
  func foo() {} // okay
}

@objc // bad-access-note-move{{ConcreteSubclassOfGeneric2}} expected-error{{generic subclasses of '@objc' classes cannot have an explicit '@objc' because they are not directly visible from Objective-C}} {{1-7=}}
class ConcreteSubclassOfGeneric2 : subject_genericClass2<Int> {}

extension ConcreteSubclassOfGeneric2 {
  @objc // access-note-move{{ConcreteSubclassOfGeneric2.foo()}}
  func foo() {} // okay
}

@objc(CustomNameForSubclassOfGeneric) // access-note-move{{ConcreteSubclassOfGeneric3}} no-error
class ConcreteSubclassOfGeneric3 : GenericContext3<Int> {}

extension ConcreteSubclassOfGeneric3 {
  @objc // access-note-move{{ConcreteSubclassOfGeneric3.foo()}}
  func foo() {} // okay
}

class subject_subscriptIndexed1 {
  @objc // access-note-move{{subject_subscriptIndexed1.subscript(_:)}}
  subscript(a: Int) -> Int { // no-error
    get { return 0 }
  }
}
class subject_subscriptIndexed2 {
  @objc // access-note-move{{subject_subscriptIndexed2.subscript(_:)}}
  subscript(a: Int8) -> Int { // no-error
    get { return 0 }
  }
}
class subject_subscriptIndexed3 {
  @objc // access-note-move{{subject_subscriptIndexed3.subscript(_:)}}
  subscript(a: UInt8) -> Int { // no-error
    get { return 0 }
  }
}

class subject_subscriptKeyed1 {
  @objc // access-note-move{{subject_subscriptKeyed1.subscript(_:)}}
  subscript(a: String) -> Int { // no-error
    get { return 0 }
  }
}
class subject_subscriptKeyed2 {
  @objc // access-note-move{{subject_subscriptKeyed2.subscript(_:)}}
  subscript(a: Class_ObjC1) -> Int { // no-error
    get { return 0 }
  }
}
class subject_subscriptKeyed3 {
  @objc // access-note-move{{subject_subscriptKeyed3.subscript(_:)}}
  subscript(a: Class_ObjC1.Type) -> Int { // no-error
    get { return 0 }
  }
}
class subject_subscriptKeyed4 {
  @objc // access-note-move{{subject_subscriptKeyed4.subscript(_:)}}
  subscript(a: Protocol_ObjC1) -> Int { // no-error
    get { return 0 }
  }
}
class subject_subscriptKeyed5 {
  @objc // access-note-move{{subject_subscriptKeyed5.subscript(_:)}}
  subscript(a: Protocol_ObjC1.Type) -> Int { // no-error
    get { return 0 }
  }
}
class subject_subscriptKeyed6 {
  @objc // access-note-move{{subject_subscriptKeyed6.subscript(_:)}}
  subscript(a: Protocol_ObjC1 & Protocol_ObjC2) -> Int { // no-error
    get { return 0 }
  }
}
class subject_subscriptKeyed7 {
  @objc // access-note-move{{subject_subscriptKeyed7.subscript(_:)}}
  subscript(a: (Protocol_ObjC1 & Protocol_ObjC2).Type) -> Int { // no-error
    get { return 0 }
  }
}

class subject_subscriptBridgedFloat {
  @objc // access-note-move{{subject_subscriptBridgedFloat.subscript(_:)}}
  subscript(a: Float32) -> Int {
    get { return 0 }
  }
}

class subject_subscriptGeneric<T> {
  @objc // access-note-move{{subject_subscriptGeneric.subscript(_:)}}
  subscript(a: Int) -> Int { // no-error
    get { return 0 }
  }
}

class subject_subscriptInvalid1 {
  @objc // bad-access-note-move{{subject_subscriptInvalid1.subscript(_:)}}
  class subscript(_ i: Int) -> AnyObject? { // access-note-adjust{{@objc}} expected-error {{class subscript cannot be marked @objc}}
    return nil
  }
}

class subject_subscriptInvalid2 {
  @objc // bad-access-note-move{{subject_subscriptInvalid2.subscript(_:)}}
  subscript(a: PlainClass) -> Int {
  // access-note-adjust{{@objc}} expected-error@-1 {{subscript cannot be marked @objc because its type cannot be represented in Objective-C}}
  // expected-note@-2 {{classes not annotated with @objc cannot be represented in Objective-C}}
    get { return 0 }
  }
}
class subject_subscriptInvalid3 {
  @objc // bad-access-note-move{{subject_subscriptInvalid3.subscript(_:)}}
  subscript(a: PlainClass.Type) -> Int { // access-note-adjust{{@objc}} expected-error {{subscript cannot be marked @objc because its type cannot be represented in Objective-C}}
    get { return 0 }
  }
}
class subject_subscriptInvalid4 {
  @objc // bad-access-note-move{{subject_subscriptInvalid4.subscript(_:)}}
  subscript(a: PlainStruct) -> Int { // access-note-adjust{{@objc}} expected-error {{subscript cannot be marked @objc because its type cannot be represented in Objective-C}}
    // expected-note@-1{{Swift structs cannot be represented in Objective-C}}
    get { return 0 }
  }
}
class subject_subscriptInvalid5 {
  @objc // bad-access-note-move{{subject_subscriptInvalid5.subscript(_:)}}
  subscript(a: PlainEnum) -> Int { // access-note-adjust{{@objc}} expected-error {{subscript cannot be marked @objc because its type cannot be represented in Objective-C}}
    // expected-note@-1{{enums cannot be represented in Objective-C}}
    get { return 0 }
  }
}
class subject_subscriptInvalid6 {
  @objc // bad-access-note-move{{subject_subscriptInvalid6.subscript(_:)}}
  subscript(a: PlainProtocol) -> Int { // access-note-adjust{{@objc}} expected-error {{subscript cannot be marked @objc because its type cannot be represented in Objective-C}}
    // expected-note@-1{{protocol-constrained type containing protocol 'PlainProtocol' cannot be represented in Objective-C}}
    get { return 0 }
  }
}
class subject_subscriptInvalid7 {
  @objc // bad-access-note-move{{subject_subscriptInvalid7.subscript(_:)}}
  subscript(a: Protocol_Class1) -> Int { // access-note-adjust{{@objc}} expected-error {{subscript cannot be marked @objc because its type cannot be represented in Objective-C}}
    // expected-note@-1{{protocol-constrained type containing protocol 'Protocol_Class1' cannot be represented in Objective-C}}
    get { return 0 }
  }
}
class subject_subscriptInvalid8 {
  @objc // bad-access-note-move{{subject_subscriptInvalid8.subscript(_:)}}
  subscript(a: Protocol_Class1 & Protocol_Class2) -> Int { // access-note-adjust{{@objc}} expected-error {{subscript cannot be marked @objc because its type cannot be represented in Objective-C}}
    // expected-note@-1{{protocol-constrained type containing protocol 'Protocol_Class1' cannot be represented in Objective-C}}
    get { return 0 }
  }
}

class subject_propertyInvalid1 {
  @objc // bad-access-note-move{{subject_propertyInvalid1.plainStruct}}
  let plainStruct = PlainStruct() // access-note-adjust{{@objc}} expected-error {{property cannot be marked @objc because its type cannot be represented in Objective-C}}
  // expected-note@-1{{Swift structs cannot be represented in Objective-C}}
}

//===--- Tests for @objc inference.

@objc // access-note-move{{infer_instanceFunc1}}
class infer_instanceFunc1 {
// CHECK-LABEL: @objc class infer_instanceFunc1 {

  func func1() {}
// CHECK-LABEL: {{^}} func func1() {

  @objc // access-note-move{{infer_instanceFunc1.func1_()}}
  func func1_() {} // no-error

  func func2(a: Int) {}
// CHECK-LABEL: {{^}} func func2(a: Int) {

  @objc // access-note-move{{infer_instanceFunc1.func2_(a:)}}
  func func2_(a: Int) {} // no-error

  func func3(a: Int) -> Int {}
// CHECK-LABEL: {{^}} func func3(a: Int) -> Int {

  @objc // access-note-move{{infer_instanceFunc1.func3_(a:)}}
  func func3_(a: Int) -> Int {} // no-error

  func func4(a: Int, b: Double) {}
// CHECK-LABEL: {{^}} func func4(a: Int, b: Double) {

  @objc // access-note-move{{infer_instanceFunc1.func4_(a:b:)}}
  func func4_(a: Int, b: Double) {} // no-error

  func func5(a: String) {}
// CHECK-LABEL: {{^}} func func5(a: String) {

  @objc // access-note-move{{infer_instanceFunc1.func5_(a:)}}
  func func5_(a: String) {} // no-error

  func func6() -> String {}
// CHECK-LABEL: {{^}} func func6() -> String {

  @objc // access-note-move{{infer_instanceFunc1.func6_()}}
  func func6_() -> String {} // no-error

  func func7(a: PlainClass) {}
// CHECK-LABEL: {{^}} func func7(a: PlainClass) {

  @objc // bad-access-note-move{{infer_instanceFunc1.func7_(a:)}}
  func func7_(a: PlainClass) {}
  // access-note-adjust{{@objc}} expected-error@-1 {{method cannot be marked @objc because the type of the parameter cannot be represented in Objective-C}}
  // expected-note@-2 {{classes not annotated with @objc cannot be represented in Objective-C}}

  func func7m(a: PlainClass.Type) {}
// CHECK-LABEL: {{^}} func func7m(a: PlainClass.Type) {

  @objc // bad-access-note-move{{infer_instanceFunc1.func7m_(a:)}}
  func func7m_(a: PlainClass.Type) {}
  // access-note-adjust{{@objc}} expected-error@-1 {{method cannot be marked @objc because the type of the parameter cannot be represented in Objective-C}}

  func func8() -> PlainClass {}
// CHECK-LABEL: {{^}} func func8() -> PlainClass {

  @objc // bad-access-note-move{{infer_instanceFunc1.func8_()}}
  func func8_() -> PlainClass {}
  // access-note-adjust{{@objc}} expected-error@-1 {{method cannot be marked @objc because its result type cannot be represented in Objective-C}}
  // expected-note@-2 {{classes not annotated with @objc cannot be represented in Objective-C}}

  func func8m() -> PlainClass.Type {}
// CHECK-LABEL: {{^}} func func8m() -> PlainClass.Type {

  @objc // bad-access-note-move{{infer_instanceFunc1.func8m_()}}
  func func8m_() -> PlainClass.Type {}
  // access-note-adjust{{@objc}} expected-error@-1 {{method cannot be marked @objc because its result type cannot be represented in Objective-C}}

  func func9(a: PlainStruct) {}
// CHECK-LABEL: {{^}} func func9(a: PlainStruct) {

  @objc // bad-access-note-move{{infer_instanceFunc1.func9_(a:)}}
  func func9_(a: PlainStruct) {}
  // access-note-adjust{{@objc}} expected-error@-1 {{method cannot be marked @objc because the type of the parameter cannot be represented in Objective-C}}
  // expected-note@-2 {{Swift structs cannot be represented in Objective-C}}

  func func10() -> PlainStruct {}
// CHECK-LABEL: {{^}} func func10() -> PlainStruct {

  @objc // bad-access-note-move{{infer_instanceFunc1.func10_()}}
  func func10_() -> PlainStruct {}
  // access-note-adjust{{@objc}} expected-error@-1 {{method cannot be marked @objc because its result type cannot be represented in Objective-C}}
  // expected-note@-2 {{Swift structs cannot be represented in Objective-C}}

  func func11(a: PlainEnum) {}
// CHECK-LABEL: {{^}} func func11(a: PlainEnum) {

  @objc // bad-access-note-move{{infer_instanceFunc1.func11_(a:)}}
  func func11_(a: PlainEnum) {}
  // access-note-adjust{{@objc}} expected-error@-1 {{method cannot be marked @objc because the type of the parameter cannot be represented in Objective-C}}
  // expected-note@-2 {{non-'@objc' enums cannot be represented in Objective-C}}

  func func12(a: PlainProtocol) {}
// CHECK-LABEL: {{^}} func func12(a: any PlainProtocol) {

  @objc // bad-access-note-move{{infer_instanceFunc1.func12_(a:)}}
  func func12_(a: PlainProtocol) {}
  // access-note-adjust{{@objc}} expected-error@-1 {{method cannot be marked @objc because the type of the parameter cannot be represented in Objective-C}}
  // expected-note@-2 {{protocol-constrained type containing protocol 'PlainProtocol' cannot be represented in Objective-C}}

  func func13(a: Class_ObjC1) {}
// CHECK-LABEL: {{^}} func func13(a: Class_ObjC1) {

  @objc // access-note-move{{infer_instanceFunc1.func13_(a:)}}
  func func13_(a: Class_ObjC1) {} // no-error

  func func14(a: Protocol_Class1) {}
// CHECK-LABEL: {{^}} func func14(a: any Protocol_Class1) {

  @objc // bad-access-note-move{{infer_instanceFunc1.func14_(a:)}}
  func func14_(a: Protocol_Class1) {}
  // access-note-adjust{{@objc}} expected-error@-1 {{method cannot be marked @objc because the type of the parameter cannot be represented in Objective-C}}
  // expected-note@-2 {{protocol-constrained type containing protocol 'Protocol_Class1' cannot be represented in Objective-C}}

  func func15(a: Protocol_ObjC1) {}
// CHECK-LABEL: {{^}} func func15(a: any Protocol_ObjC1) {
  @objc // access-note-move{{infer_instanceFunc1.func15_(a:)}}
  func func15_(a: Protocol_ObjC1) {} // no-error

  func func16(a: AnyObject) {}
// CHECK-LABEL: {{^}} func func16(a: AnyObject) {

  @objc // access-note-move{{infer_instanceFunc1.func16_(a:)}}
  func func16_(a: AnyObject) {} // no-error

  func func17(a: @escaping () -> ()) {}
// CHECK-LABEL: {{^}} func func17(a: @escaping () -> ()) {

  @objc // access-note-move{{infer_instanceFunc1.func17_(a:)}}
  func func17_(a: @escaping () -> ()) {}

  func func18(a: @escaping (Int) -> (), b: Int) {}
// CHECK-LABEL: {{^}} func func18(a: @escaping (Int) -> (), b: Int)

  @objc // access-note-move{{infer_instanceFunc1.func18_(a:b:)}}
  func func18_(a: @escaping (Int) -> (), b: Int) {}

  func func19(a: @escaping (String) -> (), b: Int) {}
// CHECK-LABEL: {{^}} func func19(a: @escaping (String) -> (), b: Int) {

  @objc // access-note-move{{infer_instanceFunc1.func19_(a:b:)}}
  func func19_(a: @escaping (String) -> (), b: Int) {}

  func func_FunctionReturn1() -> () -> () {}
// CHECK-LABEL: {{^}} func func_FunctionReturn1() -> () -> () {

  @objc // access-note-move{{infer_instanceFunc1.func_FunctionReturn1_()}}
  func func_FunctionReturn1_() -> () -> () {}

  func func_FunctionReturn2() -> (Int) -> () {}
// CHECK-LABEL: {{^}} func func_FunctionReturn2() -> (Int) -> () {

  @objc // access-note-move{{infer_instanceFunc1.func_FunctionReturn2_()}}
  func func_FunctionReturn2_() -> (Int) -> () {}

  func func_FunctionReturn3() -> () -> Int {}
// CHECK-LABEL: {{^}} func func_FunctionReturn3() -> () -> Int {

  @objc // access-note-move{{infer_instanceFunc1.func_FunctionReturn3_()}}
  func func_FunctionReturn3_() -> () -> Int {}

  func func_FunctionReturn4() -> (String) -> () {}
// CHECK-LABEL: {{^}} func func_FunctionReturn4() -> (String) -> () {

  @objc // access-note-move{{infer_instanceFunc1.func_FunctionReturn4_()}}
  func func_FunctionReturn4_() -> (String) -> () {}

  func func_FunctionReturn5() -> () -> String {}
// CHECK-LABEL: {{^}} func func_FunctionReturn5() -> () -> String {

  @objc // access-note-move{{infer_instanceFunc1.func_FunctionReturn5_()}}
  func func_FunctionReturn5_() -> () -> String {}


  func func_ZeroParams1() {}
// CHECK-LABEL: {{^}} func func_ZeroParams1() {

  @objc // access-note-move{{infer_instanceFunc1.func_ZeroParams1a()}}
  func func_ZeroParams1a() {} // no-error


  func func_OneParam1(a: Int) {}
// CHECK-LABEL: {{^}} func func_OneParam1(a: Int) {

  @objc // access-note-move{{infer_instanceFunc1.func_OneParam1a(a:)}}
  func func_OneParam1a(a: Int) {} // no-error


  func func_TupleStyle1(a: Int, b: Int) {}
  // CHECK-LABEL: {{^}} func func_TupleStyle1(a: Int, b: Int) {

  @objc // access-note-move{{infer_instanceFunc1.func_TupleStyle1a(a:b:)}}
  func func_TupleStyle1a(a: Int, b: Int) {}

  func func_TupleStyle2(a: Int, b: Int, c: Int) {}
// CHECK-LABEL: {{^}} func func_TupleStyle2(a: Int, b: Int, c: Int) {

  @objc // access-note-move{{infer_instanceFunc1.func_TupleStyle2a(a:b:c:)}}
  func func_TupleStyle2a(a: Int, b: Int, c: Int) {}

  // Check that we produce diagnostics for every parameter and return type.
  @objc // bad-access-note-move{{infer_instanceFunc1.func_MultipleDiags(a:b:)}}
  func func_MultipleDiags(a: PlainStruct, b: PlainEnum) -> Any {}
  // access-note-adjust{{@objc}} expected-error@-1 {{method cannot be marked @objc because the type of the parameter 1 cannot be represented in Objective-C}}
  // expected-note@-2 {{Swift structs cannot be represented in Objective-C}}
  // access-note-adjust{{@objc}} expected-error@-3 {{method cannot be marked @objc because the type of the parameter 2 cannot be represented in Objective-C}}
  // expected-note@-4 {{non-'@objc' enums cannot be represented in Objective-C}}
  // Produces an extra: expected-note@-5 * {{attribute 'objc' was added by access note for fancy tests}}

  @objc // access-note-move{{infer_instanceFunc1.func_UnnamedParam1(_:)}}
  func func_UnnamedParam1(_: Int) {} // no-error

  @objc // bad-access-note-move{{infer_instanceFunc1.func_UnnamedParam2(_:)}}
  func func_UnnamedParam2(_: PlainStruct) {}
  // access-note-adjust{{@objc}} expected-error@-1 {{method cannot be marked @objc because the type of the parameter cannot be represented in Objective-C}}
  // expected-note@-2 {{Swift structs cannot be represented in Objective-C}}

  @objc // access-note-move{{infer_instanceFunc1.func_varParam1(a:)}}
  func func_varParam1(a: AnyObject) {
    var a = a
    let b = a; a = b
  }

  func func_varParam2(a: AnyObject) {
    var a = a
    let b = a; a = b
  }
// CHECK-LABEL: {{^}} func func_varParam2(a: AnyObject) {
}

@objc // access-note-move{{infer_constructor1}}
class infer_constructor1 {
// CHECK-LABEL: @objc class infer_constructor1

  init() {}
  // CHECK: {{^}} init()

  init(a: Int) {}
  // CHECK: {{^}} init(a: Int)

  init(a: PlainStruct) {}
  // CHECK: {{^}} init(a: PlainStruct)

  init(malice: ()) {}
  // CHECK: {{^}} init(malice: ())

  init(forMurder _: ()) {}
  // CHECK: {{^}} init(forMurder _: ())
}

@objc // access-note-move{{infer_destructor1}}
class infer_destructor1 {
// CHECK-LABEL: @objc class infer_destructor1

  deinit {}
  // CHECK: @objc deinit
}

// @!objc
class infer_destructor2 {
// CHECK-LABEL: {{^}}class infer_destructor2

  deinit {}
  // CHECK: @objc deinit
}

@objc // access-note-move{{infer_instanceVar1}}
class infer_instanceVar1 {
// CHECK-LABEL: @objc class infer_instanceVar1 {
  init() {}

  var instanceVar1: Int
  // CHECK: {{^}} var instanceVar1: Int

  var (instanceVar2, instanceVar3): (Int, PlainProtocol)
  // CHECK: {{^}}  var instanceVar2: Int
  // CHECK: {{^}}  var instanceVar3: any PlainProtocol

  @objc // bad-access-note-move{{infer_instanceVar1.instanceVar1_}}
  var (instanceVar1_, instanceVar2_): (Int, PlainProtocol)
  // access-note-adjust{{@objc}} expected-error@-1 {{property cannot be marked @objc because its type cannot be represented in Objective-C}}
  // expected-note@-2 {{protocol-constrained type containing protocol 'PlainProtocol' cannot be represented in Objective-C}}
  // Fake for access notes: @objc // access-note-move@-3{{infer_instanceVar1.instanceVar2_}}

  var instanceVar4: Int {
  // CHECK: {{^}} var instanceVar4: Int {
    get {}
    // CHECK-NEXT: {{^}} get {}
  }

  var instanceVar5: Int {
  // CHECK: {{^}} var instanceVar5: Int {
    get {}
    // CHECK-NEXT: {{^}} get {}
    set {}
    // CHECK-NEXT: {{^}} set {}
  }

  @objc // access-note-move{{infer_instanceVar1.instanceVar5_}}
  var instanceVar5_: Int {
  // CHECK: @objc var instanceVar5_: Int {
    get {}
    // CHECK-NEXT: @objc get {}
    set {}
    // CHECK-NEXT: @objc set {}
  }

  var observingAccessorsVar1: Int {
  // CHECK: {{^}} @_hasStorage var observingAccessorsVar1: Int {
    willSet {}
    // CHECK-NEXT: {{^}} get {
    // CHECK-NEXT:    return
    // CHECK-NEXT: }
    didSet {}
    // CHECK-NEXT: {{^}} set {
  }

  @objc // access-note-move{{infer_instanceVar1.observingAccessorsVar1_}}
  var observingAccessorsVar1_: Int {
  // CHECK: {{^}} {{@_hasStorage @objc|@objc @_hasStorage}} var observingAccessorsVar1_: Int {
    willSet {}
    // CHECK-NEXT: {{^}} @objc get {
    // CHECK-NEXT:   return
    // CHECK-NEXT: }
    didSet {}
    // CHECK-NEXT: {{^}} @objc set {
  }


  var var_Int: Int
// CHECK-LABEL: {{^}} var var_Int: Int

  var var_Bool: Bool
// CHECK-LABEL: {{^}} var var_Bool: Bool

  var var_CBool: CBool
// CHECK-LABEL: {{^}} var var_CBool: CBool

  var var_String: String
// CHECK-LABEL: {{^}} var var_String: String

  var var_Float: Float
  var var_Double: Double
// CHECK-LABEL: {{^}} var var_Float: Float
// CHECK-LABEL: {{^}} var var_Double: Double

  var var_Char: Unicode.Scalar
// CHECK-LABEL: {{^}} var var_Char: Unicode.Scalar

  //===--- Tuples.

  var var_tuple1: ()
// CHECK-LABEL: {{^}} @_hasInitialValue var var_tuple1: ()

  @objc // bad-access-note-move{{infer_instanceVar1.var_tuple1_}}
  var var_tuple1_: ()
  // access-note-adjust{{@objc}} expected-error@-1 {{property cannot be marked @objc because its type cannot be represented in Objective-C}}
  // expected-note@-2 {{empty tuple type cannot be represented in Objective-C}}

  var var_tuple2: Void
// CHECK-LABEL: {{^}} @_hasInitialValue var var_tuple2: Void

  @objc // bad-access-note-move{{infer_instanceVar1.var_tuple2_}}
  var var_tuple2_: Void
  // access-note-adjust{{@objc}} expected-error@-1 {{property cannot be marked @objc because its type cannot be represented in Objective-C}}
  // expected-note@-2 {{empty tuple type cannot be represented in Objective-C}}

  var var_tuple3: (Int)
// CHECK-LABEL: {{^}} var var_tuple3: (Int)

  @objc // access-note-move{{infer_instanceVar1.var_tuple3_}}
  var var_tuple3_: (Int) // no-error

  var var_tuple4: (Int, Int)
// CHECK-LABEL: {{^}} var var_tuple4: (Int, Int)

  @objc // bad-access-note-move{{infer_instanceVar1.var_tuple4_}}
  var var_tuple4_: (Int, Int)
  // access-note-adjust{{@objc}} expected-error@-1 {{property cannot be marked @objc because its type cannot be represented in Objective-C}}
  // expected-note@-2 {{tuples cannot be represented in Objective-C}}

  //===--- Stdlib integer types.

  var var_Int8: Int8
  var var_Int16: Int16
  var var_Int32: Int32
  var var_Int64: Int64
// CHECK-LABEL: {{^}} var var_Int8: Int8
// CHECK-LABEL: {{^}} var var_Int16: Int16
// CHECK-LABEL: {{^}} var var_Int32: Int32
// CHECK-LABEL: {{^}} var var_Int64: Int64

  var var_UInt8: UInt8
  var var_UInt16: UInt16
  var var_UInt32: UInt32
  var var_UInt64: UInt64
// CHECK-LABEL: {{^}} var var_UInt8: UInt8
// CHECK-LABEL: {{^}} var var_UInt16: UInt16
// CHECK-LABEL: {{^}} var var_UInt32: UInt32
// CHECK-LABEL: {{^}} var var_UInt64: UInt64

  var var_OpaquePointer: OpaquePointer
// CHECK-LABEL: {{^}} var var_OpaquePointer: OpaquePointer

  var var_PlainClass: PlainClass
// CHECK-LABEL: {{^}}  var var_PlainClass: PlainClass

  @objc // bad-access-note-move{{infer_instanceVar1.var_PlainClass_}}
  var var_PlainClass_: PlainClass
  // access-note-adjust{{@objc}} expected-error@-1 {{property cannot be marked @objc because its type cannot be represented in Objective-C}}
  // expected-note@-2 {{classes not annotated with @objc cannot be represented in Objective-C}}

  var var_PlainStruct: PlainStruct
// CHECK-LABEL: {{^}}  var var_PlainStruct: PlainStruct

  @objc // bad-access-note-move{{infer_instanceVar1.var_PlainStruct_}}
  var var_PlainStruct_: PlainStruct
  // access-note-adjust{{@objc}} expected-error@-1 {{property cannot be marked @objc because its type cannot be represented in Objective-C}}
  // expected-note@-2 {{Swift structs cannot be represented in Objective-C}}

  var var_PlainEnum: PlainEnum
// CHECK-LABEL: {{^}} var var_PlainEnum: PlainEnum

  @objc // bad-access-note-move{{infer_instanceVar1.var_PlainEnum_}}
  var var_PlainEnum_: PlainEnum
  // access-note-adjust{{@objc}} expected-error@-1 {{property cannot be marked @objc because its type cannot be represented in Objective-C}}
  // expected-note@-2 {{non-'@objc' enums cannot be represented in Objective-C}}

  var var_PlainProtocol: PlainProtocol
// CHECK-LABEL: {{^}}  var var_PlainProtocol: any PlainProtocol

  @objc // bad-access-note-move{{infer_instanceVar1.var_PlainProtocol_}}
  var var_PlainProtocol_: PlainProtocol
  // access-note-adjust{{@objc}} expected-error@-1 {{property cannot be marked @objc because its type cannot be represented in Objective-C}}
  // expected-note@-2 {{protocol-constrained type containing protocol 'PlainProtocol' cannot be represented in Objective-C}}

  var var_ClassObjC: Class_ObjC1
// CHECK-LABEL: {{^}} var var_ClassObjC: Class_ObjC1

  @objc // access-note-move{{infer_instanceVar1.var_ClassObjC_}}
  var var_ClassObjC_: Class_ObjC1 // no-error

  var var_ProtocolClass: Protocol_Class1
// CHECK-LABEL: {{^}}  var var_ProtocolClass: any Protocol_Class1

  @objc // bad-access-note-move{{infer_instanceVar1.var_ProtocolClass_}}
  var var_ProtocolClass_: Protocol_Class1
  // access-note-adjust{{@objc}} expected-error@-1 {{property cannot be marked @objc because its type cannot be represented in Objective-C}}
  // expected-note@-2 {{protocol-constrained type containing protocol 'Protocol_Class1' cannot be represented in Objective-C}}

  var var_ProtocolObjC: Protocol_ObjC1
// CHECK-LABEL: {{^}}  var var_ProtocolObjC: any Protocol_ObjC1

  @objc // access-note-move{{infer_instanceVar1.var_ProtocolObjC_}}
  var var_ProtocolObjC_: Protocol_ObjC1 // no-error


  var var_PlainClassMetatype: PlainClass.Type
// CHECK-LABEL: {{^}}  var var_PlainClassMetatype: PlainClass.Type

  @objc // bad-access-note-move{{infer_instanceVar1.var_PlainClassMetatype_}}
  var var_PlainClassMetatype_: PlainClass.Type
  // access-note-adjust{{@objc}} expected-error@-1 {{property cannot be marked @objc because its type cannot be represented in Objective-C}}

  var var_PlainStructMetatype: PlainStruct.Type
// CHECK-LABEL: {{^}}  var var_PlainStructMetatype: PlainStruct.Type

  @objc // bad-access-note-move{{infer_instanceVar1.var_PlainStructMetatype_}}
  var var_PlainStructMetatype_: PlainStruct.Type
  // access-note-adjust{{@objc}} expected-error@-1 {{property cannot be marked @objc because its type cannot be represented in Objective-C}}

  var var_PlainEnumMetatype: PlainEnum.Type
// CHECK-LABEL: {{^}}  var var_PlainEnumMetatype: PlainEnum.Type

  @objc // bad-access-note-move{{infer_instanceVar1.var_PlainEnumMetatype_}}
  var var_PlainEnumMetatype_: PlainEnum.Type
  // access-note-adjust{{@objc}} expected-error@-1 {{property cannot be marked @objc because its type cannot be represented in Objective-C}}

  var var_PlainExistentialMetatype: PlainProtocol.Type
// CHECK-LABEL: {{^}}  var var_PlainExistentialMetatype: any PlainProtocol.Type

  @objc // bad-access-note-move{{infer_instanceVar1.var_PlainExistentialMetatype_}}
  var var_PlainExistentialMetatype_: PlainProtocol.Type
  // access-note-adjust{{@objc}} expected-error@-1 {{property cannot be marked @objc because its type cannot be represented in Objective-C}}

  var var_ClassObjCMetatype: Class_ObjC1.Type
// CHECK-LABEL: {{^}}  var var_ClassObjCMetatype: Class_ObjC1.Type

  @objc // access-note-move{{infer_instanceVar1.var_ClassObjCMetatype_}}
  var var_ClassObjCMetatype_: Class_ObjC1.Type // no-error

  var var_ProtocolClassMetatype: Protocol_Class1.Type
// CHECK-LABEL: {{^}}  var var_ProtocolClassMetatype: any Protocol_Class1.Type

  @objc // bad-access-note-move{{infer_instanceVar1.var_ProtocolClassMetatype_}}
  var var_ProtocolClassMetatype_: Protocol_Class1.Type
  // access-note-adjust{{@objc}} expected-error@-1 {{property cannot be marked @objc because its type cannot be represented in Objective-C}}

  var var_ProtocolObjCMetatype1: Protocol_ObjC1.Type
// CHECK-LABEL: {{^}}  var var_ProtocolObjCMetatype1: any Protocol_ObjC1.Type

  @objc // access-note-move{{infer_instanceVar1.var_ProtocolObjCMetatype1_}}
  var var_ProtocolObjCMetatype1_: Protocol_ObjC1.Type // no-error

  var var_ProtocolObjCMetatype2: Protocol_ObjC2.Type
// CHECK-LABEL: {{^}}  var var_ProtocolObjCMetatype2: any Protocol_ObjC2.Type

  @objc // access-note-move{{infer_instanceVar1.var_ProtocolObjCMetatype2_}}
  var var_ProtocolObjCMetatype2_: Protocol_ObjC2.Type // no-error

  var var_AnyObject1: AnyObject
  var var_AnyObject2: AnyObject.Type
// CHECK-LABEL: {{^}}  var var_AnyObject1: AnyObject
// CHECK-LABEL: {{^}}  var var_AnyObject2: any AnyObject.Type

  var var_Existential0: Any
// CHECK-LABEL: {{^}}  var var_Existential0: Any

  @objc // access-note-move{{infer_instanceVar1.var_Existential0_}}
  var var_Existential0_: Any

  var var_Existential1: PlainProtocol
  // CHECK-LABEL: {{^}}  var var_Existential1: any PlainProtocol

  @objc // bad-access-note-move{{infer_instanceVar1.var_Existential1_}}
  var var_Existential1_: PlainProtocol
  // access-note-adjust{{@objc}} expected-error@-1 {{property cannot be marked @objc because its type cannot be represented in Objective-C}}
  // expected-note@-2 {{protocol-constrained type containing protocol 'PlainProtocol' cannot be represented in Objective-C}}

  var var_Existential2: PlainProtocol & PlainProtocol
// CHECK-LABEL: {{^}}  var var_Existential2: any PlainProtocol

  @objc // bad-access-note-move{{infer_instanceVar1.var_Existential2_}}
  var var_Existential2_: PlainProtocol & PlainProtocol
  // access-note-adjust{{@objc}} expected-error@-1 {{property cannot be marked @objc because its type cannot be represented in Objective-C}}
  // expected-note@-2 {{protocol-constrained type containing protocol 'PlainProtocol' cannot be represented in Objective-C}}

  var var_Existential3: PlainProtocol & Protocol_Class1
// CHECK-LABEL: {{^}}  var var_Existential3: any PlainProtocol & Protocol_Class1

  @objc // bad-access-note-move{{infer_instanceVar1.var_Existential3_}}
  var var_Existential3_: PlainProtocol & Protocol_Class1
  // access-note-adjust{{@objc}} expected-error@-1 {{property cannot be marked @objc because its type cannot be represented in Objective-C}}
  // expected-note@-2 {{protocol-constrained type containing protocol 'PlainProtocol' cannot be represented in Objective-C}}

  var var_Existential4: PlainProtocol & Protocol_ObjC1
// CHECK-LABEL: {{^}}  var var_Existential4: any PlainProtocol & Protocol_ObjC1

  @objc // bad-access-note-move{{infer_instanceVar1.var_Existential4_}}
  var var_Existential4_: PlainProtocol & Protocol_ObjC1
  // access-note-adjust{{@objc}} expected-error@-1 {{property cannot be marked @objc because its type cannot be represented in Objective-C}}
  // expected-note@-2 {{protocol-constrained type containing protocol 'PlainProtocol' cannot be represented in Objective-C}}

  var var_Existential5: Protocol_Class1
  // CHECK-LABEL: {{^}}  var var_Existential5: any Protocol_Class1

  @objc // bad-access-note-move{{infer_instanceVar1.var_Existential5_}}
  var var_Existential5_: Protocol_Class1
  // access-note-adjust{{@objc}} expected-error@-1 {{property cannot be marked @objc because its type cannot be represented in Objective-C}}
  // expected-note@-2 {{protocol-constrained type containing protocol 'Protocol_Class1' cannot be represented in Objective-C}}

  var var_Existential6: Protocol_Class1 & Protocol_Class2
// CHECK-LABEL: {{^}}  var var_Existential6: any Protocol_Class1 & Protocol_Class2

  @objc // bad-access-note-move{{infer_instanceVar1.var_Existential6_}}
  var var_Existential6_: Protocol_Class1 & Protocol_Class2
  // access-note-adjust{{@objc}} expected-error@-1 {{property cannot be marked @objc because its type cannot be represented in Objective-C}}
  // expected-note@-2 {{protocol-constrained type containing protocol 'Protocol_Class1' cannot be represented in Objective-C}}

  var var_Existential7: Protocol_Class1 & Protocol_ObjC1
// CHECK-LABEL: {{^}}  var var_Existential7: any Protocol_Class1 & Protocol_ObjC1

  @objc // bad-access-note-move{{infer_instanceVar1.var_Existential7_}}
  var var_Existential7_: Protocol_Class1 & Protocol_ObjC1
  // access-note-adjust{{@objc}} expected-error@-1 {{property cannot be marked @objc because its type cannot be represented in Objective-C}}
  // expected-note@-2 {{protocol-constrained type containing protocol 'Protocol_Class1' cannot be represented in Objective-C}}

  var var_Existential8: Protocol_ObjC1
// CHECK-LABEL: {{^}}  var var_Existential8: any Protocol_ObjC1

  @objc // access-note-move{{infer_instanceVar1.var_Existential8_}}
  var var_Existential8_: Protocol_ObjC1 // no-error

  var var_Existential9: Protocol_ObjC1 & Protocol_ObjC2
// CHECK-LABEL: {{^}}  var var_Existential9: any Protocol_ObjC1 & Protocol_ObjC2

  @objc // access-note-move{{infer_instanceVar1.var_Existential9_}}
  var var_Existential9_: Protocol_ObjC1 & Protocol_ObjC2 // no-error


  var var_ExistentialMetatype0: Any.Type
  var var_ExistentialMetatype1: PlainProtocol.Type
  var var_ExistentialMetatype2: (PlainProtocol & PlainProtocol).Type
  var var_ExistentialMetatype3: (PlainProtocol & Protocol_Class1).Type
  var var_ExistentialMetatype4: (PlainProtocol & Protocol_ObjC1).Type
  var var_ExistentialMetatype5: (Protocol_Class1).Type
  var var_ExistentialMetatype6: (Protocol_Class1 & Protocol_Class2).Type
  var var_ExistentialMetatype7: (Protocol_Class1 & Protocol_ObjC1).Type
  var var_ExistentialMetatype8: Protocol_ObjC1.Type
  var var_ExistentialMetatype9: (Protocol_ObjC1 & Protocol_ObjC2).Type
// CHECK-LABEL: {{^}}  var var_ExistentialMetatype0: any Any.Type
// CHECK-LABEL: {{^}}  var var_ExistentialMetatype1: any PlainProtocol.Type
// CHECK-LABEL: {{^}}  var var_ExistentialMetatype2: any (PlainProtocol).Type
// CHECK-LABEL: {{^}}  var var_ExistentialMetatype3: any (PlainProtocol & Protocol_Class1).Type
// CHECK-LABEL: {{^}}  var var_ExistentialMetatype4: any (PlainProtocol & Protocol_ObjC1).Type
// CHECK-LABEL: {{^}}  var var_ExistentialMetatype5: any (Protocol_Class1).Type
// CHECK-LABEL: {{^}}  var var_ExistentialMetatype6: any (Protocol_Class1 & Protocol_Class2).Type
// CHECK-LABEL: {{^}}  var var_ExistentialMetatype7: any (Protocol_Class1 & Protocol_ObjC1).Type
// CHECK-LABEL: {{^}}  var var_ExistentialMetatype8: any Protocol_ObjC1.Type
// CHECK-LABEL: {{^}}  var var_ExistentialMetatype9: any (Protocol_ObjC1 & Protocol_ObjC2).Type


  var var_UnsafeMutablePointer1: UnsafeMutablePointer<Int>
  var var_UnsafeMutablePointer2: UnsafeMutablePointer<Bool>
  var var_UnsafeMutablePointer3: UnsafeMutablePointer<CBool>
  var var_UnsafeMutablePointer4: UnsafeMutablePointer<String>
  var var_UnsafeMutablePointer5: UnsafeMutablePointer<Float>
  var var_UnsafeMutablePointer6: UnsafeMutablePointer<Double>
  var var_UnsafeMutablePointer7: UnsafeMutablePointer<OpaquePointer>
  var var_UnsafeMutablePointer8: UnsafeMutablePointer<PlainClass>
  var var_UnsafeMutablePointer9: UnsafeMutablePointer<PlainStruct>
  var var_UnsafeMutablePointer10: UnsafeMutablePointer<PlainEnum>
  var var_UnsafeMutablePointer11: UnsafeMutablePointer<PlainProtocol>
  var var_UnsafeMutablePointer12: UnsafeMutablePointer<AnyObject>
  var var_UnsafeMutablePointer13: UnsafeMutablePointer<AnyObject.Type>
  var var_UnsafeMutablePointer100: UnsafeMutableRawPointer
  var var_UnsafeMutablePointer101: UnsafeMutableRawPointer
  var var_UnsafeMutablePointer102: UnsafeMutablePointer<(Int, Int)>
// CHECK-LABEL: {{^}}  var var_UnsafeMutablePointer1: UnsafeMutablePointer<Int>
// CHECK-LABEL: {{^}}  var var_UnsafeMutablePointer2: UnsafeMutablePointer<Bool>
// CHECK-LABEL: {{^}}  var var_UnsafeMutablePointer3: UnsafeMutablePointer<CBool>
// CHECK-LABEL: {{^}}  var var_UnsafeMutablePointer4: UnsafeMutablePointer<String>
// CHECK-LABEL: {{^}}  var var_UnsafeMutablePointer5: UnsafeMutablePointer<Float>
// CHECK-LABEL: {{^}}  var var_UnsafeMutablePointer6: UnsafeMutablePointer<Double>
// CHECK-LABEL: {{^}}  var var_UnsafeMutablePointer7: UnsafeMutablePointer<OpaquePointer>
// CHECK-LABEL: {{^}}  var var_UnsafeMutablePointer8: UnsafeMutablePointer<PlainClass>
// CHECK-LABEL: {{^}}  var var_UnsafeMutablePointer9: UnsafeMutablePointer<PlainStruct>
// CHECK-LABEL: {{^}}  var var_UnsafeMutablePointer10: UnsafeMutablePointer<PlainEnum>
// CHECK-LABEL: {{^}}  var var_UnsafeMutablePointer11: UnsafeMutablePointer<any PlainProtocol>
// CHECK-LABEL: {{^}}  var var_UnsafeMutablePointer12: UnsafeMutablePointer<AnyObject>
// CHECK-LABEL: var var_UnsafeMutablePointer13: UnsafeMutablePointer<any AnyObject.Type>
// CHECK-LABEL: {{^}}  var var_UnsafeMutablePointer100: UnsafeMutableRawPointer
// CHECK-LABEL: {{^}}  var var_UnsafeMutablePointer101: UnsafeMutableRawPointer
// CHECK-LABEL: {{^}}  var var_UnsafeMutablePointer102: UnsafeMutablePointer<(Int, Int)>

  var var_Optional1: Class_ObjC1?
  var var_Optional2: Protocol_ObjC1?
  var var_Optional3: Class_ObjC1.Type?
  var var_Optional4: Protocol_ObjC1.Type?
  var var_Optional5: AnyObject?
  var var_Optional6: AnyObject.Type?
  var var_Optional7: String?
  var var_Optional8: Protocol_ObjC1?
  var var_Optional9: Protocol_ObjC1.Type?
  var var_Optional10: (Protocol_ObjC1 & Protocol_ObjC2)?
  var var_Optional11: (Protocol_ObjC1 & Protocol_ObjC2).Type?
  var var_Optional12: OpaquePointer?
  var var_Optional13: UnsafeMutablePointer<Int>?
  var var_Optional14: UnsafeMutablePointer<Class_ObjC1>?

// CHECK-LABEL: {{^}}  @_hasInitialValue var var_Optional1: Class_ObjC1?
// CHECK-LABEL: {{^}}  @_hasInitialValue var var_Optional2: (any Protocol_ObjC1)?
// CHECK-LABEL: {{^}}  @_hasInitialValue var var_Optional3: Class_ObjC1.Type?
// CHECK-LABEL: {{^}}  @_hasInitialValue var var_Optional4: (any Protocol_ObjC1.Type)?
// CHECK-LABEL: {{^}}  @_hasInitialValue var var_Optional5: AnyObject?
// CHECK-LABEL: {{^}}  @_hasInitialValue var var_Optional6: (any AnyObject.Type)?
// CHECK-LABEL: {{^}}  @_hasInitialValue var var_Optional7: String?
// CHECK-LABEL: {{^}}  @_hasInitialValue var var_Optional8: (any Protocol_ObjC1)?
// CHECK-LABEL: {{^}}  @_hasInitialValue var var_Optional9: (any Protocol_ObjC1.Type)?
// CHECK-LABEL: {{^}}  @_hasInitialValue var var_Optional10: (any Protocol_ObjC1 & Protocol_ObjC2)?
// CHECK-LABEL: {{^}}  @_hasInitialValue var var_Optional11: (any (Protocol_ObjC1 & Protocol_ObjC2).Type)?
// CHECK-LABEL: {{^}}  @_hasInitialValue var var_Optional12: OpaquePointer?
// CHECK-LABEL: {{^}}  @_hasInitialValue var var_Optional13: UnsafeMutablePointer<Int>?
// CHECK-LABEL: {{^}}  @_hasInitialValue var var_Optional14: UnsafeMutablePointer<Class_ObjC1>?


  var var_ImplicitlyUnwrappedOptional1: Class_ObjC1!
  var var_ImplicitlyUnwrappedOptional2: Protocol_ObjC1!
  var var_ImplicitlyUnwrappedOptional3: Class_ObjC1.Type!
  var var_ImplicitlyUnwrappedOptional4: Protocol_ObjC1.Type!
  var var_ImplicitlyUnwrappedOptional5: AnyObject!
  var var_ImplicitlyUnwrappedOptional6: AnyObject.Type!
  var var_ImplicitlyUnwrappedOptional7: String!
  var var_ImplicitlyUnwrappedOptional8: Protocol_ObjC1!
  var var_ImplicitlyUnwrappedOptional9: (Protocol_ObjC1 & Protocol_ObjC2)!

// CHECK-LABEL: {{^}}  @_hasInitialValue var var_ImplicitlyUnwrappedOptional1: Class_ObjC1!
// CHECK-LABEL: {{^}}  @_hasInitialValue var var_ImplicitlyUnwrappedOptional2: (any Protocol_ObjC1)!
// CHECK-LABEL: {{^}}  @_hasInitialValue var var_ImplicitlyUnwrappedOptional3: Class_ObjC1.Type!
// CHECK-LABEL: {{^}}  @_hasInitialValue var var_ImplicitlyUnwrappedOptional4: (any Protocol_ObjC1.Type)!
// CHECK-LABEL: {{^}}  @_hasInitialValue var var_ImplicitlyUnwrappedOptional5: AnyObject!
// CHECK-LABEL: {{^}}  @_hasInitialValue var var_ImplicitlyUnwrappedOptional6: (any AnyObject.Type)!
// CHECK-LABEL: {{^}}  @_hasInitialValue var var_ImplicitlyUnwrappedOptional7: String!
// CHECK-LABEL: {{^}}  @_hasInitialValue var var_ImplicitlyUnwrappedOptional8: (any Protocol_ObjC1)!
// CHECK-LABEL: {{^}}  @_hasInitialValue var var_ImplicitlyUnwrappedOptional9: (any Protocol_ObjC1 & Protocol_ObjC2)!

  var var_Optional_fail1: PlainClass?
  var var_Optional_fail2: PlainClass.Type?
  var var_Optional_fail3: PlainClass!
  var var_Optional_fail4: PlainStruct?
  var var_Optional_fail5: PlainStruct.Type?
  var var_Optional_fail6: PlainEnum?
  var var_Optional_fail7: PlainEnum.Type?
  var var_Optional_fail8: PlainProtocol?
  var var_Optional_fail10: PlainProtocol?
  var var_Optional_fail11: (PlainProtocol & Protocol_ObjC1)?
  var var_Optional_fail12: Int?
  var var_Optional_fail13: Bool?
  var var_Optional_fail14: CBool?
  var var_Optional_fail20: AnyObject??
  var var_Optional_fail21: AnyObject.Type??
  var var_Optional_fail22: ComparisonResult? // a non-bridged imported value type
  var var_Optional_fail23: NSRange? // a bridged struct imported from C
// CHECK-NOT: @objc{{.*}}Optional_fail

  // CHECK-LABEL: {{^}}  var var_CFunctionPointer_1: @convention(c) () -> ()
  var var_CFunctionPointer_1: @convention(c) () -> ()
  // CHECK-LABEL: {{^}}  var var_CFunctionPointer_invalid_1: Int
  var var_CFunctionPointer_invalid_1: @convention(c) Int // expected-error {{@convention attribute only applies to function types}}
  // CHECK-LABEL: {{^}} var var_CFunctionPointer_invalid_2: <<error type>>
  var var_CFunctionPointer_invalid_2: @convention(c) (PlainStruct) -> Int // expected-error {{'(PlainStruct) -> Int' is not representable in Objective-C, so it cannot be used with '@convention(c)'}}
  
  // <rdar://problem/20918869> Confusing diagnostic for @convention(c) throws
  var var_CFunctionPointer_invalid_3 : @convention(c) (Int) throws -> Int // expected-error {{'(Int) throws -> Int' is not representable in Objective-C, so it cannot be used with '@convention(c)'}}

  weak var var_Weak1: Class_ObjC1?
  weak var var_Weak2: Protocol_ObjC1?
  // <rdar://problem/16473062> weak and unowned variables of metatypes are rejected
  //weak var var_Weak3: Class_ObjC1.Type?
  //weak var var_Weak4: Protocol_ObjC1.Type?
  weak var var_Weak5: AnyObject?
  //weak var var_Weak6: AnyObject.Type?
  weak var var_Weak7: Protocol_ObjC1?
  weak var var_Weak8: (Protocol_ObjC1 & Protocol_ObjC2)?

// CHECK-LABEL: {{^}}  @_hasInitialValue weak var var_Weak1: @sil_weak Class_ObjC1?
// CHECK-LABEL: {{^}}  @_hasInitialValue weak var var_Weak2: @sil_weak (any Protocol_ObjC1)?
// CHECK-LABEL: {{^}}  @_hasInitialValue weak var var_Weak5: @sil_weak AnyObject?
// CHECK-LABEL: {{^}}  @_hasInitialValue weak var var_Weak7: @sil_weak (any Protocol_ObjC1)?
// CHECK-LABEL: {{^}}  @_hasInitialValue weak var var_Weak8: @sil_weak (any Protocol_ObjC1 & Protocol_ObjC2)?

  weak var var_Weak_fail1: PlainClass?
  weak var var_Weak_bad2: PlainStruct?
  // expected-error@-1 {{'weak' may only be applied to class and class-bound protocol types, not 'PlainStruct'}}

  weak var var_Weak_bad3: PlainEnum?
  // expected-error@-1 {{'weak' may only be applied to class and class-bound protocol types, not 'PlainEnum'}}
  weak var var_Weak_bad4: String?
  // expected-error@-1 {{'weak' may only be applied to class and class-bound protocol types, not 'String'}}
// CHECK-NOT: @objc{{.*}}Weak_fail


  unowned var var_Unowned1: Class_ObjC1
  unowned var var_Unowned2: Protocol_ObjC1
  // <rdar://problem/16473062> weak and unowned variables of metatypes are rejected
  //unowned var var_Unowned3: Class_ObjC1.Type
  //unowned var var_Unowned4: Protocol_ObjC1.Type
  unowned var var_Unowned5: AnyObject
  //unowned var var_Unowned6: AnyObject.Type
  unowned var var_Unowned7: Protocol_ObjC1
  unowned var var_Unowned8: Protocol_ObjC1 & Protocol_ObjC2

// CHECK-LABEL: {{^}}  unowned var var_Unowned1: @sil_unowned Class_ObjC1
// CHECK-LABEL: {{^}}  unowned var var_Unowned2: @sil_unowned any Protocol_ObjC1
// CHECK-LABEL: {{^}}  unowned var var_Unowned5: @sil_unowned AnyObject
// CHECK-LABEL: {{^}}  unowned var var_Unowned7: @sil_unowned any Protocol_ObjC1
// CHECK-LABEL: {{^}}  unowned var var_Unowned8: @sil_unowned any Protocol_ObjC1 & Protocol_ObjC2


  unowned var var_Unowned_fail1: PlainClass
  unowned var var_Unowned_bad2: PlainStruct
  // expected-error@-1 {{'unowned' may only be applied to class and class-bound protocol types, not 'PlainStruct'}}
  unowned var var_Unowned_bad3: PlainEnum
  // expected-error@-1 {{'unowned' may only be applied to class and class-bound protocol types, not 'PlainEnum'}}
  unowned var var_Unowned_bad4: String
  // expected-error@-1 {{'unowned' may only be applied to class and class-bound protocol types, not 'String'}}
// CHECK-NOT: @objc{{.*}}Unowned_fail


  var var_FunctionType1: () -> ()
// CHECK-LABEL: {{^}}  var var_FunctionType1: () -> ()

  var var_FunctionType2: (Int) -> ()
// CHECK-LABEL: {{^}}  var var_FunctionType2: (Int) -> ()

  var var_FunctionType3: (Int) -> Int
// CHECK-LABEL: {{^}}  var var_FunctionType3: (Int) -> Int

  var var_FunctionType4: (Int, Double) -> ()
// CHECK-LABEL: {{^}}  var var_FunctionType4: (Int, Double) -> ()

  var var_FunctionType5: (String) -> ()
// CHECK-LABEL: {{^}}  var var_FunctionType5: (String) -> ()

  var var_FunctionType6: () -> String
// CHECK-LABEL: {{^}}  var var_FunctionType6: () -> String

  var var_FunctionType7: (PlainClass) -> ()
// CHECK-LABEL: {{^}}  var var_FunctionType7: (PlainClass) -> ()

  var var_FunctionType8: () -> PlainClass
// CHECK-LABEL: {{^}}  var var_FunctionType8: () -> PlainClass

  var var_FunctionType9: (PlainStruct) -> ()
// CHECK-LABEL: {{^}}  var var_FunctionType9: (PlainStruct) -> ()

  var var_FunctionType10: () -> PlainStruct
// CHECK-LABEL: {{^}}  var var_FunctionType10: () -> PlainStruct

  var var_FunctionType11: (PlainEnum) -> ()
// CHECK-LABEL: {{^}}  var var_FunctionType11: (PlainEnum) -> ()

  var var_FunctionType12: (PlainProtocol) -> ()
// CHECK-LABEL: {{^}}  var var_FunctionType12: (any PlainProtocol) -> ()

  var var_FunctionType13: (Class_ObjC1) -> ()
// CHECK-LABEL: {{^}}  var var_FunctionType13: (Class_ObjC1) -> ()

  var var_FunctionType14: (Protocol_Class1) -> ()
// CHECK-LABEL: {{^}}  var var_FunctionType14: (any Protocol_Class1) -> ()

  var var_FunctionType15: (Protocol_ObjC1) -> ()
// CHECK-LABEL: {{^}}  var var_FunctionType15: (any Protocol_ObjC1) -> ()

  var var_FunctionType16: (AnyObject) -> ()
// CHECK-LABEL: {{^}} var var_FunctionType16: (AnyObject) -> ()

  var var_FunctionType17: (() -> ()) -> ()
// CHECK-LABEL: {{^}}  var var_FunctionType17: (() -> ()) -> ()

  var var_FunctionType18: ((Int) -> (), Int) -> ()
// CHECK-LABEL: {{^}}  var var_FunctionType18: ((Int) -> (), Int) -> ()

  var var_FunctionType19: ((String) -> (), Int) -> ()
// CHECK-LABEL: {{^}}  var var_FunctionType19: ((String) -> (), Int) -> ()


  var var_FunctionTypeReturn1: () -> () -> ()
// CHECK-LABEL: {{^}}  var var_FunctionTypeReturn1: () -> () -> ()

  @objc // access-note-move{{infer_instanceVar1.var_FunctionTypeReturn1_}}
  var var_FunctionTypeReturn1_: () -> () -> () // no-error

  var var_FunctionTypeReturn2: () -> (Int) -> ()
// CHECK-LABEL: {{^}}  var var_FunctionTypeReturn2: () -> (Int) -> ()

  @objc // access-note-move{{infer_instanceVar1.var_FunctionTypeReturn2_}}
  var var_FunctionTypeReturn2_: () -> (Int) -> () // no-error

  var var_FunctionTypeReturn3: () -> () -> Int
// CHECK-LABEL: {{^}}  var var_FunctionTypeReturn3: () -> () -> Int

  @objc // access-note-move{{infer_instanceVar1.var_FunctionTypeReturn3_}}
  var var_FunctionTypeReturn3_: () -> () -> Int // no-error

  var var_FunctionTypeReturn4: () -> (String) -> ()
// CHECK-LABEL: {{^}}  var var_FunctionTypeReturn4: () -> (String) -> ()

  @objc // access-note-move{{infer_instanceVar1.var_FunctionTypeReturn4_}}
  var var_FunctionTypeReturn4_: () -> (String) -> () // no-error

  var var_FunctionTypeReturn5: () -> () -> String
// CHECK-LABEL: {{^}}  var var_FunctionTypeReturn5: () -> () -> String

  @objc // access-note-move{{infer_instanceVar1.var_FunctionTypeReturn5_}}
  var var_FunctionTypeReturn5_: () -> () -> String // no-error


  var var_BlockFunctionType1: @convention(block) () -> ()
// CHECK-LABEL: {{^}}  var var_BlockFunctionType1: @convention(block) () -> ()

  @objc // access-note-move{{infer_instanceVar1.var_BlockFunctionType1_}}
  var var_BlockFunctionType1_: @convention(block) () -> () // no-error

  var var_ArrayType1: [AnyObject]
  // CHECK-LABEL: {{^}}  var var_ArrayType1: [AnyObject]

  @objc // access-note-move{{infer_instanceVar1.var_ArrayType1_}}
  var var_ArrayType1_: [AnyObject] // no-error

  var var_ArrayType2: [@convention(block) (AnyObject) -> AnyObject] // no-error
  // CHECK-LABEL: {{^}}  var var_ArrayType2: [@convention(block) (AnyObject) -> AnyObject]

  @objc // access-note-move{{infer_instanceVar1.var_ArrayType2_}}
  var var_ArrayType2_: [@convention(block) (AnyObject) -> AnyObject] // no-error

  var var_ArrayType3: [PlainStruct]
  // CHECK-LABEL: {{^}}  var var_ArrayType3: [PlainStruct]

  @objc // bad-access-note-move{{infer_instanceVar1.var_ArrayType3_}}
  var var_ArrayType3_: [PlainStruct]
  // access-note-adjust{{@objc}} expected-error @-1{{property cannot be marked @objc because its type cannot be represented in Objective-C}}
  // expected-note@-2 {{Swift structs cannot be represented in Objective-C}}

  var var_ArrayType4: [(AnyObject) -> AnyObject] // no-error
  // CHECK-LABEL: {{^}}  var var_ArrayType4: [(AnyObject) -> AnyObject]

  @objc // bad-access-note-move{{infer_instanceVar1.var_ArrayType4_}}
  var var_ArrayType4_: [(AnyObject) -> AnyObject]
  // access-note-adjust{{@objc}} expected-error @-1{{property cannot be marked @objc because its type cannot be represented in Objective-C}}
  // expected-note@-2 {{Swift structs cannot be represented in Objective-C}}

  var var_ArrayType5: [Protocol_ObjC1]
  // CHECK-LABEL: {{^}}  var var_ArrayType5: [any Protocol_ObjC1]

  @objc // access-note-move{{infer_instanceVar1.var_ArrayType5_}}
  var var_ArrayType5_: [Protocol_ObjC1] // no-error

  var var_ArrayType6: [Class_ObjC1]
  // CHECK-LABEL: {{^}}  var var_ArrayType6: [Class_ObjC1]

  @objc // access-note-move{{infer_instanceVar1.var_ArrayType6_}}
  var var_ArrayType6_: [Class_ObjC1] // no-error

  var var_ArrayType7: [PlainClass]
  // CHECK-LABEL: {{^}}  var var_ArrayType7: [PlainClass]

  @objc // bad-access-note-move{{infer_instanceVar1.var_ArrayType7_}}
  var var_ArrayType7_: [PlainClass]
  // access-note-adjust{{@objc}} expected-error @-1{{property cannot be marked @objc because its type cannot be represented in Objective-C}}
  // expected-note@-2 {{Swift structs cannot be represented in Objective-C}}

  var var_ArrayType8: [PlainProtocol]
  // CHECK-LABEL: {{^}}  var var_ArrayType8: [any PlainProtocol]

  @objc // bad-access-note-move{{infer_instanceVar1.var_ArrayType8_}}
  var var_ArrayType8_: [PlainProtocol]
  // access-note-adjust{{@objc}} expected-error @-1{{property cannot be marked @objc because its type cannot be represented in Objective-C}}
  // expected-note@-2 {{Swift structs cannot be represented in Objective-C}}

  var var_ArrayType9: [Protocol_ObjC1 & PlainProtocol]
  // CHECK-LABEL: {{^}}  var var_ArrayType9: [any PlainProtocol & Protocol_ObjC1]

  @objc // bad-access-note-move{{infer_instanceVar1.var_ArrayType9_}}
  var var_ArrayType9_: [Protocol_ObjC1 & PlainProtocol]
  // access-note-adjust{{@objc}} expected-error @-1{{property cannot be marked @objc because its type cannot be represented in Objective-C}}
  // expected-note@-2 {{Swift structs cannot be represented in Objective-C}}

  var var_ArrayType10: [Protocol_ObjC1 & Protocol_ObjC2]
  // CHECK-LABEL: {{^}}  var var_ArrayType10: [any Protocol_ObjC1 & Protocol_ObjC2]

  @objc // access-note-move{{infer_instanceVar1.var_ArrayType10_}}
  var var_ArrayType10_: [Protocol_ObjC1 & Protocol_ObjC2]
  // no-error

  var var_ArrayType11: [Any]
  // CHECK-LABEL: {{^}}  var var_ArrayType11: [Any]

  @objc // access-note-move{{infer_instanceVar1.var_ArrayType11_}}
  var var_ArrayType11_: [Any]

  var var_ArrayType13: [Any?]
  // CHECK-LABEL: {{^}}  var var_ArrayType13: [Any?]

  @objc // bad-access-note-move{{infer_instanceVar1.var_ArrayType13_}}
  var var_ArrayType13_: [Any?]
  // access-note-adjust{{@objc}} expected-error @-1{{property cannot be marked @objc because its type cannot be represented in Objective-C}}
  // expected-note@-2 {{Swift structs cannot be represented in Objective-C}}

  var var_ArrayType15: [AnyObject?]
  // CHECK-LABEL: {{^}}  var var_ArrayType15: [AnyObject?]

  @objc // bad-access-note-move{{infer_instanceVar1.var_ArrayType15_}}
  var var_ArrayType15_: [AnyObject?]
  // access-note-adjust{{@objc}} expected-error @-1{{property cannot be marked @objc because its type cannot be represented in Objective-C}}
  // expected-note@-2 {{Swift structs cannot be represented in Objective-C}}

  var var_ArrayType16: [[@convention(block) (AnyObject) -> AnyObject]] // no-error
  // CHECK-LABEL: {{^}}  var var_ArrayType16: {{\[}}[@convention(block) (AnyObject) -> AnyObject]]

  @objc // access-note-move{{infer_instanceVar1.var_ArrayType16_}}
  var var_ArrayType16_: [[@convention(block) (AnyObject) -> AnyObject]] // no-error

  var var_ArrayType17: [[(AnyObject) -> AnyObject]] // no-error
  // CHECK-LABEL: {{^}}  var var_ArrayType17: {{\[}}[(AnyObject) -> AnyObject]]

  @objc // bad-access-note-move{{infer_instanceVar1.var_ArrayType17_}}
  var var_ArrayType17_: [[(AnyObject) -> AnyObject]]
  // access-note-adjust{{@objc}} expected-error @-1{{property cannot be marked @objc because its type cannot be represented in Objective-C}}
  // expected-note@-2 {{Swift structs cannot be represented in Objective-C}}
}

@objc // access-note-move{{ObjCBase}}
class ObjCBase {}

class infer_instanceVar2<
    GP_Unconstrained,
    GP_PlainClass : PlainClass,
    GP_PlainProtocol : PlainProtocol,
    GP_Class_ObjC : Class_ObjC1,
    GP_Protocol_Class : Protocol_Class1,
    GP_Protocol_ObjC : Protocol_ObjC1> : ObjCBase {
// CHECK-LABEL: class infer_instanceVar2<{{.*}}> : ObjCBase where {{.*}} {
  override init() {}

  var var_GP_Unconstrained: GP_Unconstrained
// CHECK-LABEL: {{^}}  var var_GP_Unconstrained: GP_Unconstrained

  @objc // bad-access-note-move{{infer_instanceVar2.var_GP_Unconstrained_}}
  var var_GP_Unconstrained_: GP_Unconstrained
  // access-note-adjust{{@objc}} expected-error@-1 {{property cannot be marked @objc because its type cannot be represented in Objective-C}}
  // expected-note@-2 {{generic type parameters cannot be represented in Objective-C}}

  var var_GP_PlainClass: GP_PlainClass
// CHECK-LABEL: {{^}}  var var_GP_PlainClass: GP_PlainClass

  @objc // bad-access-note-move{{infer_instanceVar2.var_GP_PlainClass_}}
  var var_GP_PlainClass_: GP_PlainClass
  // access-note-adjust{{@objc}} expected-error@-1 {{property cannot be marked @objc because its type cannot be represented in Objective-C}}
  // expected-note@-2 {{generic type parameters cannot be represented in Objective-C}}

  var var_GP_PlainProtocol: GP_PlainProtocol
// CHECK-LABEL: {{^}}  var var_GP_PlainProtocol: GP_PlainProtocol

  @objc // bad-access-note-move{{infer_instanceVar2.var_GP_PlainProtocol_}}
  var var_GP_PlainProtocol_: GP_PlainProtocol
  // access-note-adjust{{@objc}} expected-error@-1 {{property cannot be marked @objc because its type cannot be represented in Objective-C}}
  // expected-note@-2 {{generic type parameters cannot be represented in Objective-C}}

  var var_GP_Class_ObjC: GP_Class_ObjC
// CHECK-LABEL: {{^}}  var var_GP_Class_ObjC: GP_Class_ObjC

  @objc // bad-access-note-move{{infer_instanceVar2.var_GP_Class_ObjC_}}
  var var_GP_Class_ObjC_: GP_Class_ObjC
  // access-note-adjust{{@objc}} expected-error@-1 {{property cannot be marked @objc because its type cannot be represented in Objective-C}}
  // expected-note@-2 {{generic type parameters cannot be represented in Objective-C}}

  var var_GP_Protocol_Class: GP_Protocol_Class
// CHECK-LABEL: {{^}}  var var_GP_Protocol_Class: GP_Protocol_Class

  @objc // bad-access-note-move{{infer_instanceVar2.var_GP_Protocol_Class_}}
  var var_GP_Protocol_Class_: GP_Protocol_Class
  // access-note-adjust{{@objc}} expected-error@-1 {{property cannot be marked @objc because its type cannot be represented in Objective-C}}
  // expected-note@-2 {{generic type parameters cannot be represented in Objective-C}}

  var var_GP_Protocol_ObjC: GP_Protocol_ObjC
// CHECK-LABEL: {{^}}  var var_GP_Protocol_ObjC: GP_Protocol_ObjC

  @objc // bad-access-note-move{{infer_instanceVar2.var_GP_Protocol_ObjCa}}
  var var_GP_Protocol_ObjCa: GP_Protocol_ObjC
  // access-note-adjust{{@objc}} expected-error@-1 {{property cannot be marked @objc because its type cannot be represented in Objective-C}}
  // expected-note@-2 {{generic type parameters cannot be represented in Objective-C}}

  func func_GP_Unconstrained(a: GP_Unconstrained) {}
// CHECK-LABEL: {{^}} func func_GP_Unconstrained(a: GP_Unconstrained) {

  @objc // bad-access-note-move{{infer_instanceVar2.func_GP_Unconstrained_(a:)}}
  func func_GP_Unconstrained_(a: GP_Unconstrained) {}
  // access-note-adjust{{@objc}} expected-error@-1 {{method cannot be marked @objc because the type of the parameter cannot be represented in Objective-C}}
  // expected-note@-2 {{generic type parameters cannot be represented in Objective-C}}

  @objc // bad-access-note-move{{infer_instanceVar2.func_GP_Unconstrained_()}}
  func func_GP_Unconstrained_() -> GP_Unconstrained {}
  // access-note-adjust{{@objc}} expected-error@-1 {{method cannot be marked @objc because its result type cannot be represented in Objective-C}}
  // expected-note@-2 {{generic type parameters cannot be represented in Objective-C}}

  @objc // bad-access-note-move{{infer_instanceVar2.func_GP_Class_ObjC__()}}
  func func_GP_Class_ObjC__() -> GP_Class_ObjC {}
  // access-note-adjust{{@objc}} expected-error@-1 {{method cannot be marked @objc because its result type cannot be represented in Objective-C}}
  // expected-note@-2 {{generic type parameters cannot be represented in Objective-C}}
}

class infer_instanceVar3 : Class_ObjC1 {
// CHECK-LABEL: @objc @_inheritsConvenienceInitializers class infer_instanceVar3 : Class_ObjC1 {

  var v1: Int = 0
// CHECK-LABEL: {{^}}  @_hasInitialValue var v1: Int
}


@objc // access-note-move{{infer_instanceVar4}}
protocol infer_instanceVar4 {
// CHECK-LABEL: @objc protocol infer_instanceVar4 {

  var v1: Int { get }
// CHECK-LABEL: @objc var v1: Int { get }
}

// @!objc
class infer_instanceVar5 {
// CHECK-LABEL: {{^}}class infer_instanceVar5 {

  @objc // access-note-move{{infer_instanceVar5.instanceVar1}}
  var instanceVar1: Int {
  // CHECK: @objc var instanceVar1: Int
    get {}
    // CHECK: @objc get {}
    set {}
    // CHECK: @objc set {}
  }
}

@objc // access-note-move{{infer_staticVar1}}
class infer_staticVar1 {
// CHECK-LABEL: @objc class infer_staticVar1 {

  class var staticVar1: Int = 42 // expected-error {{class stored properties not supported}}
  // CHECK: {{^}}  @_hasInitialValue class var staticVar1: Int
}

// @!objc
class infer_subscript1 {
// CHECK-LABEL: class infer_subscript1

  @objc // access-note-move{{infer_subscript1.subscript(_:)}}
  subscript(i: Int) -> Int {
  // CHECK: @objc subscript(i: Int) -> Int
    get {}
    // CHECK: @objc get {}
    set {}
    // CHECK: @objc set {}
  }
}


@objc // access-note-move{{infer_throughConformanceProto1}}
protocol infer_throughConformanceProto1 {
// CHECK-LABEL: @objc protocol infer_throughConformanceProto1 {

  func funcObjC1()
  var varObjC1: Int { get }
  var varObjC2: Int { get set }
  // CHECK: @objc func funcObjC1()
  // CHECK: @objc var varObjC1: Int { get }
  // CHECK: @objc var varObjC2: Int { get set }
}

class infer_class1 : PlainClass {}
// CHECK-LABEL: {{^}}@_inheritsConvenienceInitializers class infer_class1 : PlainClass {

class infer_class2 : Class_ObjC1 {}
// CHECK-LABEL: @objc @_inheritsConvenienceInitializers class infer_class2 : Class_ObjC1 {

class infer_class3 : infer_class2 {}
// CHECK-LABEL: @objc @_inheritsConvenienceInitializers class infer_class3 : infer_class2 {

class infer_class4 : Protocol_Class1 {}
// CHECK-LABEL: {{^}}class infer_class4 : Protocol_Class1 {

class infer_class5 : Protocol_ObjC1 {}
// CHECK-LABEL: {{^}}class infer_class5 : Protocol_ObjC1 {

//
// If a protocol conforms to an @objc protocol, this does not infer @objc on
// the protocol itself, or on the newly introduced requirements.  Only the
// inherited @objc requirements get @objc.
//
// Same rule applies to classes.
//

protocol infer_protocol1 {
// CHECK-LABEL: {{^}}protocol infer_protocol1 {
  func nonObjC1()
  // CHECK: {{^}} func nonObjC1()
}

protocol infer_protocol2 : Protocol_Class1 {
// CHECK-LABEL: {{^}}protocol infer_protocol2 : Protocol_Class1 {
  func nonObjC1()
  // CHECK: {{^}} func nonObjC1()
}

protocol infer_protocol3 : Protocol_ObjC1 {
// CHECK-LABEL: {{^}}protocol infer_protocol3 : Protocol_ObjC1 {
  func nonObjC1()
  // CHECK: {{^}} func nonObjC1()
}

protocol infer_protocol4 : Protocol_Class1, Protocol_ObjC1 {
// CHECK-LABEL: {{^}}protocol infer_protocol4 : Protocol_Class1, Protocol_ObjC1 {
  func nonObjC1()
  // CHECK: {{^}} func nonObjC1()
}

protocol infer_protocol5 : Protocol_ObjC1, Protocol_Class1 {
// CHECK-LABEL: {{^}}protocol infer_protocol5 : Protocol_Class1, Protocol_ObjC1 {
  func nonObjC1()
  // CHECK: {{^}} func nonObjC1()
}

class C {
  // Don't crash.
  @objc func foo(x: Undeclared) {} // expected-error {{cannot find type 'Undeclared' in scope}}
  @IBAction func myAction(sender: Undeclared) {} // expected-error {{cannot find type 'Undeclared' in scope}}
  @IBSegueAction func myAction(coder: Undeclared, sender: Undeclared) -> Undeclared {fatalError()} // expected-error {{cannot find type 'Undeclared' in scope}} expected-error {{cannot find type 'Undeclared' in scope}} expected-error {{cannot find type 'Undeclared' in scope}}
}

//===---
//===--- @IBOutlet implies @objc
//===---

class HasIBOutlet {
// CHECK-LABEL: {{^}}class HasIBOutlet {

  init() {}

  @IBOutlet weak var goodOutlet: Class_ObjC1!
  // CHECK-LABEL: {{^}} @objc @IBOutlet @_hasInitialValue weak var goodOutlet: @sil_weak Class_ObjC1!

  @IBOutlet var badOutlet: PlainStruct
  // expected-error@-1 {{@IBOutlet property cannot have non-object type 'PlainStruct'}} {{3-13=}}
  // expected-error@-2 {{@IBOutlet property has non-optional type 'PlainStruct'}}
  // expected-note@-3 {{add '?' to form the optional type 'PlainStruct?'}}
  // expected-note@-4 {{add '!' to form an implicitly unwrapped optional}}
  // CHECK-LABEL: {{^}}  @IBOutlet var badOutlet: PlainStruct
}

//===---
//===--- @IBAction implies @objc
//===---

// CHECK-LABEL: {{^}}class HasIBAction {
class HasIBAction {
  @IBAction func goodAction(_ sender: AnyObject?) { }
  // CHECK: {{^}}  @objc @IBAction @MainActor @preconcurrency func goodAction(_ sender: AnyObject?) {

  @IBAction func badAction(_ sender: PlainStruct?) { }
  // expected-error@-1{{method cannot be marked @IBAction because the type of the parameter cannot be represented in Objective-C}}
}

//===---
//===--- @IBSegueAction implies @objc
//===---

// CHECK-LABEL: {{^}}class HasIBSegueAction {
class HasIBSegueAction {
  @IBSegueAction func goodSegueAction(_ coder: AnyObject) -> AnyObject {fatalError()}
  // CHECK: {{^}}  @objc @IBSegueAction func goodSegueAction(_ coder: AnyObject) -> AnyObject {

  @IBSegueAction func badSegueAction(_ coder: PlainStruct?) -> Int? {fatalError()}
  // expected-error@-1{{method cannot be marked @IBSegueAction because the type of the parameter cannot be represented in Objective-C}}
}

//===---
//===--- @IBInspectable implies @objc
//===---

// CHECK-LABEL: {{^}}class HasIBInspectable {
class HasIBInspectable {
  @IBInspectable var goodProperty: AnyObject?
  // CHECK: {{^}}  @objc @IBInspectable @_hasInitialValue var goodProperty: AnyObject?
}

//===---
//===--- @GKInspectable implies @objc
//===---

// CHECK-LABEL: {{^}}class HasGKInspectable {
class HasGKInspectable {
  @GKInspectable var goodProperty: AnyObject?
  // CHECK: {{^}}  @objc @GKInspectable @_hasInitialValue var goodProperty: AnyObject?
}

//===---
//===--- @NSManaged implies @objc
//===---

class HasNSManaged {
// CHECK-LABEL: {{^}}class HasNSManaged {

  init() {}

  @NSManaged
  var goodManaged: Class_ObjC1
  // CHECK-LABEL: {{^}}  @objc @NSManaged dynamic var goodManaged: Class_ObjC1 {
  // CHECK-NEXT: {{^}} @objc get
  // CHECK-NEXT: {{^}} @objc set
  // CHECK-NEXT: {{^}} }

  @NSManaged
  var badManaged: PlainStruct
  // expected-error@-1 {{property cannot be marked @NSManaged because its type cannot be represented in Objective-C}}
  // expected-note@-2 {{Swift structs cannot be represented in Objective-C}}
  // CHECK-LABEL: {{^}}  @NSManaged dynamic var badManaged: PlainStruct {
  // CHECK-NEXT: {{^}} get
  // CHECK-NEXT: {{^}} set
  // CHECK-NEXT: {{^}} }
}

//===---
//===--- Pointer argument types
//===---

@objc // access-note-move{{TakesCPointers}}
class TakesCPointers {
// CHECK-LABEL: {{^}}@objc class TakesCPointers {
  func constUnsafeMutablePointer(p: UnsafePointer<Int>) {}
  // CHECK-LABEL: {{^}} func constUnsafeMutablePointer(p: UnsafePointer<Int>) {

  func constUnsafeMutablePointerToAnyObject(p: UnsafePointer<AnyObject>) {}
  // CHECK-LABEL: {{^}} func constUnsafeMutablePointerToAnyObject(p: UnsafePointer<AnyObject>) {

  func constUnsafeMutablePointerToClass(p: UnsafePointer<TakesCPointers>) {}
  // CHECK-LABEL: {{^}} func constUnsafeMutablePointerToClass(p: UnsafePointer<TakesCPointers>) {

  func mutableUnsafeMutablePointer(p: UnsafeMutablePointer<Int>) {}
  // CHECK-LABEL: {{^}} func mutableUnsafeMutablePointer(p: UnsafeMutablePointer<Int>) {

  func mutableStrongUnsafeMutablePointerToAnyObject(p: UnsafeMutablePointer<AnyObject>) {}
  // CHECK-LABEL: {{^}} func mutableStrongUnsafeMutablePointerToAnyObject(p: UnsafeMutablePointer<AnyObject>) {

  func mutableAutoreleasingUnsafeMutablePointerToAnyObject(p: AutoreleasingUnsafeMutablePointer<AnyObject>) {}
  // CHECK-LABEL: {{^}} func mutableAutoreleasingUnsafeMutablePointerToAnyObject(p: AutoreleasingUnsafeMutablePointer<AnyObject>) {
  }

// @objc with nullary names
@objc(NSObjC2) // access-note-move{{Class_ObjC2}}
class Class_ObjC2 {
// CHECK-LABEL: @objc(NSObjC2) class Class_ObjC2

  @objc(initWithMalice) // access-note-move{{Class_ObjC2.init(foo:)}}
  init(foo: ()) { }

  @objc(initWithIntent) // access-note-move{{Class_ObjC2.init(bar:)}}
  init(bar _: ()) { }

  @objc(initForMurder) // access-note-move{{Class_ObjC2.init()}}
  init() { }

  @objc(isFoo) // access-note-move{{Class_ObjC2.foo()}}
  func foo() -> Bool {}
  // CHECK-LABEL: @objc(isFoo) func foo() -> Bool {
}

@objc() // expected-error {{expected name within parentheses of @objc attribute}}
class Class_ObjC3 { 
}

// @objc with selector names
extension PlainClass {
  // CHECK-LABEL: @objc(setFoo:) dynamic func
  @objc(setFoo:) // access-note-move{{PlainClass.foo(b:)}}
  func foo(b: Bool) { }

  // CHECK-LABEL: @objc(setWithRed:green:blue:alpha:) dynamic func set
  @objc(setWithRed:green:blue:alpha:) // access-note-move{{PlainClass.set(_:green:blue:alpha:)}}
  func set(_: Float, green: Float, blue: Float, alpha: Float) { }

  // CHECK-LABEL: @objc(createWithRed:green:blue:alpha:) dynamic class func createWith
  @objc(createWithRed:green blue:alpha)
  class func createWithRed(_: Float, green: Float, blue: Float, alpha: Float) { }
  // expected-error@-2{{missing ':' after selector piece in @objc attribute}}{{28-28=:}}
  // expected-error@-3{{missing ':' after selector piece in @objc attribute}}{{39-39=:}}

  // CHECK-LABEL: @objc(::) dynamic func badlyNamed
  @objc(::) // access-note-move{{PlainClass.badlyNamed(_:y:)}}
  func badlyNamed(_: Int, y: Int) {}
}

@objc(Class:) // bad-access-note-move{{BadClass1}} expected-error{{'@objc' class must have a simple name}}{{12-13=}}
class BadClass1 { }

@objc(Protocol:) // bad-access-note-move{{BadProto1}} expected-error{{'@objc' protocol must have a simple name}}{{15-16=}}
protocol BadProto1 { }

@objc(Enum:) // bad-access-note-move{{BadEnum1}} expected-error{{'@objc' enum must have a simple name}}{{11-12=}}
enum BadEnum1: Int { case X }

@objc // access-note-move{{BadEnum2}}
enum BadEnum2: Int {
  @objc(X:) // bad-access-note-move{{BadEnum2.X}} expected-error{{'@objc' enum case must have a simple name}}{{10-11=}}
  case X
}

class BadClass2 {
  @objc(realDealloc) // expected-error{{'@objc' deinitializer cannot have a name}}
  deinit { }

  @objc(badprop:foo:wibble:) // bad-access-note-move{{BadClass2.badprop}} expected-error{{'@objc' property must have a simple name}}{{16-28=}}
  var badprop: Int = 5

  @objc(foo) // bad-access-note-move{{BadClass2.subscript(_:)}} expected-error{{'@objc' subscript cannot have a name; did you mean to put the name on the getter or setter?}}
  subscript (i: Int) -> Int {
    get {
      return i
    }
  }

  @objc(foo) // bad-access-note-move{{BadClass2.noArgNamesOneParam(x:)}} expected-error{{'@objc' method name provides names for 0 arguments, but method has one parameter}}
  func noArgNamesOneParam(x: Int) { }
  
  @objc(foo) // bad-access-note-move{{BadClass2.noArgNamesOneParam2(_:)}} expected-error{{'@objc' method name provides names for 0 arguments, but method has one parameter}}
  func noArgNamesOneParam2(_: Int) { }

  @objc(foo) // bad-access-note-move{{BadClass2.noArgNamesTwoParams(_:y:)}} expected-error{{'@objc' method name provides names for 0 arguments, but method has 2 parameters}}
  func noArgNamesTwoParams(_: Int, y: Int) { }

  @objc(foo:) // bad-access-note-move{{BadClass2.oneArgNameTwoParams(_:y:)}} expected-error{{'@objc' method name provides one argument name, but method has 2 parameters}}
  func oneArgNameTwoParams(_: Int, y: Int) { }

  @objc(foo:) // bad-access-note-move{{BadClass2.oneArgNameNoParams()}} expected-error{{'@objc' method name provides one argument name, but method has 0 parameters}}
  func oneArgNameNoParams() { }

  @objc(foo:) // bad-access-note-move{{BadClass2.init()}} expected-error{{'@objc' initializer name provides one argument name, but initializer has 0 parameters}}
  init() { }

  var _prop = 5
  @objc // access-note-move{{BadClass2.prop}}
  var prop: Int {
    @objc(property) // access-note-move{{getter:BadClass2.prop()}}
    get { return _prop }
    @objc(setProperty:) // access-note-move{{setter:BadClass2.prop()}}
    set { _prop = newValue }
  }

  var prop2: Int {
    @objc(property) // bad-access-note-move{{getter:BadClass2.prop2()}} expected-error{{'@objc' getter for non-'@objc' property}} {{5-21=}}
    get { return _prop }
    @objc(setProperty:) // bad-access-note-move{{setter:BadClass2.prop2()}} expected-error{{'@objc' setter for non-'@objc' property}} {{5-25=}}
    set { _prop = newValue }
  }

  var prop3: Int {
    @objc(setProperty:) // expected-error{{observing accessors are not allowed to be marked @objc}} {{5-25=}}
    didSet { }
  }
}

// FIXME: This could be part of BadClass except that access notes can't
// distinguish between overloads of `subscript(_:)`.
class GoodClass {
  @objc // access-note-move{{GoodClass.subscript(_:)}}
  subscript (c: Class_ObjC1) -> Class_ObjC1 {
    @objc(getAtClass:) // access-note-move{{getter:GoodClass.subscript(_:)}}
    get {
      return c
    }

    @objc(setAtClass:class:) // access-note-move{{setter:GoodClass.subscript(_:)}}
    set {
    }
  }
}

// Swift overrides that aren't also @objc overrides.
class Super {
  @objc(renamedFoo) // access-note-move{{Super.foo}}
  var foo: Int { get { return 3 } } // expected-note 2{{overridden declaration is here}}

  @objc // access-note-move{{Super.process(i:)}}
  func process(i: Int) -> Int { } // expected-note {{overriding '@objc' instance method 'process(i:)' here}}
}

class Sub1 : Super {
  @objc(foo) // bad-access-note-move{{Sub1.foo}} expected-error{{Objective-C property has a different name from the property it overrides ('foo' vs. 'renamedFoo')}}{{9-12=renamedFoo}}
  override var foo: Int { get { return 5 } }

  override func process(i: Int?) -> Int { } // expected-error{{method cannot be an @objc override because the type of the parameter cannot be represented in Objective-C}}
}

class Sub2 : Super {
  @objc // bad-access-note-move{{Sub2.foo}} -- @objc is already implied by overriding an @objc attribute, so access notes shouldn't emit a remark
  override var foo: Int { get { return 5 } }
}

class Sub3 : Super {
  override var foo: Int { get { return 5 } }
}

class Sub4 : Super {
  @objc(renamedFoo) // access-note-move{{Sub4.foo}}
  override var foo: Int { get { return 5 } }
}

class Sub5 : Super {
  @objc(wrongFoo) // bad-access-note-move{{Sub5.foo}} expected-error{{Objective-C property has a different name from the property it overrides ('wrongFoo' vs. 'renamedFoo')}} {{9-17=renamedFoo}}
  override var foo: Int { get { return 5 } }
}

enum NotObjCEnum { case X }
struct NotObjCStruct {}

// Closure arguments can only be @objc if their parameters and returns are.
// CHECK-LABEL: @objc class ClosureArguments
@objc // access-note-move{{ClosureArguments}}
class ClosureArguments {
  // CHECK: @objc func foo
  @objc // access-note-move{{ClosureArguments.foo(f:)}}
  func foo(f: (Int) -> ()) {}
  // CHECK: @objc func bar
  @objc // bad-access-note-move{{ClosureArguments.bar(f:)}}
  func bar(f: (NotObjCEnum) -> NotObjCStruct) {} // access-note-adjust{{@objc}} expected-error{{method cannot be marked @objc because the type of the parameter cannot be represented in Objective-C}} expected-note{{function types cannot be represented in Objective-C unless their parameters and returns can be}}
  // CHECK: @objc func bas
  @objc // bad-access-note-move{{ClosureArguments.bas(f:)}}
  func bas(f: (NotObjCEnum) -> ()) {} // access-note-adjust{{@objc}} expected-error{{method cannot be marked @objc because the type of the parameter cannot be represented in Objective-C}} expected-note{{function types cannot be represented in Objective-C unless their parameters and returns can be}}
  // CHECK: @objc func zim
  @objc // bad-access-note-move{{ClosureArguments.zim(f:)}}
  func zim(f: () -> NotObjCStruct) {} // access-note-adjust{{@objc}} expected-error{{method cannot be marked @objc because the type of the parameter cannot be represented in Objective-C}} expected-note{{function types cannot be represented in Objective-C unless their parameters and returns can be}}
  // CHECK: @objc func zang
  @objc // bad-access-note-move{{ClosureArguments.zang(f:)}}
  func zang(f: (NotObjCEnum, NotObjCStruct) -> ()) {} // access-note-adjust{{@objc}} expected-error{{method cannot be marked @objc because the type of the parameter cannot be represented in Objective-C}} expected-note{{function types cannot be represented in Objective-C unless their parameters and returns can be}}
  @objc // bad-access-note-move{{ClosureArguments.zangZang(f:)}}
  func zangZang(f: (Int...) -> ()) {} // access-note-adjust{{@objc}} expected-error{{method cannot be marked @objc because the type of the parameter cannot be represented in Objective-C}} expected-note{{function types cannot be represented in Objective-C unless their parameters and returns can be}}
  // CHECK: {{^}}  func fooImplicit
  func fooImplicit(f: (Int) -> ()) {}
  // CHECK: {{^}}  func barImplicit
  func barImplicit(f: (NotObjCEnum) -> NotObjCStruct) {}
  // CHECK: {{^}}  func basImplicit
  func basImplicit(f: (NotObjCEnum) -> ()) {}
  // CHECK: {{^}}  func zimImplicit
  func zimImplicit(f: () -> NotObjCStruct) {}
  // CHECK: {{^}}  func zangImplicit
  func zangImplicit(f: (NotObjCEnum, NotObjCStruct) -> ()) {}
  // CHECK: {{^}}  func zangZangImplicit
  func zangZangImplicit(f: (Int...) -> ()) {}
}

typealias GoodBlock = @convention(block) (Int) -> ()
typealias BadBlock = @convention(block) (NotObjCEnum) -> () // expected-error{{'(NotObjCEnum) -> ()' is not representable in Objective-C, so it cannot be used with '@convention(block)'}}


// CHECK-LABEL: @objc class AccessControl
@objc // access-note-move{{AccessControl}}
class AccessControl {
  // CHECK: {{^}} func foo
  func foo() {}
  // CHECK: {{^}} private func bar
  private func bar() {}
  // CHECK: @objc private func baz
  @objc // access-note-move{{AccessControl.baz()}}
  private func baz() {}
}

//===--- Ban @objc +load methods
class Load1 {
  // Okay: not @objc
  class func load() { }
  class func alloc() {}
  class func allocWithZone(_: Int) {}
  class func initialize() {}
}

@objc // access-note-move{{Load2}}
class Load2 {
  class func load() { }
  class func alloc() {}
  class func allocWithZone(_: Int) {}
  class func initialize() {}
}

@objc // access-note-move{{Load3}}
class Load3 {
  class var load: Load3 {
    get { return Load3() }
    set { }
  }

  @objc(alloc) // access-note-move{{Load3.prop}}
  class var prop: Int { return 0 } // expected-error {{getter for 'prop' defines Objective-C class method 'alloc', which is not permitted by Swift}}
  @objc(allocWithZone:) // access-note-move{{Load3.fooWithZone(_:)}}
  class func fooWithZone(_: Int) {} // expected-error {{method 'fooWithZone' defines Objective-C class method 'allocWithZone:', which is not permitted by Swift}}
  @objc(initialize) // access-note-move{{Load3.barnitialize()}}
  class func barnitialize() {} // expected-error {{method 'barnitialize()' defines Objective-C class method 'initialize', which is not permitted by Swift}}
}

// Members of protocol extensions cannot be @objc

extension PlainProtocol {
  @objc // bad-access-note-move{{PlainProtocol.property}} expected-error{{@objc can only be used with members of classes, @objc protocols, and concrete extensions of classes}}
  var property: Int { return 5 }

  @objc // bad-access-note-move{{PlainProtocol.subscript(_:)}} expected-error{{@objc can only be used with members of classes, @objc protocols, and concrete extensions of classes}}
  subscript(x: Int) -> Class_ObjC1 { return Class_ObjC1() }

  @objc // bad-access-note-move{{PlainProtocol.fun()}} expected-error{{@objc can only be used with members of classes, @objc protocols, and concrete extensions of classes}}
  func fun() { }
}

extension Protocol_ObjC1 {
  @objc // bad-access-note-move{{Protocol_ObjC1.property}} expected-error{{@objc can only be used with members of classes, @objc protocols, and concrete extensions of classes}}
  var property: Int { return 5 }

  @objc // bad-access-note-move{{Protocol_ObjC1.subscript(_:)}} expected-error{{@objc can only be used with members of classes, @objc protocols, and concrete extensions of classes}}
  subscript(x: Int) -> Class_ObjC1 { return Class_ObjC1() }

  @objc // bad-access-note-move{{Protocol_ObjC1.fun()}} expected-error{{@objc can only be used with members of classes, @objc protocols, and concrete extensions of classes}}
  func fun() { }
}

// CHECK-LABEL: extension Protocol_ObjC1
extension Protocol_ObjC1 {
  // Don't infer @objc for extensions of @objc protocols.

  // CHECK: {{^}} var propertyOK: Int
  var propertyOK: Int { return 5 }
}

//===---
//===--- Error handling
//===---
// CHECK-LABEL: class ClassThrows1
class ClassThrows1 {
  // CHECK: @objc func methodReturnsVoid() throws
  @objc // access-note-move{{ClassThrows1.methodReturnsVoid()}}
  func methodReturnsVoid() throws { }

  // CHECK: @objc func methodReturnsObjCClass() throws -> Class_ObjC1
  @objc // access-note-move{{ClassThrows1.methodReturnsObjCClass()}}
  func methodReturnsObjCClass() throws -> Class_ObjC1 {
    return Class_ObjC1()
  }

  // CHECK: @objc func methodReturnsBridged() throws -> String
  @objc // access-note-move{{ClassThrows1.methodReturnsBridged()}}
  func methodReturnsBridged() throws -> String { return String() }

  // CHECK: @objc func methodReturnsArray() throws -> [String]
  @objc // access-note-move{{ClassThrows1.methodReturnsArray()}}
  func methodReturnsArray() throws -> [String] { return [String]() }

  // CHECK: @objc init(degrees: Double) throws
  @objc // access-note-move{{ClassThrows1.init(degrees:)}}
  init(degrees: Double) throws { }

  // Errors

  @objc // bad-access-note-move{{ClassThrows1.methodReturnsOptionalObjCClass()}}
  func methodReturnsOptionalObjCClass() throws -> Class_ObjC1? { return nil } // access-note-adjust{{@objc}} expected-error{{throwing method cannot be marked @objc because it returns a value of optional type 'Class_ObjC1?'; 'nil' indicates failure to Objective-C}}

  @objc // bad-access-note-move{{ClassThrows1.methodReturnsOptionalArray()}}
  func methodReturnsOptionalArray() throws -> [String]? { return nil } // access-note-adjust{{@objc}} expected-error{{throwing method cannot be marked @objc because it returns a value of optional type '[String]?'; 'nil' indicates failure to Objective-C}}

  @objc // bad-access-note-move{{ClassThrows1.methodReturnsInt()}}
  func methodReturnsInt() throws -> Int { return 0 } // access-note-adjust{{@objc}} expected-error{{throwing method cannot be marked @objc because it returns a value of type 'Int'; return 'Void' or a type that bridges to an Objective-C class}}

  @objc // bad-access-note-move{{ClassThrows1.methodAcceptsThrowingFunc(fn:)}}
  func methodAcceptsThrowingFunc(fn: (String) throws -> Int) { }
  // access-note-adjust{{@objc}} expected-error@-1{{method cannot be marked @objc because the type of the parameter cannot be represented in Objective-C}}
  // expected-note@-2{{throwing function types cannot be represented in Objective-C}}

  @objc // bad-access-note-move{{ClassThrows1.init(radians:)}}
  init?(radians: Double) throws { } // access-note-adjust{{@objc}} expected-error{{a failable and throwing initializer cannot be marked @objc because 'nil' indicates failure to Objective-C}}

  @objc // bad-access-note-move{{ClassThrows1.init(string:)}}
  init!(string: String) throws { } // access-note-adjust{{@objc}} expected-error{{a failable and throwing initializer cannot be marked @objc because 'nil' indicates failure to Objective-C}}

  @objc // bad-access-note-move{{ClassThrows1.fooWithErrorEnum1(x:)}}
  func fooWithErrorEnum1(x: ErrorEnum) {}
  // access-note-adjust{{@objc}} expected-error@-1{{method cannot be marked @objc because the type of the parameter cannot be represented in Objective-C}}
  // expected-note@-2{{non-'@objc' enums cannot be represented in Objective-C}}

  // CHECK: {{^}} func fooWithErrorEnum2(x: ErrorEnum)
  func fooWithErrorEnum2(x: ErrorEnum) {}

  @objc // bad-access-note-move{{ClassThrows1.fooWithErrorProtocolComposition1(x:)}}
  func fooWithErrorProtocolComposition1(x: Error & Protocol_ObjC1) { }
  // access-note-adjust{{@objc}} expected-error@-1{{method cannot be marked @objc because the type of the parameter cannot be represented in Objective-C}}
  // expected-note@-2{{protocol-constrained type containing 'Error' cannot be represented in Objective-C}}

  // CHECK: {{^}} func fooWithErrorProtocolComposition2(x: any Error & Protocol_ObjC1)
  func fooWithErrorProtocolComposition2(x: Error & Protocol_ObjC1) { }
}


// CHECK-LABEL: @objc class ImplicitClassThrows1
// CHECK-DUMP-LABEL: class_decl{{.*}}"ImplicitClassThrows1"
@objc // access-note-move{{ImplicitClassThrows1}}
class ImplicitClassThrows1 {
  // CHECK: {{^}} func methodReturnsVoid() throws
  // CHECK-DUMP-LABEL: func_decl{{.*}}"methodReturnsVoid()"
  // CHECK-DUMP-NOT: foreign_error_convention
  func methodReturnsVoid() throws { }

  // CHECK: {{^}} func methodReturnsObjCClass() throws -> Class_ObjC1
  // CHECK-DUMP-LABEL: func_decl{{.*}}"methodReturnsObjCClass()"
  // CHECK-DUMP-NOT: foreign_error_convention
  func methodReturnsObjCClass() throws -> Class_ObjC1 {
    return Class_ObjC1()
  }

  // CHECK: {{^}} func methodReturnsBridged() throws -> String
  func methodReturnsBridged() throws -> String { return String() }

  // CHECK: {{^}} func methodReturnsArray() throws -> [String]
  func methodReturnsArray() throws -> [String] { return [String]() }

  // CHECK: {{^}} func methodReturnsOptionalObjCClass() throws -> Class_ObjC1?
  func methodReturnsOptionalObjCClass() throws -> Class_ObjC1? { return nil }

  // CHECK: {{^}} func methodWithTrailingClosures(_ s: String, fn1: @escaping ((Int) -> Int), fn2: @escaping (Int) -> Int, fn3: @escaping (Int) -> Int)
  // CHECK-DUMP-LABEL: func_decl{{.*}}"methodWithTrailingClosures(_:fn1:fn2:fn3:)"
  // CHECK-DUMP-NOT:  foreign_error_convention
  func methodWithTrailingClosures(_ s: String, fn1: (@escaping (Int) -> Int), fn2: @escaping (Int) -> Int, fn3: @escaping (Int) -> Int) throws { }

  // CHECK: {{^}} init(degrees: Double) throws
  // CHECK-DUMP-LABEL: constructor_decl{{.*}}"init(degrees:)"
  // CHECK-DUMP-NOT:  foreign_error_convention
  init(degrees: Double) throws { }

  // CHECK: {{^}} func methodReturnsBridgedValueType() throws -> NSRange
  func methodReturnsBridgedValueType() throws -> NSRange { return NSRange() }

  @objc // bad-access-note-move{{ImplicitClassThrows1.methodReturnsBridgedValueType2()}}
  func methodReturnsBridgedValueType2() throws -> NSRange {
    return NSRange()
  }
  // access-note-adjust{{@objc}} expected-error@-3{{throwing method cannot be marked @objc because it returns a value of type 'NSRange' (aka '_NSRange'); return 'Void' or a type that bridges to an Objective-C class}}

  // CHECK: {{^}} func methodReturnsError() throws -> any Error
  func methodReturnsError() throws -> Error { return ErrorEnum.failed }

  // CHECK: {{^}} func methodReturnStaticBridged() throws -> ((Int) -> (Int) -> Int)
  func methodReturnStaticBridged() throws -> ((Int) -> (Int) -> Int) {
    func add(x: Int) -> (Int) -> Int { 
      return { x + $0 }
    }
  }
}

// CHECK-LABEL: @objc class SubclassImplicitClassThrows1
// CHECK-DUMP-LABEL: class_decl{{.*}}"SubclassImplicitClassThrows1"
@objc // access-note-move{{SubclassImplicitClassThrows1}}
class SubclassImplicitClassThrows1 : ImplicitClassThrows1 {
  // CHECK: {{^}} override func methodWithTrailingClosures(_ s: String, fn1: @escaping ((Int) -> Int), fn2: @escaping ((Int) -> Int), fn3: @escaping ((Int) -> Int))
  // CHECK-DUMP-LABEL: func_decl{{.*}}"methodWithTrailingClosures(_:fn1:fn2:fn3:)"
  // CHECK-DUMP: (foreign_error_convention kind=ZeroResult unowned param=1 paramtype="Optional<AutoreleasingUnsafeMutablePointer<Optional<NSError>>>" resulttype="ObjCBool")
  override func methodWithTrailingClosures(_ s: String, fn1: (@escaping (Int) -> Int), fn2: (@escaping (Int) -> Int), fn3: (@escaping (Int) -> Int)) throws { }
}

class ThrowsRedecl1 {
  @objc // access-note-move{{ThrowsRedecl1.method1(_:error:)}}
  func method1(_ x: Int, error: Class_ObjC1) { } // expected-note{{declared here}}
  @objc // bad-access-note-move{{ThrowsRedecl1.method1(_:)}}
  func method1(_ x: Int) throws { } // access-note-adjust{{@objc}} expected-error {{method 'method1' with Objective-C selector 'method1:error:' conflicts with method 'method1(_:error:)' with the same Objective-C selector}}

  @objc // access-note-move{{ThrowsRedecl1.method2AndReturnError(_:)}}
  func method2AndReturnError(_ x: Int) { } // expected-note{{declared here}}
  @objc // bad-access-note-move{{ThrowsRedecl1.method2()}}
  func method2() throws { } // access-note-adjust{{@objc}} expected-error {{method 'method2()' with Objective-C selector 'method2AndReturnError:' conflicts with method 'method2AndReturnError' with the same Objective-C selector}}

  @objc // access-note-move{{ThrowsRedecl1.method3(_:error:closure:)}}
  func method3(_ x: Int, error: Int, closure: @escaping (Int) -> Int) { }  // expected-note{{declared here}}
  @objc // bad-access-note-move{{ThrowsRedecl1.method3(_:closure:)}}
  func method3(_ x: Int, closure: (Int) -> Int) throws { } // access-note-adjust{{@objc}} expected-error {{method 'method3(_:closure:)' with Objective-C selector 'method3:error:closure:' conflicts with method 'method3(_:error:closure:)' with the same Objective-C selector}}

  @objc(initAndReturnError:) // access-note-move{{ThrowsRedecl1.initMethod1(error:)}}
  func initMethod1(error: Int) { } // expected-note{{declared here}}
  @objc // bad-access-note-move{{ThrowsRedecl1.init()}}
  init() throws { } // access-note-adjust{{@objc}} expected-error {{initializer 'init()' with Objective-C selector 'initAndReturnError:' conflicts with method 'initMethod1(error:)' with the same Objective-C selector}}

  @objc(initWithString:error:) // access-note-move{{ThrowsRedecl1.initMethod2(string:error:)}}
  func initMethod2(string: String, error: Int) { } // expected-note{{declared here}}
  @objc // bad-access-note-move{{ThrowsRedecl1.init(string:)}}
  init(string: String) throws { } // access-note-adjust{{@objc}} expected-error {{initializer 'init(string:)' with Objective-C selector 'initWithString:error:' conflicts with method 'initMethod2(string:error:)' with the same Objective-C selector}}

  @objc(initAndReturnError:fn:) // access-note-move{{ThrowsRedecl1.initMethod3(error:fn:)}}
  func initMethod3(error: Int, fn: @escaping (Int) -> Int) { } // expected-note{{declared here}}
  @objc // bad-access-note-move{{ThrowsRedecl1.init(fn:)}}
  init(fn: (Int) -> Int) throws { } // access-note-adjust{{@objc}} expected-error {{initializer 'init(fn:)' with Objective-C selector 'initAndReturnError:fn:' conflicts with method 'initMethod3(error:fn:)' with the same Objective-C selector}}
}

class ThrowsObjCName {
  @objc(method4:closure:error:) // access-note-move{{ThrowsObjCName.method4(x:closure:)}}
  func method4(x: Int, closure: @escaping (Int) -> Int) throws { }

  @objc(method5AndReturnError:x:closure:) // access-note-move{{ThrowsObjCName.method5(x:closure:)}}
  func method5(x: Int, closure: @escaping (Int) -> Int) throws { }

  @objc(method6) // bad-access-note-move{{ThrowsObjCName.method6()}} expected-error{{'@objc' method name provides names for 0 arguments, but method has one parameter (the error parameter)}}
  func method6() throws { }

  @objc(method7) // bad-access-note-move{{ThrowsObjCName.method7(x:)}} expected-error{{'@objc' method name provides names for 0 arguments, but method has 2 parameters (including the error parameter)}}
  func method7(x: Int) throws { }

  // CHECK-DUMP-LABEL: func_decl{{.*}}"method8(_:fn1:fn2:)"
  // CHECK-DUMP:  (foreign_error_convention kind=ZeroResult unowned param=2 paramtype="Optional<AutoreleasingUnsafeMutablePointer<Optional<NSError>>>" resulttype="ObjCBool")
  @objc(method8:fn1:error:fn2:) // access-note-move{{ThrowsObjCName.method8(_:fn1:fn2:)}}
  func method8(_ s: String, fn1: (@escaping (Int) -> Int), fn2: @escaping (Int) -> Int) throws { }

  // CHECK-DUMP-LABEL: func_decl{{.*}}"method9(_:fn1:fn2:)"
  // CHECK-DUMP:  (foreign_error_convention kind=ZeroResult unowned param=0 paramtype="Optional<AutoreleasingUnsafeMutablePointer<Optional<NSError>>>" resulttype="ObjCBool")
  @objc(method9AndReturnError:s:fn1:fn2:) // access-note-move{{ThrowsObjCName.method9(_:fn1:fn2:)}}
  func method9(_ s: String, fn1: (@escaping (Int) -> Int), fn2: @escaping (Int) -> Int) throws { }
}

class SubclassThrowsObjCName : ThrowsObjCName {
  // CHECK-DUMP-LABEL: func_decl{{.*}}"method8(_:fn1:fn2:)"
  // CHECK-DUMP:  (foreign_error_convention kind=ZeroResult unowned param=2 paramtype="Optional<AutoreleasingUnsafeMutablePointer<Optional<NSError>>>" resulttype="ObjCBool")
  override func method8(_ s: String, fn1: (@escaping (Int) -> Int), fn2: @escaping (Int) -> Int) throws { }

  // CHECK-DUMP-LABEL: func_decl{{.*}}"method9(_:fn1:fn2:)"
  // CHECK-DUMP:  (foreign_error_convention kind=ZeroResult unowned param=0 paramtype="Optional<AutoreleasingUnsafeMutablePointer<Optional<NSError>>>" resulttype="ObjCBool")
  override func method9(_ s: String, fn1: (@escaping (Int) -> Int), fn2: @escaping (Int) -> Int) throws { }
}

@objc // access-note-move{{ProtocolThrowsObjCName}}
protocol ProtocolThrowsObjCName {
  @objc // Access notes don't allow the `optional` keyword, that's fine, honestly.
  optional func doThing(_ x: String) throws -> String // expected-note{{requirement 'doThing' declared here}}
}

class ConformsToProtocolThrowsObjCName1 : ProtocolThrowsObjCName {
  @objc // bad-access-note-move{{ConformsToProtocolThrowsObjCName1.doThing(_:)}} -- @objc inherited, so no remarks
  func doThing(_ x: String) throws -> String { return x } // okay
}

class ConformsToProtocolThrowsObjCName2 : ProtocolThrowsObjCName {
  @objc // access-note-move{{ConformsToProtocolThrowsObjCName2.doThing(_:)}}
  func doThing(_ x: Int) throws -> String { return "" }
  // expected-warning@-1{{instance method 'doThing' nearly matches optional requirement 'doThing' of protocol 'ProtocolThrowsObjCName'}}
  // expected-note@-2{{move 'doThing' to an extension to silence this warning}}
  // expected-note@-3{{make 'doThing' private to silence this warning}}{{3-3=private }}
  // expected-note@-4{{candidate has non-matching type '(Int) throws -> String'}}
}

// CHECK-LABEL: @objc class DictionaryTest
@objc // access-note-move{{DictionaryTest}}
class DictionaryTest {
  // CHECK-LABEL: {{^}} func func_dictionary1a(x: Dictionary<ObjC_Class1, ObjC_Class1>)
  func func_dictionary1a(x: Dictionary<ObjC_Class1, ObjC_Class1>) { }

  // CHECK-LABEL: {{^}} @objc func func_dictionary1b(x: Dictionary<ObjC_Class1, ObjC_Class1>)
  @objc // access-note-move{{DictionaryTest.func_dictionary1b(x:)}}
  func func_dictionary1b(x: Dictionary<ObjC_Class1, ObjC_Class1>) { }

  func func_dictionary2a(x: Dictionary<String, Int>) { }
  @objc // access-note-move{{DictionaryTest.func_dictionary2b(x:)}}
  func func_dictionary2b(x: Dictionary<String, Int>) { }
}

@objc
extension PlainClass {
  // CHECK-LABEL: @objc final func objc_ext_objc_okay(_: Int) {
  final func objc_ext_objc_okay(_: Int) { }

  final func objc_ext_objc_not_okay(_: PlainStruct) { }
  // expected-error@-1{{method cannot be in an @objc extension of a class (without @nonobjc) because the type of the parameter cannot be represented in Objective-C}}
  // expected-note@-2 {{Swift structs cannot be represented in Objective-C}}

  // CHECK-LABEL: {{^}} @nonobjc final func objc_ext_objc_explicit_nonobjc(_: PlainStruct) {
  @nonobjc final func objc_ext_objc_explicit_nonobjc(_: PlainStruct) { }
}

@objc // access-note-move{{ObjC_Class1}}
class ObjC_Class1 : Hashable {
  func hash(into hasher: inout Hasher) {}
}

func ==(lhs: ObjC_Class1, rhs: ObjC_Class1) -> Bool {
  return true
}

// CHECK-LABEL: @objc class OperatorInClass
@objc // access-note-move{{OperatorInClass}}
class OperatorInClass {
  // CHECK: {{^}} static func == (lhs: OperatorInClass, rhs: OperatorInClass) -> Bool
  static func ==(lhs: OperatorInClass, rhs: OperatorInClass) -> Bool {
    return true
  }
  // CHECK: {{^}} @objc static func + (lhs: OperatorInClass, rhs: OperatorInClass) -> OperatorInClass
  @objc
  static func +(lhs: OperatorInClass, rhs: OperatorInClass) -> OperatorInClass { // expected-error {{operator methods cannot be declared @objc}}
    return lhs
  }
} // CHECK: {{^}$}}

@objc // access-note-move{{OperatorInProtocol}}
protocol OperatorInProtocol {
  static func +(lhs: Self, rhs: Self) -> Self // expected-error {{@objc protocols must not have operator requirements}}
}

class AdoptsOperatorInProtocol : OperatorInProtocol {
  static func +(lhs: AdoptsOperatorInProtocol, rhs: AdoptsOperatorInProtocol) -> Self {}
  // expected-error@-1 {{operator methods cannot be declared @objc}}
}

//===--- @objc inference for witnesses

@objc // access-note-move{{InferFromProtocol}}
protocol InferFromProtocol {
  @objc(inferFromProtoMethod1:)
  optional func method1(value: Int)
}

// Infer when in the same declaration context.
// CHECK-LABEL: ClassInfersFromProtocol1
class ClassInfersFromProtocol1 : InferFromProtocol{
  // CHECK: {{^}} @objc func method1(value: Int)
  func method1(value: Int) { }
}

// Infer when in a different declaration context of the same class.
// CHECK-LABEL: ClassInfersFromProtocol2a
class ClassInfersFromProtocol2a {
  // CHECK: {{^}} @objc func method1(value: Int)
  func method1(value: Int) { }
}

extension ClassInfersFromProtocol2a : InferFromProtocol { }

// Infer when in a different declaration context of the same class.
class ClassInfersFromProtocol2b : InferFromProtocol { }

// CHECK-LABEL: ClassInfersFromProtocol2b
extension ClassInfersFromProtocol2b {
  // CHECK: {{^}} @objc dynamic func method1(value: Int)
  func method1(value: Int) { }
}

// Don't infer when there is a signature mismatch.
// CHECK-LABEL: ClassInfersFromProtocol3
class ClassInfersFromProtocol3 : InferFromProtocol {
}

extension ClassInfersFromProtocol3 {
  // CHECK: {{^}} func method1(value: String)
  func method1(value: String) { }
}

// Inference for subclasses.
class SuperclassImplementsProtocol : InferFromProtocol { }

class SubclassInfersFromProtocol1 : SuperclassImplementsProtocol {
  // CHECK: {{^}} @objc func method1(value: Int)
  func method1(value: Int) { }
}

class SubclassInfersFromProtocol2 : SuperclassImplementsProtocol {
}

extension SubclassInfersFromProtocol2 {
  // CHECK: {{^}} @objc dynamic func method1(value: Int)
  func method1(value: Int) { }
}

@objc // access-note-move{{NeverReturningMethod}}
class NeverReturningMethod {
  @objc // access-note-move{{NeverReturningMethod.doesNotReturn()}}
  func doesNotReturn() -> Never {}
}

// https://github.com/apple/swift/issues/47601
class User: NSObject {
}

@objc
extension User {
	var name: String {
		get {
			return "No name"
		}
		set {
			// Nothing
		}
	}

	var other: String {
    unsafeAddress { // expected-error {{addressors are not allowed to be marked @objc}}
    }
  }
}

// 'dynamic' methods cannot be @inlinable.
class BadClass {
  @objc // access-note-move{{BadClass.badMethod1()}}
  @inlinable dynamic func badMethod1() {}
  // expected-error@-1 {{'@inlinable' attribute cannot be applied to 'dynamic' declarations}}
}

@objc // access-note-move{{ObjCProtocolWithWeakProperty}}
protocol ObjCProtocolWithWeakProperty {
   weak var weakProp: AnyObject? { get set } // okay
}

@objc // access-note-move{{ObjCProtocolWithUnownedProperty}}
protocol ObjCProtocolWithUnownedProperty {
   unowned var unownedProp: AnyObject { get set } // okay
}

// rdar://problem/46699152: errors about read/modify accessors being implicitly
// marked @objc.
@objc // access-note-move{{MyObjCClass}}
class MyObjCClass: NSObject {}

@objc
extension MyObjCClass {
    @objc // access-note-move{{MyObjCClass.objCVarInObjCExtension}}
    static var objCVarInObjCExtension: Bool {
        get {
            return true
        }
        set {}
    }

    // CHECK: {{^}} @objc private dynamic func stillExposedToObjCDespiteBeingPrivate()
    private func stillExposedToObjCDespiteBeingPrivate() {}
}

@objc
private extension MyObjCClass {
  // CHECK: {{^}} @objc dynamic func alsoExposedToObjCDespiteBeingPrivate()
  func alsoExposedToObjCDespiteBeingPrivate() {}
}

@objcMembers class VeryObjCClass: NSObject {
  // CHECK: {{^}} private func notExposedToObjC()
  private func notExposedToObjC() {}
}

// https://github.com/apple/swift/issues/51538

class issue51538_C {}

@objc // access-note-move{{issue51538_P}}
protocol issue51538_P {
  func throwingMethod1() throws -> Unmanaged<CFArray> // Ok
  func throwingMethod2() throws -> Unmanaged<issue51538_C> // expected-error {{method cannot be a member of an @objc protocol because its result type cannot be represented in Objective-C}}
  // expected-note@-1 {{inferring '@objc' because the declaration is a member of an '@objc' protocol}}
  // expected-note@-2 {{Swift structs cannot be represented in Objective-C}}
}

// https://github.com/apple/swift/issues/55246
// Make sure we reject an @objc generic subscript.
class issue55246 {
  @objc // bad-access-note-move{{issue55246.subscript(_:)}}
  subscript<T>(foo : [T]) -> Int { return 0 }
  // access-note-adjust{{@objc}} expected-error@-1 {{subscript cannot be marked @objc because it has generic parameters}}
}

// @backDeployed

public class BackDeployClass {
  @backDeployed(before: macOS 12.0) // expected-error {{'@backDeployed' must not be used on an '@objc' instance method}}
  @objc
  final public func objcMethod() {}
}