зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1583819 - Webidl parser should report error if there are multiple definitions with same identifier from the mixin interfaces; r=bzbarsky
Differential Revision: https://phabricator.services.mozilla.com/D47136 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
11b80b3ccf
Коммит
2cae03d6e1
|
@ -1101,6 +1101,13 @@ class IDLInterfaceOrNamespace(IDLInterfaceOrInterfaceMixinOrNamespace):
|
||||||
|
|
||||||
for mixin in sorted(self.includedMixins,
|
for mixin in sorted(self.includedMixins,
|
||||||
key=lambda x: x.identifier.name):
|
key=lambda x: x.identifier.name):
|
||||||
|
for mixinMember in mixin.members:
|
||||||
|
for member in self.members:
|
||||||
|
if mixinMember.identifier.name == member.identifier.name:
|
||||||
|
raise WebIDLError(
|
||||||
|
"Multiple definitions of %s on %s coming from 'includes' statements" %
|
||||||
|
(member.identifier.name, self),
|
||||||
|
[mixinMember.location, member.location])
|
||||||
self.members.extend(mixin.members)
|
self.members.extend(mixin.members)
|
||||||
|
|
||||||
for ancestor in self.getInheritedInterfaces():
|
for ancestor in self.getInheritedInterfaces():
|
||||||
|
|
|
@ -337,6 +337,44 @@ def WebIDLTest(parser, harness):
|
||||||
harness.ok(threw,
|
harness.ok(threw,
|
||||||
"Should fail if an interface mixin includes maplike")
|
"Should fail if an interface mixin includes maplike")
|
||||||
|
|
||||||
|
parser = parser.reset()
|
||||||
|
threw = False
|
||||||
|
try:
|
||||||
|
parser.parse("""
|
||||||
|
interface Interface {
|
||||||
|
attribute short attr;
|
||||||
|
};
|
||||||
|
interface mixin Mixin {
|
||||||
|
attribute short attr;
|
||||||
|
};
|
||||||
|
Interface includes Mixin;
|
||||||
|
""")
|
||||||
|
results = parser.finish()
|
||||||
|
except:
|
||||||
|
threw = True
|
||||||
|
harness.ok(threw,
|
||||||
|
"Should fail if the included mixin interface has duplicated member")
|
||||||
|
|
||||||
|
parser = parser.reset()
|
||||||
|
threw = False
|
||||||
|
try:
|
||||||
|
parser.parse("""
|
||||||
|
interface Interface {};
|
||||||
|
interface mixin Mixin1 {
|
||||||
|
attribute short attr;
|
||||||
|
};
|
||||||
|
interface mixin Mixin2 {
|
||||||
|
attribute short attr;
|
||||||
|
};
|
||||||
|
Interface includes Mixin1;
|
||||||
|
Interface includes Mixin2;
|
||||||
|
""")
|
||||||
|
results = parser.finish()
|
||||||
|
except:
|
||||||
|
threw = True
|
||||||
|
harness.ok(threw,
|
||||||
|
"Should fail if the included mixin interfaces have duplicated member")
|
||||||
|
|
||||||
parser = parser.reset()
|
parser = parser.reset()
|
||||||
parser.parse("""
|
parser.parse("""
|
||||||
[Global] interface Window {};
|
[Global] interface Window {};
|
||||||
|
|
Загрузка…
Ссылка в новой задаче