Bug 1611777 - Part 11: Support optional chaining in class heritage expression. r=yulia
authorAndré Bargull <andre.bargull@gmail.com>
Wed, 29 Jan 2020 16:29:15 +0000
changeset 512102 468ff3d2cf8e3e6e5eac3a79285cc9e53f7e2f22
parent 512101 e82fbc9dee634c29797c5019b12c2c1ebea3eba1
child 512103 849b4d84f74365b7202bf923423335967e07712e
push id37072
push usercsabou@mozilla.com
push dateThu, 30 Jan 2020 15:44:43 +0000
treeherdermozilla-central@f97c48da9cee [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersyulia
bugs1611777
milestone74.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1611777 - Part 11: Support optional chaining in class heritage expression. r=yulia Differential Revision: https://phabricator.services.mozilla.com/D61158
js/src/frontend/Parser.cpp
js/src/tests/non262/expressions/optional-chain-class-heritage.js
--- a/js/src/frontend/Parser.cpp
+++ b/js/src/frontend/Parser.cpp
@@ -7290,17 +7290,17 @@ GeneralParser<ParseHandler, Unit>::class
       return null();
     }
     HasHeritage hasHeritage =
         hasHeritageBool ? HasHeritage::Yes : HasHeritage::No;
     if (hasHeritage == HasHeritage::Yes) {
       if (!tokenStream.getToken(&tt)) {
         return null();
       }
-      classHeritage = memberExpr(yieldHandling, TripledotProhibited, tt);
+      classHeritage = optionalExpr(yieldHandling, TripledotProhibited, tt);
       if (!classHeritage) {
         return null();
       }
     }
 
     if (!mustMatchToken(TokenKind::LeftCurly, JSMSG_CURLY_BEFORE_CLASS)) {
       return null();
     }
new file mode 100644
--- /dev/null
+++ b/js/src/tests/non262/expressions/optional-chain-class-heritage.js
@@ -0,0 +1,10 @@
+// Optional expression can be part of a class heritage expression.
+
+var a = {b: null};
+
+class C extends a?.b {}
+
+assertEq(Object.getPrototypeOf(C.prototype), null);
+
+if (typeof reportCompare === "function")
+  reportCompare(true, true);