From 7fb122d0a2c9310bf36d4eed63deccb4e7aeb3f5 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Tue, 28 Apr 2015 12:25:55 -0400 Subject: [PATCH] Bug 1157588. Produce a better error message when someone tries to pass a mixin as an argument. r=peterv --- dom/bindings/Configuration.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/dom/bindings/Configuration.py b/dom/bindings/Configuration.py index d1f9d934a430..797cf9c9e9af 100644 --- a/dom/bindings/Configuration.py +++ b/dom/bindings/Configuration.py @@ -25,6 +25,7 @@ class Configuration: # |parseData|. self.descriptors = [] self.interfaces = {} + self.optimizedOutDescriptorNames = set() self.generatedEvents = generatedEvents; self.maxProtoChainLength = 0; for thing in parseData: @@ -60,6 +61,7 @@ class Configuration: # if they have no interface object because chances are we # don't need to do anything interesting with them. if iface.isConsequential() and not iface.hasInterfaceObject(): + self.optimizedOutDescriptorNames.add(iface.identifier.name) continue entry = {} else: @@ -246,14 +248,24 @@ class Configuration: Gets the appropriate descriptor for the given interface name and the given workers boolean. """ - for d in self.descriptorsByName[interfaceName]: + # We may have optimized out this descriptor, but the chances of anyone + # asking about it are then slim. Put the check for that _after_ we've + # done our normal lookups. But that means we have to do our normal + # lookups in a way that will not throw if they fail. + for d in self.descriptorsByName.get(interfaceName, []): if d.workers == workers: return d if workers: - for d in self.descriptorsByName[interfaceName]: + for d in self.descriptorsByName.get(interfaceName, []): return d + if interfaceName in self.optimizedOutDescriptorNames: + raise NoSuchDescriptorError( + "No descriptor for '%s', which is a mixin ([NoInterfaceObject] " + "and a consequential interface) without an explicit " + "Bindings.conf annotation." % interfaceName) + raise NoSuchDescriptorError("For " + interfaceName + " found no matches"); def getDescriptorProvider(self, workers): """