@@ -1521,9 +1521,14 @@ final class RecoveryTests: XCTestCase {
1521
1521
class WrongInheritanceClause11️⃣(Int) {}
1522
1522
""" ,
1523
1523
diagnostics: [
1524
- // TODO: Old parser expected error on line 1: expected ':' to begin inheritance clause, Fix-It replacements: 30 - 31 = ': ', 34 - 35 = ''
1525
- DiagnosticSpec ( message: " unexpected code '(Int)' in class " )
1526
- ]
1524
+ DiagnosticSpec (
1525
+ message: " expected ':' to begin inheritance clause " ,
1526
+ fixIts: [ " replace '()' with ':' " ]
1527
+ )
1528
+ ] ,
1529
+ fixedSource: """
1530
+ class WrongInheritanceClause1: Int {}
1531
+ """
1527
1532
)
1528
1533
}
1529
1534
@@ -1533,9 +1538,14 @@ final class RecoveryTests: XCTestCase {
1533
1538
class WrongInheritanceClause21️⃣(Base2<Int>) {}
1534
1539
""" ,
1535
1540
diagnostics: [
1536
- // TODO: Old parser expected error on line 1: expected ':' to begin inheritance clause, Fix-It replacements: 30 - 31 = ': ', 41 - 42 = ''
1537
- DiagnosticSpec ( message: " unexpected code '(Base2<Int>)' in class " )
1538
- ]
1541
+ DiagnosticSpec (
1542
+ message: " expected ':' to begin inheritance clause " ,
1543
+ fixIts: [ " replace '()' with ':' " ]
1544
+ )
1545
+ ] ,
1546
+ fixedSource: """
1547
+ class WrongInheritanceClause2: Base2<Int>{}
1548
+ """
1539
1549
)
1540
1550
}
1541
1551
@@ -1545,9 +1555,14 @@ final class RecoveryTests: XCTestCase {
1545
1555
class WrongInheritanceClause3<T>1️⃣(SubModule.Base1) where T:AnyObject {}
1546
1556
""" ,
1547
1557
diagnostics: [
1548
- // TODO: Old parser expected error on line 1: expected ':' to begin inheritance clause, Fix-It replacements: 33 - 34 = ': ', 49 - 50 = ''
1549
- DiagnosticSpec ( message: " unexpected code '(SubModule.Base1) where T:AnyObject' in class " )
1550
- ]
1558
+ DiagnosticSpec (
1559
+ message: " expected ':' to begin inheritance clause " ,
1560
+ fixIts: [ " replace '()' with ':' " ]
1561
+ )
1562
+ ] ,
1563
+ fixedSource: """
1564
+ class WrongInheritanceClause3<T>: SubModule.Base1 where T:AnyObject {}
1565
+ """
1551
1566
)
1552
1567
}
1553
1568
@@ -1557,9 +1572,14 @@ final class RecoveryTests: XCTestCase {
1557
1572
class WrongInheritanceClause41️⃣(SubModule.Base2<Int>) {}
1558
1573
""" ,
1559
1574
diagnostics: [
1560
- // TODO: Old parser expected error on line 1: expected ':' to begin inheritance clause, Fix-It replacements: 30 - 31 = ': ', 51 - 52 = ''
1561
- DiagnosticSpec ( message: " unexpected code '(SubModule.Base2<Int>)' in class " )
1562
- ]
1575
+ DiagnosticSpec (
1576
+ message: " expected ':' to begin inheritance clause " ,
1577
+ fixIts: [ " replace '()' with ':' " ]
1578
+ )
1579
+ ] ,
1580
+ fixedSource: """
1581
+ class WrongInheritanceClause4: SubModule.Base2<Int>{}
1582
+ """
1563
1583
)
1564
1584
}
1565
1585
@@ -1569,47 +1589,55 @@ final class RecoveryTests: XCTestCase {
1569
1589
class WrongInheritanceClause5<T>1️⃣(SubModule.Base2<Int>) where T:AnyObject {}
1570
1590
""" ,
1571
1591
diagnostics: [
1572
- // TODO: Old parser expected error on line 1: expected ':' to begin inheritance clause, Fix-It replacements: 33 - 34 = ': ', 54 - 55 = ''
1573
- DiagnosticSpec ( message: " unexpected code '(SubModule.Base2<Int>) where T:AnyObject' in class " )
1574
- ]
1592
+ DiagnosticSpec (
1593
+ message: " expected ':' to begin inheritance clause " ,
1594
+ fixIts: [ " replace '()' with ':' " ]
1595
+ )
1596
+ ] ,
1597
+ fixedSource: """
1598
+ class WrongInheritanceClause5<T>: SubModule.Base2<Int>where T:AnyObject {}
1599
+ """
1575
1600
)
1576
1601
}
1577
1602
1578
1603
func testRecovery130( ) {
1579
1604
assertParse (
1580
1605
"""
1581
- class WrongInheritanceClause61️⃣(Int 2️⃣{}3️⃣
1606
+ class WrongInheritanceClause61️⃣(Int {}
1582
1607
""" ,
1583
1608
diagnostics: [
1584
- // TODO: Old parser expected error on line 1: expected ':' to begin inheritance clause, Fix-It replacements: 30 - 31 = ': '
1585
- DiagnosticSpec ( locationMarker: " 1️⃣ " , message: " expected '{' in class " , fixIts: [ " insert '{' " ] ) ,
1586
- DiagnosticSpec ( locationMarker: " 1️⃣ " , message: " expected 'var' in variable " , fixIts: [ " insert 'var' " ] ) ,
1587
- DiagnosticSpec ( locationMarker: " 2️⃣ " , message: " expected ')' to end tuple pattern " , fixIts: [ " insert ')' " ] ) ,
1588
- DiagnosticSpec ( locationMarker: " 3️⃣ " , message: " expected '}' to end class " , fixIts: [ " insert '}' " ] ) ,
1589
- ]
1609
+ DiagnosticSpec (
1610
+ message: " expected ':' to begin inheritance clause " ,
1611
+ fixIts: [ " replace '(' with ':' " ]
1612
+ )
1613
+ ] ,
1614
+ fixedSource: """
1615
+ class WrongInheritanceClause6: Int {}
1616
+ """
1590
1617
)
1591
1618
}
1592
1619
1593
1620
func testRecovery131( ) {
1594
1621
assertParse (
1595
1622
"""
1596
- class WrongInheritanceClause7<T>1️⃣(Int 2️⃣where T:AnyObject {}
1623
+ class WrongInheritanceClause7<T>1️⃣(Int where T:AnyObject {}
1597
1624
""" ,
1598
1625
diagnostics: [
1599
- // TODO: Old parser expected error on line 1: expected ':' to begin inheritance clause, Fix-It replacements: 33 - 34 = ': '
1600
- DiagnosticSpec ( locationMarker: " 1️⃣ " , message: " expected '{' in class " , fixIts: [ " insert '{' " ] ) ,
1601
- DiagnosticSpec ( locationMarker: " 1️⃣ " , message: " expected 'var' in variable " , fixIts: [ " insert 'var' " ] ) ,
1602
- DiagnosticSpec ( locationMarker: " 2️⃣ " , message: " expected ')' to end tuple pattern " , fixIts: [ " insert ')' " ] ) ,
1603
- DiagnosticSpec ( locationMarker: " 2️⃣ " , message: " expected '}' to end class " , fixIts: [ " insert '}' " ] ) ,
1604
- DiagnosticSpec ( locationMarker: " 2️⃣ " , message: " extraneous code 'where T:AnyObject {}' at top level " ) ,
1605
- ]
1626
+ DiagnosticSpec (
1627
+ message: " expected ':' to begin inheritance clause " ,
1628
+ fixIts: [ " replace '(' with ':' " ]
1629
+ )
1630
+ ] ,
1631
+ fixedSource: """
1632
+ class WrongInheritanceClause7<T>: Int where T:AnyObject {}
1633
+ """
1606
1634
)
1607
1635
}
1608
1636
1609
1637
func testRecovery132( ) {
1638
+ // <rdar://problem/18502220> [swift-crashes 078] parser crash on invalid cast in sequence expr
1610
1639
assertParse (
1611
1640
"""
1612
- // <rdar://problem/18502220> [swift-crashes 078] parser crash on invalid cast in sequence expr
1613
1641
Base=1 as Base=1
1614
1642
"""
1615
1643
)
0 commit comments