Skip to content

Commit

Permalink
Fix unit test and move it to TypeCheckNoTranspileTests.java so it run…
Browse files Browse the repository at this point in the history
…s without class transpilation and remove debugging code so the test passes.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=208519103
  • Loading branch information
concavelenz authored and lauraharker committed Aug 14, 2018
1 parent e4fbe81 commit 6fc18b2
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
3 changes: 1 addition & 2 deletions src/com/google/javascript/jscomp/TypeCheck.java
Expand Up @@ -1324,8 +1324,7 @@ private void visitObjectOrClassLiteralKey(
// Allow the definition of "constructor" as an unquoted key in class bodies. They will // Allow the definition of "constructor" as an unquoted key in class bodies. They will
// never be renamed so quoting is unimportant for the ALL_UNQUOTED renaming policy // never be renamed so quoting is unimportant for the ALL_UNQUOTED renaming policy
// and the property is not accessed directly. // and the property is not accessed directly.
boolean temp = true; if (!key.isMemberFunctionDef()
if (temp || !key.isMemberFunctionDef()
|| !key.getParent().isClassMembers() || !key.getParent().isClassMembers()
|| !key.getString().equals("constructor")) { || !key.getString().equals("constructor")) {
report(t, key, ILLEGAL_OBJLIT_KEY, "dict"); report(t, key, ILLEGAL_OBJLIT_KEY, "dict");
Expand Down
Expand Up @@ -4024,5 +4024,9 @@ public void testDefaultValueForNestedArrayPatternMustBeIterable() {
"required: Iterable")); "required: Iterable"));
} }


public void testDictClass1() {
testTypes("/** @dict */ var C = class { constructor() {} 'x'(){} };");
}

// TODO(b/77597706): add tests for missing property warnings on object destructuring string keys // TODO(b/77597706): add tests for missing property warnings on object destructuring string keys
} }
4 changes: 0 additions & 4 deletions test/com/google/javascript/jscomp/TypeCheckTest.java
Expand Up @@ -1199,10 +1199,6 @@ public void testObjLitDef7() {
"Illegal key, the object literal is a dict"); "Illegal key, the object literal is a dict");
} }


public void testDictClass1() {
testTypes("var C = /** @dict */ class { constructor() {} 'x'(){} };");
}

public void testInstanceOfReduction1() { public void testInstanceOfReduction1() {
testTypes("/** @constructor */ var T = function() {};\n" + testTypes("/** @constructor */ var T = function() {};\n" +
"/** @param {T|string} x\n@return {T} */\n" + "/** @param {T|string} x\n@return {T} */\n" +
Expand Down

0 comments on commit 6fc18b2

Please sign in to comment.