@@ -1491,6 +1491,123 @@ public void testProtectedAccessForProperties16() {
1491
1491
"}" )));
1492
1492
}
1493
1493
1494
+ @ Test
1495
+ public void testProtectedAccessForProperties17 () {
1496
+ // Access in subclass field initializer where Subclass parent is SCRIPT.
1497
+ test (
1498
+ srcs (
1499
+ """
1500
+ class SuperClass {
1501
+ /** @protected @return {number} */
1502
+ getNum() { return 1; }
1503
+ }
1504
+ """ ,
1505
+ """
1506
+ class Subclass extends SuperClass {
1507
+ numField = this.getNum();
1508
+ }
1509
+ """ ));
1510
+ }
1511
+
1512
+ @ Test
1513
+ public void testProtectedAccessForProperties18 () {
1514
+ // Access in subclass field initializer where Subclass parent is BLOCK.
1515
+ test (
1516
+ srcs (
1517
+ """
1518
+ class SuperClass {
1519
+ /** @protected @return {number} */
1520
+ getNum() { return 1; }
1521
+ }
1522
+ """ ,
1523
+ """
1524
+ {
1525
+ class Subclass extends SuperClass {
1526
+ numField = this.getNum();
1527
+ }
1528
+ }
1529
+ """ ));
1530
+ }
1531
+
1532
+ @ Test
1533
+ public void testProtectedAccessForProperties19 () {
1534
+ // Access in subclass field initializer where class parent is ASSIGN.
1535
+ test (
1536
+ srcs (
1537
+ """
1538
+ class SuperClass {
1539
+ /** @protected @return {number} */
1540
+ getNum() { return 1; }
1541
+ }
1542
+ """ ,
1543
+ """
1544
+ const Subclass = class extends SuperClass {
1545
+ numField = this.getNum();
1546
+ }
1547
+ """ ));
1548
+ }
1549
+
1550
+ @ Test
1551
+ public void testProtectedAccessForProperties20 () {
1552
+ // Access in subclass field initializer where class parent is FUNCTION.
1553
+ test (
1554
+ srcs (
1555
+ """
1556
+ class SuperClass {
1557
+ /** @protected @return {number} */
1558
+ getNum() { return 1; }
1559
+ }
1560
+ """ ,
1561
+ """
1562
+ const Subclass = (() => class extends SuperClass {
1563
+ numField = this.getNum();
1564
+ })();
1565
+ """ ));
1566
+ }
1567
+
1568
+ @ Test
1569
+ public void testProtectedAccessForProperties21 () {
1570
+ // Access in subclass field initializer where class parent is RETURN.
1571
+ test (
1572
+ srcs (
1573
+ """
1574
+ class SuperClass {
1575
+ /** @protected @return {number} */
1576
+ getNum() { return 1; }
1577
+ }
1578
+ """ ,
1579
+ """
1580
+ function classGenerator() {
1581
+ return class extends SuperClass {
1582
+ numField = this.getNum();
1583
+ };
1584
+ }
1585
+ const Subclass = classGenerator();
1586
+ """ ));
1587
+ }
1588
+
1589
+ @ Test
1590
+ public void testProtectedAccessForProperties22 () {
1591
+ // Access in subclass field initializer where class parent is GETPROP.
1592
+ test (
1593
+ srcs (
1594
+ """
1595
+ class SuperClass {
1596
+ /** @protected @return {number} */
1597
+ getNum() { return 1; }
1598
+ }
1599
+ """ ,
1600
+ """
1601
+ function getValue() {
1602
+ return class extends SuperClass {
1603
+ numField = this.getNum();
1604
+ static staticField = 1;
1605
+ }.staticField;
1606
+ }
1607
+ const value = getValue();
1608
+ """ ));
1609
+ }
1610
+
1494
1611
@ Test
1495
1612
public void testProtectedPropAccess_inDifferentFile_inSubclass_throughDestructuring () {
1496
1613
test (
0 commit comments