Fix in compiler pass: cr.defineProperty() with 2 arguments means opt_kind == cr.PropertyKind.JS
BUG=393873 R=tbreisacher@chromium.org Review URL: https://codereview.chromium.org/473853003 Cr-Commit-Position: refs/heads/master@{#289902} git-svn-id: svn://svn.chromium.org/chrome/trunk/src@289902 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
third_party/closure_compiler/runner
@ -107,15 +107,15 @@ public class ChromePass extends AbstractPostOrderCallback implements CompilerPas
|
||||
}
|
||||
|
||||
private Node getTypeByCrPropertyKind(Node propertyKind) {
|
||||
if (propertyKind == null || propertyKind.matchesQualifiedName("cr.PropertyKind.JS")) {
|
||||
return new Node(Token.QMARK);
|
||||
}
|
||||
if (propertyKind.matchesQualifiedName("cr.PropertyKind.ATTR")) {
|
||||
return IR.string("string");
|
||||
}
|
||||
if (propertyKind.matchesQualifiedName("cr.PropertyKind.BOOL_ATTR")) {
|
||||
return IR.string("boolean");
|
||||
}
|
||||
if (propertyKind.matchesQualifiedName("cr.PropertyKind.JS")) {
|
||||
return new Node(Token.QMARK);
|
||||
}
|
||||
compiler.report(JSError.make(propertyKind, CR_DEFINE_PROPERTY_INVALID_PROPERTY_KIND,
|
||||
propertyKind.getQualifiedName()));
|
||||
return null;
|
||||
|
9
third_party/closure_compiler/runner/test/com/google/javascript/jscomp/ChromePassTest.java
vendored
9
third_party/closure_compiler/runner/test/com/google/javascript/jscomp/ChromePassTest.java
vendored
@ -219,6 +219,15 @@ public class ChromePassTest extends CompilerTestCase {
|
||||
"a.prototype.c;");
|
||||
}
|
||||
|
||||
public void testCrDefinePropertyCalledWithouthThirdArgumentMeansCrPropertyKindJs()
|
||||
throws Exception {
|
||||
test(
|
||||
"cr.defineProperty(a.prototype, 'c');",
|
||||
"cr.defineProperty(a.prototype, 'c');\n" +
|
||||
"/** @type {?} */\n" +
|
||||
"a.prototype.c;");
|
||||
}
|
||||
|
||||
public void testCrDefinePropertyDefinesUnquotedPropertyOnPrototypeWhenFunctionIsPassed()
|
||||
throws Exception {
|
||||
test(
|
||||
|
Reference in New Issue
Block a user