Bug 1562008. Update the grammar for IDL union types to exclude Promise types. r=peterv
authorBoris Zbarsky <bzbarsky@mit.edu>
Tue, 02 Jul 2019 22:17:40 +0000
changeset 543873 eec541e479b2d0380374191b6fdd83bb5a6765a5
parent 543872 a77d24d3de6401fc7f226540fd7ccb56570a58c5
child 543874 999f86ddfd50c7bfcc1122716c80cefa5c0ce92c
push id2131
push userffxbld-merge
push dateMon, 26 Aug 2019 18:30:20 +0000
treeherdermozilla-release@b19ffb3ca153 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspeterv
bugs1562008
milestone69.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 1562008. Update the grammar for IDL union types to exclude Promise types. r=peterv Differential Revision: https://phabricator.services.mozilla.com/D36238
dom/bindings/parser/WebIDL.py
--- a/dom/bindings/parser/WebIDL.py
+++ b/dom/bindings/parser/WebIDL.py
@@ -6665,39 +6665,47 @@ class Parser(Tokenizer):
         p[0] = self.handleNullable(p[1], p[2])
 
     def p_TypeWithExtendedAttributes(self, p):
         """
             TypeWithExtendedAttributes : ExtendedAttributeList Type
         """
         p[0] = p[2].withExtendedAttributes(p[1])
 
-    def p_SingleTypeNonAnyType(self, p):
-        """
-            SingleType : NonAnyType
+    def p_SingleTypeDistinguishableType(self, p):
+        """
+            SingleType : DistinguishableType
         """
         p[0] = p[1]
 
     def p_SingleTypeAnyType(self, p):
         """
             SingleType : ANY
         """
         p[0] = BuiltinTypes[IDLBuiltinType.Types.any]
 
+    # Note: Promise<void> is allowed, so we want to parametrize on ReturnType,
+    # not Type.  Promise types can't be null, hence no "Null" in there.
+    def p_SingleTypePromiseType(self, p):
+        """
+            SingleType : PROMISE LT ReturnType GT
+        """
+        p[0] = IDLPromiseType(self.getLocation(p, 1), p[3])
+
     def p_UnionType(self, p):
         """
             UnionType : LPAREN UnionMemberType OR UnionMemberType UnionMemberTypes RPAREN
         """
         types = [p[2], p[4]]
         types.extend(p[5])
         p[0] = IDLUnionType(self.getLocation(p, 1), types)
 
-    def p_UnionMemberTypeNonAnyType(self, p):
-        """
-            UnionMemberType : ExtendedAttributeList NonAnyType
+    def p_UnionMemberTypeDistinguishableType(self, p):
+        """
+            UnionMemberType : ExtendedAttributeList DistinguishableType
         """
         p[0] = p[2].withExtendedAttributes(p[1])
 
     def p_UnionMemberType(self, p):
         """
             UnionMemberType : UnionType Null
         """
         p[0] = self.handleNullable(p[1], p[2])
@@ -6710,71 +6718,63 @@ class Parser(Tokenizer):
         p[0].extend(p[3])
 
     def p_UnionMemberTypesEmpty(self, p):
         """
             UnionMemberTypes :
         """
         p[0] = []
 
-    def p_NonAnyType(self, p):
-        """
-            NonAnyType : PrimitiveType Null
-                       | ARRAYBUFFER Null
-                       | SHAREDARRAYBUFFER Null
-                       | READABLESTREAM Null
-                       | OBJECT Null
+    def p_DistinguishableType(self, p):
+        """
+            DistinguishableType : PrimitiveType Null
+                                | ARRAYBUFFER Null
+                                | SHAREDARRAYBUFFER Null
+                                | READABLESTREAM Null
+                                | OBJECT Null
         """
         if p[1] == "object":
             type = BuiltinTypes[IDLBuiltinType.Types.object]
         elif p[1] == "ArrayBuffer":
             type = BuiltinTypes[IDLBuiltinType.Types.ArrayBuffer]
         elif p[1] == "SharedArrayBuffer":
             type = BuiltinTypes[IDLBuiltinType.Types.SharedArrayBuffer]
         elif p[1] == "ReadableStream":
             type = BuiltinTypes[IDLBuiltinType.Types.ReadableStream]
         else:
             type = BuiltinTypes[p[1]]
 
         p[0] = self.handleNullable(type, p[2])
 
-    def p_NonAnyTypeStringType(self, p):
-        """
-            NonAnyType : StringType Null
+    def p_DistinguishableTypeStringType(self, p):
+        """
+            DistinguishableType : StringType Null
         """
         p[0] = self.handleNullable(p[1], p[2])
 
-    def p_NonAnyTypeSequenceType(self, p):
-        """
-            NonAnyType : SEQUENCE LT TypeWithExtendedAttributes GT Null
+    def p_DistinguishableTypeSequenceType(self, p):
+        """
+            DistinguishableType : SEQUENCE LT TypeWithExtendedAttributes GT Null
         """
         innerType = p[3]
         type = IDLSequenceType(self.getLocation(p, 1), innerType)
         p[0] = self.handleNullable(type, p[5])
 
-    # Note: Promise<void> is allowed, so we want to parametrize on ReturnType,
-    # not Type.  Promise types can't be null, hence no "Null" in there.
-    def p_NonAnyTypePromiseType(self, p):
-        """
-            NonAnyType : PROMISE LT ReturnType GT
-        """
-        p[0] = IDLPromiseType(self.getLocation(p, 1), p[3])
-
-    def p_NonAnyTypeRecordType(self, p):
-        """
-            NonAnyType : RECORD LT StringType COMMA TypeWithExtendedAttributes GT Null
+    def p_DistinguishableTypeRecordType(self, p):
+        """
+            DistinguishableType : RECORD LT StringType COMMA TypeWithExtendedAttributes GT Null
         """
         keyType = p[3]
         valueType = p[5]
         type = IDLRecordType(self.getLocation(p, 1), keyType, valueType)
         p[0] = self.handleNullable(type, p[7])
 
-    def p_NonAnyTypeScopedName(self, p):
-        """
-            NonAnyType : ScopedName Null
+    def p_DistinguishableTypeScopedName(self, p):
+        """
+            DistinguishableType : ScopedName Null
         """
         assert isinstance(p[1], IDLUnresolvedIdentifier)
 
         if p[1].name == "Promise":
             raise WebIDLError("Promise used without saying what it's "
                               "parametrized over",
                               [self.getLocation(p, 1)])
 
@@ -6794,19 +6794,19 @@ class Parser(Tokenizer):
                 p[0] = self.handleNullable(type, p[2])
                 return
         except:
             pass
 
         type = IDLUnresolvedType(self.getLocation(p, 1), p[1])
         p[0] = self.handleNullable(type, p[2])
 
-    def p_NonAnyTypeDate(self, p):
-        """
-            NonAnyType : DATE Null
+    def p_DistinguishableTypeDate(self, p):
+        """
+            DistinguishableType : DATE Null
         """
         p[0] = self.handleNullable(BuiltinTypes[IDLBuiltinType.Types.date],
                                    p[2])
 
     def p_ConstType(self, p):
         """
             ConstType : PrimitiveType
         """