Enable transpilation for CheckNullableReturnTest since it runs after type checking.
If transpilation is OFF, the type checkers can see ES6 code and crash.
@@ -19,7 +19,6 @@ package com.google.javascript.jscomp.lint;
import com.google.javascript.jscomp.CheckLevel;
import com.google.javascript.jscomp.Compiler;
import com.google.javascript.jscomp.CompilerOptions;
-import com.google.javascript.jscomp.CompilerOptions.LanguageMode;
import com.google.javascript.jscomp.CompilerPass;
import com.google.javascript.jscomp.DiagnosticGroups;
import com.google.javascript.jscomp.TypeICompilerTestCase;
@@ -49,6 +48,12 @@ public final class CheckNullableReturnTest extends TypeICompilerTestCase {
return 1;
}
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
+ enableTranspile();
+ }
+
public void testSimpleWarning() {
testError(LINE_JOINER.join(
"/** @return {SomeType} */",
@@ -131,7 +136,6 @@ public final class CheckNullableReturnTest extends TypeICompilerTestCase {
" return new SomeType();",
" }",
"}"));
- setAcceptedLanguage(LanguageMode.ECMASCRIPT_2015);
testError(LINE_JOINER.join(
"var obj = {",
" /** @return {SomeType} */",
@@ -155,7 +159,6 @@ public final class CheckNullableReturnTest extends TypeICompilerTestCase {
" return new SomeType();",
" }",
"}"));
- setAcceptedLanguage(LanguageMode.ECMASCRIPT_2015);
testError(LINE_JOINER.join(
"var obj = {",
" /** @return {SomeType} */",
@@ -211,7 +214,6 @@ public final class CheckNullableReturnTest extends TypeICompilerTestCase {
testOk(LINE_JOINER.join(
"/** @return {SomeType} */",
"function f() {}"));
- setAcceptedLanguage(LanguageMode.ECMASCRIPT_2015);
testOk(LINE_JOINER.join(
"var obj = {",
" /** @return {SomeType} */\n",
@@ -228,7 +230,6 @@ public final class CheckNullableReturnTest extends TypeICompilerTestCase {
"function f4(arr) {",
" return arr[0] || null;",
"}"));
- setAcceptedLanguage(LanguageMode.ECMASCRIPT_2015);
testOk(LINE_JOINER.join(
"var obj = {",
" /**",
@@ -266,13 +267,11 @@ public final class CheckNullableReturnTest extends TypeICompilerTestCase {
private void testBodyOk(String body) {
testOk(createFunction(body));
- setAcceptedLanguage(LanguageMode.ECMASCRIPT_2015);
testOk(createShorthandFunctionInObjLit(body));
}
private void testBodyError(String body) {
testError(createFunction(body));
- setAcceptedLanguage(LanguageMode.ECMASCRIPT_2015);
testError(createShorthandFunctionInObjLit(body));
}
}
