diff --git a/test/com/google/javascript/jscomp/AmbiguatePropertiesTest.java b/test/com/google/javascript/jscomp/AmbiguatePropertiesTest.java index 4927d854cde..4bbf0b33d0e 100644 --- a/test/com/google/javascript/jscomp/AmbiguatePropertiesTest.java +++ b/test/com/google/javascript/jscomp/AmbiguatePropertiesTest.java @@ -49,7 +49,6 @@ protected void setUp() throws Exception { enableNormalize(); enableClosurePass(); enableGatherExternProperties(); - this.mode = TypeInferenceMode.BOTH; ignoreWarnings( NewTypeInference.GLOBAL_THIS, NewTypeInference.PROPERTY_ACCESS_ON_NONOBJECT); @@ -1123,8 +1122,6 @@ public void testDontRenamePrototypeWithoutExterns() { "/** @return {!Foo} */", "Foo.prototype.a = function() {};"); - // NTI reqires at least the MINIMAL_EXTERNS. - this.mode = TypeInferenceMode.OTI_ONLY; test(externs(""), srcs(js), expected(output)); } } diff --git a/test/com/google/javascript/jscomp/CheckAccessControlsTest.java b/test/com/google/javascript/jscomp/CheckAccessControlsTest.java index cb8454ef60e..d8e11bcf966 100644 --- a/test/com/google/javascript/jscomp/CheckAccessControlsTest.java +++ b/test/com/google/javascript/jscomp/CheckAccessControlsTest.java @@ -329,10 +329,6 @@ public void testWarningForSuperclassMethod2() { } public void testWarningForBind() { - // NTI reports NTI_REDCLARED_PROPERTY here, which is as intended. If this were a new - // property and not the existing `bind`, then we'd report the deprecation warning as expected - // (see testAutoboxedDeprecatedProperty and testAutoboxedPrivateProperty). - this.mode = TypeInferenceMode.OTI_ONLY; testDepProp( "/** @deprecated I'm bound to this method... */ Function.prototype.bind = function() {};" + "(function() {}).bind();", @@ -467,19 +463,10 @@ public void testPrivateAccess_googModule() { "(new One()).m();"), }; - this.mode = TypeInferenceMode.OTI_ONLY; testError( srcs(js), error(BAD_PRIVATE_PROPERTY_ACCESS) .withMessage("Access to private property m of One not allowed here.")); - - /* - this.mode = TypeInferenceMode.NTI_ONLY; - testError( - srcs(js), - error(BAD_PRIVATE_PROPERTY_ACCESS).withMessage( - "Access to private property m of module$exports$example$One not allowed here.")); - */ } public void testNoPrivateAccessForProperties1() { @@ -1698,9 +1685,6 @@ public void testNamespaceConstantProperty1() { } public void testNamespaceConstantProperty2() { - // NTI requires an @const annotation on namespaces, as in testNamespaceConstantProperty1. - // This is the only difference between the two tests. - this.mode = TypeInferenceMode.OTI_ONLY; testError( "var o = {};\n" + "/** @const */ o.x = 1;\n" @@ -1742,8 +1726,6 @@ public void testConstantProperty3b1() { } public void testConstantProperty3b2() { - // NTI reports NTI_REDECLARED_PROPERTY - this.mode = TypeInferenceMode.OTI_ONLY; // The old type checker should report this but it doesn't. testSame("/** @const */ var o = { XYZ: 1 };" + "o.XYZ = 2;"); @@ -1807,8 +1789,6 @@ public void testConstantProperty10a() { } public void testConstantProperty10b() { - // NTI reports NTI_REDECLARED_PROPERTY - this.mode = TypeInferenceMode.OTI_ONLY; testSame("/** @constructor */ function Foo() { this.PROP = 1;}" + "Foo.prototype.PROP;"); } @@ -1825,9 +1805,6 @@ public void testConstantProperty11() { } public void testConstantProperty12() { - // NTI deliberately disallows this pattern (separate declaration and initialization - // of const properties). (b/30205953) - this.mode = TypeInferenceMode.OTI_ONLY; testSame("/** @constructor */ function Foo() {}" + "/** @const */ Foo.prototype.bar;" + "/**\n" diff --git a/test/com/google/javascript/jscomp/CheckConformanceTest.java b/test/com/google/javascript/jscomp/CheckConformanceTest.java index 9f4283b6421..1fe69f5d150 100644 --- a/test/com/google/javascript/jscomp/CheckConformanceTest.java +++ b/test/com/google/javascript/jscomp/CheckConformanceTest.java @@ -1400,7 +1400,6 @@ public void testCustomBanUnknownInterfaceProp1() { " a.gak();", "}"); - this.mode = TypeInferenceMode.OTI_ONLY; testWarning( js, CheckConformance.CONFORMANCE_VIOLATION, @@ -1524,17 +1523,11 @@ public void testCustomBanUnresolvedType() { + " error_message: 'BanUnresolvedType Message'\n" + "}"; - // NOTE(aravindpg): In NTI we annotate the node `a` with its inferred type instead of Unknown, - // and so this test doesn't recognize `a` as unresolved. Fixing this is undesirable. - // However, we do intend to add warnings for unfulfilled forward declares, which essentially - // addresses this use case. - this.mode = TypeInferenceMode.OTI_ONLY; testWarning( "goog.forwardDeclare('Foo'); /** @param {Foo} a */ function f(a) {a.foo()};", CheckConformance.CONFORMANCE_VIOLATION, "Violation: BanUnresolvedType Message\nReference to type 'Foo' never resolved."); - this.mode = TypeInferenceMode.BOTH; testNoWarning(lines( "/** @suppress {newCheckTypes}", " * @param {!Object} data", @@ -1552,9 +1545,6 @@ public void testCustomStrictBanUnresolvedType() { + " error_message: 'StrictBanUnresolvedType Message'\n" + "}"; - // NTI doesn't model unresolved types separately from unknown, so this check always results - // in conformance. - this.mode = TypeInferenceMode.OTI_ONLY; testWarning( "goog.forwardDeclare('Foo'); /** @param {Foo} a */ var f = function(a) {}", CheckConformance.CONFORMANCE_VIOLATION, diff --git a/test/com/google/javascript/jscomp/CheckTemplateParamsTest.java b/test/com/google/javascript/jscomp/CheckTemplateParamsTest.java index 147dabd2bcb..6c91a8e2865 100644 --- a/test/com/google/javascript/jscomp/CheckTemplateParamsTest.java +++ b/test/com/google/javascript/jscomp/CheckTemplateParamsTest.java @@ -17,7 +17,6 @@ package com.google.javascript.jscomp; import static com.google.javascript.jscomp.RhinoErrorReporter.TOO_MANY_TEMPLATE_PARAMS; -import static com.google.javascript.jscomp.newtypes.JSTypeCreatorFromJSDoc.INVALID_GENERICS_INSTANTIATION; /** * Tests for the "Too many template parameters" warning. Ideally this would be part of @@ -25,12 +24,6 @@ * (as strings) not ones from JSTypeRegistry (as DiagnosticTypes). */ public final class CheckTemplateParamsTest extends TypeICompilerTestCase { - @Override - protected void setUp() throws Exception { - super.setUp(); - this.mode = TypeInferenceMode.BOTH; - } - @Override protected int getNumRepetitions() { return 1; @@ -54,7 +47,7 @@ public void testArray() { testSame("/** @type {!Array} */ var x;"); test( srcs("/** @type {!Array} */ var x;"), - warningOtiNti(TOO_MANY_TEMPLATE_PARAMS, INVALID_GENERICS_INSTANTIATION)); + warning(TOO_MANY_TEMPLATE_PARAMS)); } public void testObject() { @@ -63,7 +56,7 @@ public void testObject() { testSame("/** @type {!Object} */ var x;"); test( srcs("/** @type {!Object} */ var x;"), - warningOtiNti(TOO_MANY_TEMPLATE_PARAMS, INVALID_GENERICS_INSTANTIATION)); + warning(TOO_MANY_TEMPLATE_PARAMS)); } public void testClass() { @@ -72,7 +65,7 @@ public void testClass() { srcs(lines( "/** @constructor */ function SomeClass() {};", "/** @type {!SomeClass} */ var x;")), - warningOtiNti(TOO_MANY_TEMPLATE_PARAMS, INVALID_GENERICS_INSTANTIATION)); + warning(TOO_MANY_TEMPLATE_PARAMS)); testSame(lines( "/** @constructor @template T */ function SomeClass() {};", @@ -82,7 +75,7 @@ public void testClass() { srcs(lines( "/** @constructor @template T */ function SomeClass() {};", "/** @type {!SomeClass} */ var x;")), - warningOtiNti(TOO_MANY_TEMPLATE_PARAMS, INVALID_GENERICS_INSTANTIATION)); + warning(TOO_MANY_TEMPLATE_PARAMS)); } } diff --git a/test/com/google/javascript/jscomp/CheckUnusedPrivatePropertiesTest.java b/test/com/google/javascript/jscomp/CheckUnusedPrivatePropertiesTest.java index 2599253836b..19ae9b65be0 100644 --- a/test/com/google/javascript/jscomp/CheckUnusedPrivatePropertiesTest.java +++ b/test/com/google/javascript/jscomp/CheckUnusedPrivatePropertiesTest.java @@ -82,7 +82,7 @@ public void testConstructorPropertyUsed1() { } public void testClassPropUnused1() { - this.mode = TypeInferenceMode.NEITHER; + this.mode = TypeInferenceMode.DISABLED; // A property defined on "this" can be removed unused("class C { constructor() { /** @private */ this.a = 2 } }"); @@ -94,7 +94,7 @@ public void testClassPropUnused2() { } public void testClassMethodUnused1() { - this.mode = TypeInferenceMode.NEITHER; + this.mode = TypeInferenceMode.DISABLED; unused("class C { constructor() {} /** @private */ method() {} }"); used("class C { constructor() {} /** @private */ method() {} }\n new C().method();"); @@ -102,7 +102,7 @@ public void testClassMethodUnused1() { // The JSDoc seems to be missing here, reenable this test when it is fixed. public void disable_testClassMethodUnused2() { - this.mode = TypeInferenceMode.NEITHER; + this.mode = TypeInferenceMode.DISABLED; unused("class C { constructor() {}\n /** @private */ ['method']() {} }"); used("class C { constructor() {}\n /** @private */ ['method']() {} }\n new C()['method']();"); diff --git a/test/com/google/javascript/jscomp/ClosureRewriteClassTest.java b/test/com/google/javascript/jscomp/ClosureRewriteClassTest.java index 62b6695e7f3..63e3907e3aa 100644 --- a/test/com/google/javascript/jscomp/ClosureRewriteClassTest.java +++ b/test/com/google/javascript/jscomp/ClosureRewriteClassTest.java @@ -41,17 +41,12 @@ public final class ClosureRewriteClassTest extends TypeICompilerTestCase { "goog.defineClass = function(a,b) {};", "var use;"); - private static final Diagnostic INSTANTIATE_ABSTRACT_CLASS = warningOtiNti( - TypeCheck.INSTANTIATE_ABSTRACT_CLASS, - NewTypeInference.CANNOT_INSTANTIATE_ABSTRACT_CLASS); + private static final Diagnostic INSTANTIATE_ABSTRACT_CLASS = + warning(TypeCheck.INSTANTIATE_ABSTRACT_CLASS); - private static final Diagnostic NOT_A_CONSTRUCTOR = warningOtiNti( - TypeCheck.NOT_A_CONSTRUCTOR, - NewTypeInference.NOT_A_CONSTRUCTOR); + private static final Diagnostic NOT_A_CONSTRUCTOR = warning(TypeCheck.NOT_A_CONSTRUCTOR); - private static final Diagnostic INEXISTENT_PROPERTY = warningOtiNti( - TypeCheck.INEXISTENT_PROPERTY, - NewTypeInference.INEXISTENT_PROPERTY); + private static final Diagnostic INEXISTENT_PROPERTY = warning(TypeCheck.INEXISTENT_PROPERTY); public ClosureRewriteClassTest() { super(EXTERNS); @@ -65,7 +60,7 @@ protected CompilerPass getProcessor(Compiler compiler) { @Override protected void setUp() throws Exception { super.setUp(); - this.mode = TypeInferenceMode.NEITHER; + this.mode = TypeInferenceMode.DISABLED; enableRunTypeCheckAfterProcessing(); } @@ -154,7 +149,7 @@ public void testConst() { public void testAnnotations1() { // verify goog.defineClass values are constructible, by default - this.mode = TypeInferenceMode.BOTH; + this.mode = TypeInferenceMode.CHECKED; testRewrite( "var x = goog.defineClass(Object, {\n" + " constructor: function(){}\n" @@ -168,7 +163,7 @@ public void testAnnotations1() { public void testAnnotations2a() { // @interface is preserved - this.mode = TypeInferenceMode.BOTH; + this.mode = TypeInferenceMode.CHECKED; testRewriteWarning( lines( "var x = goog.defineClass(null, {", @@ -185,7 +180,7 @@ public void testAnnotations2a() { public void testAnnotations2b() { // @interface is preserved, at the class level too - this.mode = TypeInferenceMode.BOTH; + this.mode = TypeInferenceMode.CHECKED; testRewriteWarning( lines( "/** @interface */", @@ -200,7 +195,7 @@ public void testAnnotations2b() { public void testAnnotations3a() { // verify goog.defineClass is a @struct by default - this.mode = TypeInferenceMode.BOTH; + this.mode = TypeInferenceMode.CHECKED; testRewriteWarning( lines( "var y = goog.defineClass(null, {", @@ -222,8 +217,8 @@ public void testAnnotations3a() { public void testAnnotations3b() { // verify goog.defineClass is a @struct by default, but can be overridden (only in OTI) - this.mode = TypeInferenceMode.BOTH; - testRewriteWarning( + this.mode = TypeInferenceMode.CHECKED; + testRewrite( lines( "/** @unrestricted */", "var y = goog.defineClass(null, {", @@ -239,8 +234,7 @@ public void testAnnotations3b() { "/** @constructor @struct @extends {y} */", "var x = function() {this.a = 1};", "goog.inherits(x,y);", - "use(new y().a);"), - warningOtiNti(null, NewTypeInference.INEXISTENT_PROPERTY)); + "use(new y().a);")); } public void testRecordAnnotations() { @@ -255,7 +249,7 @@ public void testRecordAnnotations() { } public void testRecordAnnotations2() { - this.mode = TypeInferenceMode.BOTH; + this.mode = TypeInferenceMode.CHECKED; testRewrite( "/** @record */\n" + "var Rec = goog.defineClass(null, {f : function() {}});\n" @@ -269,7 +263,7 @@ public void testRecordAnnotations2() { public void testAbstract1() { // @abstract is preserved - this.mode = TypeInferenceMode.BOTH; + this.mode = TypeInferenceMode.CHECKED; testRewriteWarning( lines( "var x = goog.defineClass(null, {", @@ -286,7 +280,7 @@ public void testAbstract1() { public void testAbstract2() { // @abstract is preserved, at the class level too - this.mode = TypeInferenceMode.BOTH; + this.mode = TypeInferenceMode.CHECKED; testRewriteWarning( lines( "/** @abstract */", diff --git a/test/com/google/javascript/jscomp/CodePrinterTest.java b/test/com/google/javascript/jscomp/CodePrinterTest.java index 4109c4b72df..debfd62071b 100644 --- a/test/com/google/javascript/jscomp/CodePrinterTest.java +++ b/test/com/google/javascript/jscomp/CodePrinterTest.java @@ -1543,7 +1543,7 @@ void setOptions(CompilerOptions options) { private void assertTypeAnnotations(String js, String expected) { assertEquals( expected, - new CodePrinter.Builder(parse(js, TypeInferenceMode.OTI_ONLY)) + new CodePrinter.Builder(parse(js, TypeInferenceMode.CHECKED)) .setCompilerOptions(newCompilerOptions(new CompilerOptionBuilder() { @Override void setOptions(CompilerOptions options) { @@ -1994,13 +1994,13 @@ void setOptions(CompilerOptions options) { public void testStrict() { String result = - defaultBuilder(parse("var x", TypeInferenceMode.OTI_ONLY)).setTagAsStrict(true).build(); + defaultBuilder(parse("var x", TypeInferenceMode.CHECKED)).setTagAsStrict(true).build(); assertEquals("'use strict';var x", result); } public void testStrictPretty() { String result = - defaultBuilder(parse("var x", TypeInferenceMode.OTI_ONLY)) + defaultBuilder(parse("var x", TypeInferenceMode.CHECKED)) .setTagAsStrict(true) .setPrettyPrint(true) .build(); @@ -2009,13 +2009,13 @@ public void testStrictPretty() { public void testExterns() { String result = - defaultBuilder(parse("var x", TypeInferenceMode.OTI_ONLY)).setTagAsExterns(true).build(); + defaultBuilder(parse("var x", TypeInferenceMode.CHECKED)).setTagAsExterns(true).build(); assertEquals("/** @externs */\nvar x", result); } public void testIjs() { String result = - defaultBuilder(parse("var x", TypeInferenceMode.OTI_ONLY)) + defaultBuilder(parse("var x", TypeInferenceMode.CHECKED)) .setTagAsTypeSummary(true) .build(); assertEquals("/** @fileoverview @typeSummary */\nvar x", result); diff --git a/test/com/google/javascript/jscomp/CodePrinterTestBase.java b/test/com/google/javascript/jscomp/CodePrinterTestBase.java index 094decb0d01..06a624e5fba 100644 --- a/test/com/google/javascript/jscomp/CodePrinterTestBase.java +++ b/test/com/google/javascript/jscomp/CodePrinterTestBase.java @@ -15,8 +15,6 @@ */ package com.google.javascript.jscomp; -import static com.google.common.base.Preconditions.checkArgument; - import com.google.common.collect.ImmutableList; import com.google.javascript.jscomp.CompilerOptions.LanguageMode; import com.google.javascript.jscomp.TypeICompilerTestCase.TypeInferenceMode; @@ -44,11 +42,10 @@ protected void setUp() throws Exception { } Node parse(String js) { - return parse(js, TypeInferenceMode.NEITHER); + return parse(js, TypeInferenceMode.DISABLED); } Node parse(String js, TypeInferenceMode mode) { - checkArgument(mode != TypeInferenceMode.BOTH); Compiler compiler = new Compiler(); lastCompiler = compiler; CompilerOptions options = new CompilerOptions(); @@ -67,7 +64,7 @@ Node parse(String js, TypeInferenceMode mode) { Node root = externsAndJs.getLastChild(); Node externs = externsAndJs.getFirstChild(); - if (mode.runsOTI()) { + if (mode.runsTypeCheck()) { DefaultPassConfig passConfig = new DefaultPassConfig(null); CompilerPass typeResolver = passConfig.resolveTypes.create(compiler); typeResolver.process(externs, root); diff --git a/test/com/google/javascript/jscomp/DeclaredGlobalExternsOnWindowTest.java b/test/com/google/javascript/jscomp/DeclaredGlobalExternsOnWindowTest.java index 670e593e360..4bb9c18eab8 100644 --- a/test/com/google/javascript/jscomp/DeclaredGlobalExternsOnWindowTest.java +++ b/test/com/google/javascript/jscomp/DeclaredGlobalExternsOnWindowTest.java @@ -30,7 +30,6 @@ protected void setUp() throws Exception { super.setUp(); setAcceptedLanguage(LanguageMode.ECMASCRIPT_2017); allowExternsChanges(); - this.mode = TypeInferenceMode.BOTH; enableRunTypeCheckAfterProcessing(); } @@ -177,12 +176,10 @@ public void testWindowPropertyWithJsDoc() { "/** @param {number} n*/", "function f(n) {}", "f(window.x);")), - warningOtiNti(TypeValidator.TYPE_MISMATCH_WARNING, NewTypeInference.INVALID_ARGUMENT_TYPE)); + warning(TypeValidator.TYPE_MISMATCH_WARNING)); } public void testEnum() { - // TODO(sdh): figure out why NTI doesn't recognize props if 'window' not explicitly declared - this.mode = TypeInferenceMode.OTI_ONLY; testSame( externs(lines( MINIMAL_EXTERNS, @@ -208,8 +205,6 @@ public void testConstructorIsSameType() { "function bar(f) {}", "bar(new Foo());"))); - // TODO(sdh): figure out why NTI doesn't recognize props if 'window' not explicitly declared - this.mode = TypeInferenceMode.OTI_ONLY; testSame( externs(lines( MINIMAL_EXTERNS, diff --git a/test/com/google/javascript/jscomp/DevirtualizePrototypeMethodsTest.java b/test/com/google/javascript/jscomp/DevirtualizePrototypeMethodsTest.java index 79e0583b1ce..a53e54a64b4 100644 --- a/test/com/google/javascript/jscomp/DevirtualizePrototypeMethodsTest.java +++ b/test/com/google/javascript/jscomp/DevirtualizePrototypeMethodsTest.java @@ -44,7 +44,7 @@ protected int getNumRepetitions() { @Override protected void setUp() throws Exception { super.setUp(); - this.mode = TypeInferenceMode.NEITHER; + this.mode = TypeInferenceMode.DISABLED; } /** @@ -89,7 +89,7 @@ public void testRewritePrototypeMethodsWithCorrectTypes() throws Exception { "JSCompiler_StaticMethods_bar(o, 2);", "JSCompiler_StaticMethods_baz(o)"); - this.mode = TypeInferenceMode.OTI_ONLY; + this.mode = TypeInferenceMode.CHECKED; test(input, expected); checkTypeOfRewrittenMethods(); } diff --git a/test/com/google/javascript/jscomp/DisambiguatePropertiesTest.java b/test/com/google/javascript/jscomp/DisambiguatePropertiesTest.java index 6a75fefa05a..1198ef7fcd8 100644 --- a/test/com/google/javascript/jscomp/DisambiguatePropertiesTest.java +++ b/test/com/google/javascript/jscomp/DisambiguatePropertiesTest.java @@ -469,7 +469,6 @@ public void testIgnoreUnknownType() { + "var F = new Foo;F.blah=0;" + "var U=function(){return{}};U().blah()"; - this.mode = TypeInferenceMode.OTI_ONLY; testSets(js, expected, "{}"); } @@ -581,7 +580,6 @@ public void testStaticProperty() { + "Bar.a = 0;"; String output; - this.mode = TypeInferenceMode.OTI_ONLY; output = "" + "/** @constructor */ function Foo(){}" + "/** @constructor */ function Bar(){}" @@ -701,7 +699,6 @@ public void testUntypedCodeWrongDisambiguation1() { + "var arr = [new Foo, new Bar];\n" + "var /** !Foo */z = arr[1];\n" + "z.Foo$p1;\n"; - this.mode = TypeInferenceMode.OTI_ONLY; testSets(js, output, "{p1=[[Bar], [Foo]]}"); } @@ -1367,7 +1364,6 @@ public void testInvalidatingInterface() { + "(new Foo).a = 0;" + "/** @interface */ function I() {};\n" + "I.prototype.a;\n"; - this.mode = TypeInferenceMode.OTI_ONLY; testSets(js, "{}", TypeValidator.TYPE_MISMATCH_WARNING); } @@ -1555,7 +1551,6 @@ public void testConstructorsWithTypeErrorsAreNotDisambiguated() { "", "(new Bar()).alias();"); - this.mode = TypeInferenceMode.OTI_ONLY; testSets("", js, js, "{}", TypeValidator.TYPE_MISMATCH_WARNING, "assignment\n" + "found : function(new:Foo): undefined\n" + "required: function(new:Bar): undefined"); @@ -1808,7 +1803,6 @@ public void testDontInvalidateForGenericsMismatch() { " this.Bar$prop = 123;", "}"); - this.mode = TypeInferenceMode.OTI_ONLY; testSets(js, output, "{prop=[[Bar], [Foo]]}"); } @@ -1962,7 +1956,6 @@ public void testMismatchInvalidation() { + "var F = new Bar;\n" + "F.a = 0;"; - this.mode = TypeInferenceMode.OTI_ONLY; testSets("", js, js, "{}", TypeValidator.TYPE_MISMATCH_WARNING, lines( "initializing variable", @@ -1977,7 +1970,6 @@ public void testBadCast() { + "Bar.prototype.a = 0;\n" + "var a = /** @type {!Foo} */ (new Bar);\n" + "a.a = 4;"; - this.mode = TypeInferenceMode.OTI_ONLY; testSets("", js, js, "{}", TypeValidator.INVALID_CAST, "invalid cast - must be a subtype or supertype\n" + "from: Bar\n" @@ -2023,7 +2015,6 @@ public void testObjectLiteral() { + "Bar.prototype.Bar_prototype$a;\n" + "var F = /** @type {Foo} */ ({ Foo_prototype$a: 'a' });"; - this.mode = TypeInferenceMode.OTI_ONLY; testSets(js, output, "{a=[[Bar.prototype], [Foo.prototype]]}"); } @@ -2321,7 +2312,6 @@ public void testIgnoreSpecializedProperties2() { " this.Foo$num = 123;", "}"); - this.mode = TypeInferenceMode.OTI_ONLY; testSets("", js, otiOutput, "{num=[[Foo], [function(): undefined]]}"); } diff --git a/test/com/google/javascript/jscomp/Es6RewriteBlockScopedDeclarationTest.java b/test/com/google/javascript/jscomp/Es6RewriteBlockScopedDeclarationTest.java index 6776a545bbf..74b68761f2c 100644 --- a/test/com/google/javascript/jscomp/Es6RewriteBlockScopedDeclarationTest.java +++ b/test/com/google/javascript/jscomp/Es6RewriteBlockScopedDeclarationTest.java @@ -35,7 +35,6 @@ protected void setUp() throws Exception { setAcceptedLanguage(LanguageMode.ECMASCRIPT_2015); enableTypeCheck(); enableTypeInfoValidation(); - this.mode = TypeInferenceMode.OTI_ONLY; } @Override @@ -1287,10 +1286,8 @@ public void testNormalizeDeclarations() { } public void testTypeAnnotationsOnLetConst() { - this.mode = TypeInferenceMode.BOTH; - Diagnostic mismatch = - warningOtiNti(TypeValidator.TYPE_MISMATCH_WARNING, NewTypeInference.MISTYPED_ASSIGN_RHS); + warning(TypeValidator.TYPE_MISMATCH_WARNING); test(srcs("/** @type {number} */ let x = 5; x = 'str';"), mismatch); test(srcs("let /** number */ x = 5; x = 'str';"), mismatch); @@ -1304,8 +1301,6 @@ public void testTypeAnnotationsOnLetConst() { } public void testDoWhileForOfCapturedLetAnnotated() { - this.mode = TypeInferenceMode.BOTH; - test( lines( "while (true) {", @@ -1334,7 +1329,7 @@ public void testDoWhileForOfCapturedLetAnnotated() { " (function() { x++; })();", " x = 'str';", "}")), - warningOtiNti(TypeValidator.TYPE_MISMATCH_WARNING, null)); + warning(TypeValidator.TYPE_MISMATCH_WARNING)); test( srcs( @@ -1343,7 +1338,7 @@ public void testDoWhileForOfCapturedLetAnnotated() { " (function() { x++; })();", " x = 'str';", "}")), - warningOtiNti(TypeValidator.TYPE_MISMATCH_WARNING, null)); + warning(TypeValidator.TYPE_MISMATCH_WARNING)); } public void testLetForInitializers() { diff --git a/test/com/google/javascript/jscomp/Es6RewriteBlockScopedFunctionDeclarationTest.java b/test/com/google/javascript/jscomp/Es6RewriteBlockScopedFunctionDeclarationTest.java index 67953408485..ccf1995eba1 100644 --- a/test/com/google/javascript/jscomp/Es6RewriteBlockScopedFunctionDeclarationTest.java +++ b/test/com/google/javascript/jscomp/Es6RewriteBlockScopedFunctionDeclarationTest.java @@ -19,14 +19,13 @@ import com.google.javascript.jscomp.CompilerOptions.LanguageMode; /** Test case for {@link Es6RewriteBlockScopedFunctionDeclaration}. */ -public final class Es6RewriteBlockScopedFunctionDeclarationTest extends TypeICompilerTestCase { +public final class Es6RewriteBlockScopedFunctionDeclarationTest extends CompilerTestCase { @Override protected void setUp() throws Exception { super.setUp(); setAcceptedLanguage(LanguageMode.ECMASCRIPT_2015); enableRunTypeCheckAfterProcessing(); - this.mode = TypeInferenceMode.NEITHER; } @Override diff --git a/test/com/google/javascript/jscomp/Es6RewriteDestructuringTest.java b/test/com/google/javascript/jscomp/Es6RewriteDestructuringTest.java index 78230f67c7e..b301341806a 100644 --- a/test/com/google/javascript/jscomp/Es6RewriteDestructuringTest.java +++ b/test/com/google/javascript/jscomp/Es6RewriteDestructuringTest.java @@ -25,7 +25,7 @@ public class Es6RewriteDestructuringTest extends TypeICompilerTestCase { protected void setUp() throws Exception { super.setUp(); setAcceptedLanguage(LanguageMode.ECMASCRIPT_2015); - this.mode = TypeInferenceMode.NEITHER; + this.mode = TypeInferenceMode.DISABLED; enableRunTypeCheckAfterProcessing(); } @@ -468,7 +468,7 @@ public void testDefaultValueInObjectPattern() { } public void testDefaultParameters() { - this.mode = TypeInferenceMode.BOTH; + this.mode = TypeInferenceMode.CHECKED; test( "function f(/** ? */ zero, /** ?= */ one = 1, /** ?= */ two = 2) {}; f(1); f(1,2,3);", lines( @@ -486,7 +486,7 @@ public void testDefaultParameters() { " one = (one === undefined) ? 1 : one;", " two = (two === undefined) ? 2 : two;", "}; f();")), - warningOtiNti(TypeCheck.WRONG_ARGUMENT_COUNT, NewTypeInference.WRONG_ARGUMENT_COUNT)); + warning(TypeCheck.WRONG_ARGUMENT_COUNT)); } public void testDefaultAndRestParameters() { @@ -506,7 +506,7 @@ public void testDefaultAndRestParameters() { } public void testDefaultUndefinedParameters() { - this.mode = TypeInferenceMode.BOTH; + this.mode = TypeInferenceMode.CHECKED; test("function f(zero, one=undefined) {}", "function f(zero, one) {}"); @@ -536,7 +536,7 @@ public void testCatch() { } public void testTypeCheck() { - this.mode = TypeInferenceMode.BOTH; + this.mode = TypeInferenceMode.CHECKED; test( "/** @param {{x: number}} obj */ function f({x}) {}", @@ -549,7 +549,7 @@ public void testTypeCheck() { test( srcs(lines("/** @param {{x: number}} obj */", "function f({x}) {}", "f({ x: 'str'});")), - warningOtiNti(TypeValidator.TYPE_MISMATCH_WARNING, NewTypeInference.INVALID_ARGUMENT_TYPE)); + warning(TypeValidator.TYPE_MISMATCH_WARNING)); test( lines( @@ -606,7 +606,7 @@ public void testTypeCheck() { } public void testDestructuringPatternInExterns() { - this.mode = TypeInferenceMode.BOTH; + this.mode = TypeInferenceMode.CHECKED; allowExternsChanges(); testSame( @@ -618,12 +618,12 @@ public void testDestructuringPatternInExterns() { "", "Foo.prototype.bar = function({a}) {};")), srcs("(new Foo).bar({b: 0});"), - warningOtiNti(TypeCheck.POSSIBLE_INEXISTENT_PROPERTY, null)); + warning(TypeCheck.POSSIBLE_INEXISTENT_PROPERTY)); // TODO(sdh): figure out what's going on here } public void testTypeCheck_inlineAnnotations() { - this.mode = TypeInferenceMode.BOTH; + this.mode = TypeInferenceMode.CHECKED; test( "function f(/** {x: number} */ {x}) {}", @@ -635,7 +635,7 @@ public void testTypeCheck_inlineAnnotations() { test( srcs(lines("function f(/** {x: number} */ {x}) {}", "f({ x: 'str'});")), - warningOtiNti(TypeValidator.TYPE_MISMATCH_WARNING, NewTypeInference.INVALID_ARGUMENT_TYPE)); + warning(TypeValidator.TYPE_MISMATCH_WARNING)); } public void testDestructuringArrayNotInExprResult() { diff --git a/test/com/google/javascript/jscomp/Es6ToEs3ConverterTest.java b/test/com/google/javascript/jscomp/Es6ToEs3ConverterTest.java index 0fff3fc68a5..1ebda3c7d00 100644 --- a/test/com/google/javascript/jscomp/Es6ToEs3ConverterTest.java +++ b/test/com/google/javascript/jscomp/Es6ToEs3ConverterTest.java @@ -21,12 +21,10 @@ import static com.google.javascript.jscomp.Es6RewriteClass.DYNAMIC_EXTENDS_TYPE; import static com.google.javascript.jscomp.Es6ToEs3Util.CANNOT_CONVERT; import static com.google.javascript.jscomp.Es6ToEs3Util.CANNOT_CONVERT_YET; -import static com.google.javascript.jscomp.NewTypeInference.CANNOT_INSTANTIATE_ABSTRACT_CLASS; import static com.google.javascript.jscomp.TypeCheck.INSTANTIATE_ABSTRACT_CLASS; import static com.google.javascript.jscomp.parsing.parser.FeatureSet.ES7_MODULES; import com.google.javascript.jscomp.CompilerOptions.LanguageMode; -import com.google.javascript.jscomp.newtypes.JSTypeCreatorFromJSDoc; import com.google.javascript.jscomp.parsing.parser.FeatureSet; /** @@ -101,7 +99,7 @@ protected void setUp() throws Exception { setAcceptedLanguage(LanguageMode.ECMASCRIPT_2016); setLanguageOut(LanguageMode.ECMASCRIPT3); enableRunTypeCheckAfterProcessing(); - this.mode = TypeInferenceMode.NEITHER; + this.mode = TypeInferenceMode.DISABLED; } protected final PassFactory makePassFactory( @@ -549,11 +547,11 @@ public void testClassExpression() { } public void testAbstractClass() { - this.mode = TypeInferenceMode.BOTH; + this.mode = TypeInferenceMode.CHECKED; test( "/** @abstract */ class Foo {} var x = new Foo();", "/** @abstract @constructor @struct */ var Foo = function() {}; var x = new Foo();", - warningOtiNti(INSTANTIATE_ABSTRACT_CLASS, CANNOT_INSTANTIATE_ABSTRACT_CLASS)); + warning(INSTANTIATE_ABSTRACT_CLASS)); } /** @@ -1657,7 +1655,7 @@ public void testGithub752() { } public void testInvalidClassUse() { - this.mode = TypeInferenceMode.BOTH; + this.mode = TypeInferenceMode.CHECKED; test( lines( @@ -1687,7 +1685,7 @@ public void testInvalidClassUse() { "Foo.f = function() {};", "class Sub extends Foo {}", "Sub.f();")), - warningOtiNti(TypeCheck.INEXISTENT_PROPERTY, NewTypeInference.INEXISTENT_PROPERTY)); + warning(TypeCheck.INEXISTENT_PROPERTY)); test( lines( @@ -1918,7 +1916,7 @@ public void testEs5GettersAndSettersClassesWithTypes() { } public void testClassEs5GetterSetterIncorrectTypes() { - this.mode = TypeInferenceMode.BOTH; + this.mode = TypeInferenceMode.CHECKED; setLanguageOut(LanguageMode.ECMASCRIPT5); ignoreWarnings( NewTypeInference.INEXISTENT_PROPERTY, NewTypeInference.INVALID_OBJLIT_PROPERTY_TYPE); @@ -1939,9 +1937,7 @@ public void testClassEs5GetterSetterIncorrectTypes() { " get: function() {}", " }", "});"), - warningOtiNti( - TypeValidator.TYPE_MISMATCH_WARNING, - JSTypeCreatorFromJSDoc.FUNCTION_WITH_NONFUNC_JSDOC)); + warning(TypeValidator.TYPE_MISMATCH_WARNING)); // Using @type instead of @param on a setter. test( @@ -1959,9 +1955,7 @@ public void testClassEs5GetterSetterIncorrectTypes() { " set: function(v) {}", " }", "});"), - warningOtiNti( - TypeValidator.TYPE_MISMATCH_WARNING, - JSTypeCreatorFromJSDoc.FUNCTION_WITH_NONFUNC_JSDOC)); + warning(TypeValidator.TYPE_MISMATCH_WARNING)); } /** @@ -2486,8 +2480,7 @@ public void testArgumentsEscaped() { } public void testForOfOnNonIterable() { - // TODO(sdh): figure out why NTI is not complaining about invalid argument type to makeIterator - this.mode = TypeInferenceMode.OTI_ONLY; + this.mode = TypeInferenceMode.CHECKED; test( srcs( lines( @@ -2497,7 +2490,7 @@ public void testForOfOnNonIterable() { " length: 2,", "};", "for (var x of arrayLike) {}")), - warningOtiNti(TypeValidator.TYPE_MISMATCH_WARNING, NewTypeInference.INVALID_ARGUMENT_TYPE)); + warning(TypeValidator.TYPE_MISMATCH_WARNING)); } public void testSpreadCall() { @@ -2543,7 +2536,7 @@ public void testSpreadCall() { "($jscomp$spread$args1 = G.d()).n.apply($jscomp$spread$args1,", " $jscomp.arrayFromIterable(b));")); - this.mode = TypeInferenceMode.BOTH; + this.mode = TypeInferenceMode.CHECKED; test( srcs( @@ -2555,7 +2548,7 @@ public void testSpreadCall() { "}", "var arr = [1,2]", "Factory.create().m(...arr);")), - warningOtiNti(TypeCheck.INEXISTENT_PROPERTY, NewTypeInference.INEXISTENT_PROPERTY)); + warning(TypeCheck.INEXISTENT_PROPERTY)); test( lines( diff --git a/test/com/google/javascript/jscomp/Es7ToEs6ConverterTest.java b/test/com/google/javascript/jscomp/Es7ToEs6ConverterTest.java index 68e045263cc..de05243d657 100644 --- a/test/com/google/javascript/jscomp/Es7ToEs6ConverterTest.java +++ b/test/com/google/javascript/jscomp/Es7ToEs6ConverterTest.java @@ -21,7 +21,7 @@ * Test cases for ES6 transpilation. Despite the name, this isn't just testing {@link * Es6ToEs3Converter}, but also some other ES6 transpilation passes. See #getProcessor. */ -public final class Es7ToEs6ConverterTest extends TypeICompilerTestCase { +public final class Es7ToEs6ConverterTest extends CompilerTestCase { public Es7ToEs6ConverterTest() { super(MINIMAL_EXTERNS); @@ -33,7 +33,6 @@ protected void setUp() throws Exception { setAcceptedLanguage(LanguageMode.ECMASCRIPT_2016); setLanguageOut(LanguageMode.ECMASCRIPT5); enableRunTypeCheckAfterProcessing(); - this.mode = TypeInferenceMode.NEITHER; } @Override diff --git a/test/com/google/javascript/jscomp/EsNextToEs8ConverterTest.java b/test/com/google/javascript/jscomp/EsNextToEs8ConverterTest.java index 0f204932d76..c09ed069b4b 100644 --- a/test/com/google/javascript/jscomp/EsNextToEs8ConverterTest.java +++ b/test/com/google/javascript/jscomp/EsNextToEs8ConverterTest.java @@ -18,7 +18,7 @@ import com.google.javascript.jscomp.CompilerOptions.LanguageMode; /** Test cases for ESNext transpilation. */ -public final class EsNextToEs8ConverterTest extends TypeICompilerTestCase { +public final class EsNextToEs8ConverterTest extends CompilerTestCase { public EsNextToEs8ConverterTest() { super(MINIMAL_EXTERNS); @@ -30,7 +30,6 @@ protected void setUp() throws Exception { setAcceptedLanguage(LanguageMode.ECMASCRIPT_NEXT); setLanguageOut(LanguageMode.ECMASCRIPT_2017); enableRunTypeCheckAfterProcessing(); - this.mode = TypeInferenceMode.NEITHER; } @Override diff --git a/test/com/google/javascript/jscomp/ExternExportsPassTest.java b/test/com/google/javascript/jscomp/ExternExportsPassTest.java index 61c77af4527..8ee105ef4bf 100644 --- a/test/com/google/javascript/jscomp/ExternExportsPassTest.java +++ b/test/com/google/javascript/jscomp/ExternExportsPassTest.java @@ -29,7 +29,6 @@ public final class ExternExportsPassTest extends TypeICompilerTestCase { protected void setUp() throws Exception { super.setUp(); enableNormalize(); - this.mode = TypeInferenceMode.BOTH; } @Override @@ -158,8 +157,6 @@ public void testExportMultiple() throws Exception { } public void testExportMultiple2() throws Exception { - // TODO(sdh): NTI leaves out the annotation for hello for some reason. - this.mode = TypeInferenceMode.OTI_ONLY; compileAndCheck( lines( "/** @const */ var a = {};", @@ -334,7 +331,7 @@ public void testExportSymbolWithMultipleTemplateAnnotation() { public void testExportSymbolWithoutTypeCheck() { // ExternExportsPass should not emit annotations // if there is no type information available. - this.mode = TypeInferenceMode.NEITHER; + this.mode = TypeInferenceMode.DISABLED; compileAndCheck( lines( @@ -411,7 +408,7 @@ public void testExportSymbolWithConstructorWithoutTypeCheck() { // to JSTypes and not Nodes (and no JSTypes are created when checkTypes // is false), we don't really have a choice. - this.mode = TypeInferenceMode.NEITHER; + this.mode = TypeInferenceMode.DISABLED; compileAndCheck( lines( @@ -581,7 +578,6 @@ public void testExportWithReferenceToEnum() { "};", ""); - this.mode = TypeInferenceMode.OTI_ONLY; // NOTE: The type should print {E} for the @param, but is not. compileAndCheck(js, expected.replace("{E}", "{number}")); } diff --git a/test/com/google/javascript/jscomp/ImplicitNullabilityCheckTest.java b/test/com/google/javascript/jscomp/ImplicitNullabilityCheckTest.java index dc4c689402e..070fd1af42d 100644 --- a/test/com/google/javascript/jscomp/ImplicitNullabilityCheckTest.java +++ b/test/com/google/javascript/jscomp/ImplicitNullabilityCheckTest.java @@ -90,15 +90,11 @@ public void testParameterizedObject() { } public void testNullableTypedef() { - // Arguable whether or not this deserves a warning, so leaving - // out of NTI for now. - this.mode = TypeInferenceMode.OTI_ONLY; + // Arguable whether or not this deserves a warning warnImplicitlyNullable("/** @typedef {?number} */ var Num; var /** Num */ x;"); } public void testUnknownTypenameDoesntWarn() { - // Different warnings in OTI and NTI - this.mode = TypeInferenceMode.OTI_ONLY; test( externs(DEFAULT_EXTERNS), srcs("/** @type {gibberish} */ var x;"), diff --git a/test/com/google/javascript/jscomp/InlinePropertiesTest.java b/test/com/google/javascript/jscomp/InlinePropertiesTest.java index 9ba965ffd2e..efedcd80826 100644 --- a/test/com/google/javascript/jscomp/InlinePropertiesTest.java +++ b/test/com/google/javascript/jscomp/InlinePropertiesTest.java @@ -91,7 +91,6 @@ protected void setUp() throws Exception { enableNormalize(); enableClosurePass(); enableGatherExternProperties(); - this.mode = TypeInferenceMode.BOTH; this.runSmartNameRemoval = false; } diff --git a/test/com/google/javascript/jscomp/J2clCheckPassTest.java b/test/com/google/javascript/jscomp/J2clCheckPassTest.java index 5867842abe0..8796a275ebb 100644 --- a/test/com/google/javascript/jscomp/J2clCheckPassTest.java +++ b/test/com/google/javascript/jscomp/J2clCheckPassTest.java @@ -27,7 +27,6 @@ public J2clCheckPassTest() { @Override protected void setUp() throws Exception { super.setUp(); - this.mode = TypeInferenceMode.BOTH; } @Override diff --git a/test/com/google/javascript/jscomp/J2clEqualitySameRewriterPassTest.java b/test/com/google/javascript/jscomp/J2clEqualitySameRewriterPassTest.java index 8945521122c..c13ec770470 100644 --- a/test/com/google/javascript/jscomp/J2clEqualitySameRewriterPassTest.java +++ b/test/com/google/javascript/jscomp/J2clEqualitySameRewriterPassTest.java @@ -25,7 +25,6 @@ public J2clEqualitySameRewriterPassTest() { @Override protected void setUp() throws Exception { super.setUp(); - this.mode = TypeInferenceMode.BOTH; } @Override diff --git a/test/com/google/javascript/jscomp/PeepholeFoldConstantsTest.java b/test/com/google/javascript/jscomp/PeepholeFoldConstantsTest.java index e0f5708f885..00bffea9581 100644 --- a/test/com/google/javascript/jscomp/PeepholeFoldConstantsTest.java +++ b/test/com/google/javascript/jscomp/PeepholeFoldConstantsTest.java @@ -48,7 +48,7 @@ protected void setUp() throws Exception { useTypes = true; // Reduce this to 1 if we get better expression evaluators. numRepetitions = 2; - mode = TypeInferenceMode.NEITHER; + mode = TypeInferenceMode.DISABLED; } @Override @@ -763,7 +763,7 @@ public void testStringAdd() { } public void testStringAdd_identity() { - this.mode = TypeInferenceMode.BOTH; + this.mode = TypeInferenceMode.CHECKED; foldStringTypes("x + ''", "x"); foldStringTypes("'' + x", "x"); } @@ -1431,7 +1431,7 @@ public void testIssue522() { } public void testTypeBasedFoldConstant() { - this.mode = TypeInferenceMode.BOTH; + this.mode = TypeInferenceMode.CHECKED; test("function f(/** number */ x) { x + 1 + 1 + x; }", "function f(/** number */ x) { x + 2 + x; }"); @@ -1585,7 +1585,7 @@ public void testConvertToNumberNegativeInf() { } public void testAlgebraicIdentities() { - this.mode = TypeInferenceMode.BOTH; + this.mode = TypeInferenceMode.CHECKED; foldNumericTypes("x+0", "x"); foldNumericTypes("0+x", "x"); diff --git a/test/com/google/javascript/jscomp/PeepholeMinimizeConditionsTest.java b/test/com/google/javascript/jscomp/PeepholeMinimizeConditionsTest.java index 8a85f980cf5..52b37fd90bb 100644 --- a/test/com/google/javascript/jscomp/PeepholeMinimizeConditionsTest.java +++ b/test/com/google/javascript/jscomp/PeepholeMinimizeConditionsTest.java @@ -33,7 +33,7 @@ public PeepholeMinimizeConditionsTest() { protected void setUp() throws Exception { super.setUp(); late = true; - this.mode = TypeInferenceMode.NEITHER; + this.mode = TypeInferenceMode.DISABLED; // NTI warns about property accesses on * ignoreWarnings(DiagnosticGroups.NEW_CHECK_TYPES_EXTRA_CHECKS); } @@ -777,7 +777,7 @@ public void testIssue925() { } public void testCoercionSubstitution_disabled() { - this.mode = TypeInferenceMode.BOTH; + this.mode = TypeInferenceMode.CHECKED; testSame("var x = {}; if (x != null) throw 'a';"); testSame("var x = {}; var y = x != null;"); @@ -786,12 +786,12 @@ public void testCoercionSubstitution_disabled() { } public void testCoercionSubstitution_booleanResult0() { - this.mode = TypeInferenceMode.BOTH; + this.mode = TypeInferenceMode.CHECKED; testSame("var x = {}; var y = x != null;"); } public void testCoercionSubstitution_booleanResult1() { - this.mode = TypeInferenceMode.BOTH; + this.mode = TypeInferenceMode.CHECKED; testSame("var x = {}; var y = x == null;"); testSame("var x = {}; var y = x !== null;"); testSame("var x = undefined; var y = x !== null;"); @@ -805,7 +805,7 @@ public void testCoercionSubstitution_booleanResult1() { } public void testCoercionSubstitution_if() { - this.mode = TypeInferenceMode.BOTH; + this.mode = TypeInferenceMode.CHECKED; test("var x = {};\nif (x != null) throw 'a';\n", "var x={}; if (x!=null) throw 'a'"); testSame("var x = {};\nif (x == null) throw 'a';\n"); testSame("var x = {};\nif (x !== null) throw 'a';\n"); @@ -829,13 +829,13 @@ public void testCoercionSubstitution_if() { } public void testCoercionSubstitution_expression() { - this.mode = TypeInferenceMode.BOTH; + this.mode = TypeInferenceMode.CHECKED; testSame("var x = {}; x != null && alert('b');"); testSame("var x = 1; x != 0 && alert('b');"); } public void testCoercionSubstitution_hook() { - this.mode = TypeInferenceMode.BOTH; + this.mode = TypeInferenceMode.CHECKED; testSame( lines( "var x = {};", @@ -847,7 +847,7 @@ public void testCoercionSubstitution_hook() { } public void testCoercionSubstitution_not() { - this.mode = TypeInferenceMode.BOTH; + this.mode = TypeInferenceMode.CHECKED; test( "var x = {};\nvar y = !(x != null) ? 1 : 2;\n", "var x = {};\nvar y = (x == null) ? 1 : 2;\n"); @@ -855,44 +855,44 @@ public void testCoercionSubstitution_not() { } public void testCoercionSubstitution_while() { - this.mode = TypeInferenceMode.BOTH; + this.mode = TypeInferenceMode.CHECKED; testSame("var x = {}; while (x != null) throw 'a';"); testSame("var x = 1; while (x != 0) throw 'a';"); } public void testCoercionSubstitution_unknownType() { - this.mode = TypeInferenceMode.BOTH; + this.mode = TypeInferenceMode.CHECKED; testSame("var x = /** @type {?} */ ({});\nif (x != null) throw 'a';\n"); testSame("var x = /** @type {?} */ (1);\nif (x != 0) throw 'a';\n"); } public void testCoercionSubstitution_allType() { - this.mode = TypeInferenceMode.BOTH; + this.mode = TypeInferenceMode.CHECKED; testSame("var x = /** @type {*} */ ({});\nif (x != null) throw 'a';\n"); testSame("var x = /** @type {*} */ (1);\nif (x != 0) throw 'a';\n"); } public void testCoercionSubstitution_primitivesVsNull() { - this.mode = TypeInferenceMode.BOTH; + this.mode = TypeInferenceMode.CHECKED; testSame("var x = 0;\nif (x != null) throw 'a';\n"); testSame("var x = '';\nif (x != null) throw 'a';\n"); testSame("var x = false;\nif (x != null) throw 'a';\n"); } public void testCoercionSubstitution_nonNumberVsZero() { - this.mode = TypeInferenceMode.BOTH; + this.mode = TypeInferenceMode.CHECKED; testSame("var x = {};\nif (x != 0) throw 'a';\n"); testSame("var x = '';\nif (x != 0) throw 'a';\n"); testSame("var x = false;\nif (x != 0) throw 'a';\n"); } public void testCoercionSubstitution_boxedNumberVsZero() { - this.mode = TypeInferenceMode.BOTH; + this.mode = TypeInferenceMode.CHECKED; testSame("var x = new Number(0);\nif (x != 0) throw 'a';\n"); } public void testCoercionSubstitution_boxedPrimitives() { - this.mode = TypeInferenceMode.BOTH; + this.mode = TypeInferenceMode.CHECKED; testSame("var x = new Number(); if (x != null) throw 'a';"); testSame("var x = new String(); if (x != null) throw 'a';"); testSame("var x = new Boolean();\nif (x != null) throw 'a';"); diff --git a/test/com/google/javascript/jscomp/PeepholeReplaceKnownMethodsTest.java b/test/com/google/javascript/jscomp/PeepholeReplaceKnownMethodsTest.java index 8dd75a842b5..dffe194e392 100644 --- a/test/com/google/javascript/jscomp/PeepholeReplaceKnownMethodsTest.java +++ b/test/com/google/javascript/jscomp/PeepholeReplaceKnownMethodsTest.java @@ -43,7 +43,7 @@ protected void setUp() throws Exception { super.setUp(); late = true; useTypes = true; - this.mode = TypeInferenceMode.NEITHER; + this.mode = TypeInferenceMode.DISABLED; } @Override @@ -520,7 +520,7 @@ public void testFoldParseOctalNumbers() { } public void testReplaceWithCharAt() { - this.mode = TypeInferenceMode.BOTH; + this.mode = TypeInferenceMode.CHECKED; foldStringTyped("a.substring(0, 1)", "a.charAt(0)"); foldSameStringTyped("a.substring(-4, -3)"); foldSameStringTyped("a.substring(i, j + 1)"); @@ -558,16 +558,13 @@ public void testReplaceWithCharAt() { foldSameStringTyped("a.substr(1, 2)"); foldSameStringTyped("a.substr(1, 2, 3)"); - this.mode = TypeInferenceMode.OTI_ONLY; - // TODO(sdh): NTI currently infers that a is a string, allowing the peephole pass - // to rewrite substring to charAt. We need to figure out if this is desirable. + this.mode = TypeInferenceMode.CHECKED; foldSame("function f(/** ? */ a) { a.substring(0, 1); }"); foldSame("function f(/** ? */ a) { a.substr(0, 1); }"); foldSame(lines( "/** @constructor */ function A() {};", "A.prototype.substring = function() {};", "function f(/** ? */ a) { a.substring(0, 1); }")); - this.mode = TypeInferenceMode.BOTH; foldSame("function f(/** ? */ a) { a.slice(0, 1); }"); useTypes = false; diff --git a/test/com/google/javascript/jscomp/PolymerPassFindExternsTest.java b/test/com/google/javascript/jscomp/PolymerPassFindExternsTest.java index b8de1b10682..7bd14d19172 100644 --- a/test/com/google/javascript/jscomp/PolymerPassFindExternsTest.java +++ b/test/com/google/javascript/jscomp/PolymerPassFindExternsTest.java @@ -76,7 +76,6 @@ public void process(Node externs, Node root) { protected void setUp() throws Exception { super.setUp(); allowExternsChanges(); - this.mode = TypeInferenceMode.BOTH; enableRunTypeCheckAfterProcessing(); enableParseTypeInfo(); } diff --git a/test/com/google/javascript/jscomp/PolymerPassSuppressBehaviorsTest.java b/test/com/google/javascript/jscomp/PolymerPassSuppressBehaviorsTest.java index 964803e399d..98f357b4c81 100644 --- a/test/com/google/javascript/jscomp/PolymerPassSuppressBehaviorsTest.java +++ b/test/com/google/javascript/jscomp/PolymerPassSuppressBehaviorsTest.java @@ -77,7 +77,6 @@ protected void setUp() throws Exception { super.setUp(); setAcceptedLanguage(LanguageMode.ECMASCRIPT_2017); allowExternsChanges(); - this.mode = TypeInferenceMode.BOTH; enableRunTypeCheckAfterProcessing(); enableParseTypeInfo(); } @@ -171,7 +170,7 @@ public void testDefaultValueSuppression() { } public void testConstBehaviours() { - this.mode = TypeInferenceMode.NEITHER; + this.mode = TypeInferenceMode.DISABLED; test( lines( "/** @polymerBehavior */", @@ -185,7 +184,7 @@ public void testConstBehaviours() { } public void testLetBehaviours() { - this.mode = TypeInferenceMode.NEITHER; + this.mode = TypeInferenceMode.DISABLED; test( lines( "/** @polymerBehavior */", diff --git a/test/com/google/javascript/jscomp/PolymerPassTest.java b/test/com/google/javascript/jscomp/PolymerPassTest.java index 551cfe0b5e6..66a94d2696b 100644 --- a/test/com/google/javascript/jscomp/PolymerPassTest.java +++ b/test/com/google/javascript/jscomp/PolymerPassTest.java @@ -16,7 +16,6 @@ package com.google.javascript.jscomp; import static com.google.common.truth.Truth.assertThat; -import static com.google.javascript.jscomp.NewTypeInference.MISTYPED_ASSIGN_RHS; import static com.google.javascript.jscomp.PolymerClassRewriter.POLYMER_ELEMENT_PROP_CONFIG; import static com.google.javascript.jscomp.PolymerPassErrors.POLYMER_CLASS_PROPERTIES_INVALID; import static com.google.javascript.jscomp.PolymerPassErrors.POLYMER_CLASS_PROPERTIES_NOT_STATIC; @@ -132,7 +131,6 @@ protected void setUp() throws Exception { super.setUp(); setAcceptedLanguage(LanguageMode.ECMASCRIPT_2017); allowExternsChanges(); - this.mode = TypeInferenceMode.BOTH; enableRunTypeCheckAfterProcessing(); enableParseTypeInfo(); } @@ -157,7 +155,7 @@ public void testVarTarget() { "});")); // Type checker doesn't currently understand ES6 code. Remove when it does. - this.mode = TypeInferenceMode.NEITHER; + this.mode = TypeInferenceMode.DISABLED; test( lines( "var X = class extends Polymer.Element {", @@ -175,7 +173,7 @@ public void testVarTarget() { public void testLetTarget() { // Type checker doesn't currently understand ES6 code. Remove when it does. - this.mode = TypeInferenceMode.NEITHER; + this.mode = TypeInferenceMode.DISABLED; test( lines( "let X = Polymer({", @@ -191,7 +189,7 @@ public void testLetTarget() { "X = Polymer(/** @lends {X.prototype} */ {is:'x-element'});")); // Type checker doesn't currently understand ES6 code. Remove when it does. - this.mode = TypeInferenceMode.NEITHER; + this.mode = TypeInferenceMode.DISABLED; test( lines( "let X = class extends Polymer.Element {", @@ -209,7 +207,7 @@ public void testLetTarget() { public void testConstTarget() { // Type checker doesn't currently understand ES6 code. Remove when it does. - this.mode = TypeInferenceMode.NEITHER; + this.mode = TypeInferenceMode.DISABLED; testError( lines( "const X = Polymer({", @@ -266,7 +264,7 @@ public void testPathAssignmentTarget() { "});")); // Type checker doesn't currently understand ES6 code. Remove when it does. - this.mode = TypeInferenceMode.NEITHER; + this.mode = TypeInferenceMode.DISABLED; test( lines( "const x = {};", @@ -287,7 +285,7 @@ public void testPathAssignmentTarget() { public void testComputedPropName() { // Type checker doesn't currently understand ES6 code. Remove when it does. // TypeCheck cannot grab a name from a complicated computedPropName - this.mode = TypeInferenceMode.NEITHER; + this.mode = TypeInferenceMode.DISABLED; test("var X = Polymer({is:'x-element', [name + (() => 42)]: function() {return 42;}});", lines( "/** @constructor @extends {PolymerElement} @implements {PolymerXInterface} */", @@ -329,7 +327,7 @@ public void testIIFEExtractionInGlobalNamespace() { "})()")); // Type checker doesn't currently understand ES6 code. Remove when it does. - this.mode = TypeInferenceMode.NEITHER; + this.mode = TypeInferenceMode.DISABLED; test( lines( "const x = {};", @@ -380,7 +378,7 @@ public void testIIFEExtractionNoAssignmentTarget() { "})()")); // Type checker doesn't currently understand ES6 code. Remove when it does. - this.mode = TypeInferenceMode.NEITHER; + this.mode = TypeInferenceMode.DISABLED; test( lines( "(function() {", @@ -509,7 +507,7 @@ public void testOtherKeysIgnored() { "});")); // Type checker doesn't currently understand ES6 code. Remove when it does. - this.mode = TypeInferenceMode.NEITHER; + this.mode = TypeInferenceMode.DISABLED; test( lines( "class X extends Polymer.Element {", @@ -672,7 +670,7 @@ public void testPropertiesAddedToPrototype() { "});")); // Type checker doesn't currently understand ES6 code. Remove when it does. - this.mode = TypeInferenceMode.NEITHER; + this.mode = TypeInferenceMode.DISABLED; test( lines( "/** @constructor */", @@ -777,7 +775,7 @@ public void testPropertiesDefaultValueFunctions() { "});")); // Type checker doesn't currently understand ES6 code. Remove when it does. - this.mode = TypeInferenceMode.NEITHER; + this.mode = TypeInferenceMode.DISABLED; test( lines( "/** @constructor */", @@ -872,7 +870,7 @@ public void testPropertiesDefaultValueShortHandFunction() { "});")); // Type checker doesn't currently understand ES6 code. Remove when it does. - this.mode = TypeInferenceMode.NEITHER; + this.mode = TypeInferenceMode.DISABLED; test( lines( "/** @constructor */", @@ -1023,7 +1021,7 @@ public void testReadOnlyPropertySetters() { "Polymera_BInterface.prototype._setPets;")); // Type checker doesn't currently understand ES6 code. Remove when it does. - this.mode = TypeInferenceMode.NEITHER; + this.mode = TypeInferenceMode.DISABLED; String jsClass = lines( "class A extends Polymer.Element {", " static get is() { return 'a-element'; }", @@ -1168,7 +1166,7 @@ public void testReflectToAttributeProperties() { public void testPolymerClassObserversTyped() { // Type checker doesn't currently understand ES6 code. Remove when it does. - this.mode = TypeInferenceMode.NEITHER; + this.mode = TypeInferenceMode.DISABLED; test( lines( "class FooElement extends Polymer.Element {", @@ -1332,7 +1330,7 @@ public void testThisTypeAddedToFunctions() { "});")); // Type checker doesn't currently understand ES6 code. Remove when it does. - this.mode = TypeInferenceMode.NEITHER; + this.mode = TypeInferenceMode.DISABLED; test( lines( "class Foo extends Polymer.Element {", @@ -1446,7 +1444,7 @@ public void testDollarSignPropsConvertedToBrackets() { "});")); // Type checker doesn't currently understand ES6 code. Remove when it does. - this.mode = TypeInferenceMode.NEITHER; + this.mode = TypeInferenceMode.DISABLED; test( lines( "class Foo extends Polymer.Element {", @@ -2725,7 +2723,7 @@ public void testDuplicatedBehaviorsAreCopiedOnce() { public void testInvalid1() { // Type checker doesn't currently understand ES6 code. Remove when it does. - this.mode = TypeInferenceMode.NEITHER; + this.mode = TypeInferenceMode.DISABLED; testWarning("var x = Polymer('blah');", POLYMER_DESCRIPTOR_NOT_VALID); testWarning("var x = Polymer('foo-bar', {});", POLYMER_DESCRIPTOR_NOT_VALID); testError("var x = Polymer({},'blah');", POLYMER_UNEXPECTED_PARAMS); @@ -2787,7 +2785,7 @@ public void testInvalidProperties() { POLYMER_INVALID_PROPERTY); // Type checker doesn't currently understand ES6 code. Remove when it does. - this.mode = TypeInferenceMode.NEITHER; + this.mode = TypeInferenceMode.DISABLED; testError( lines( "var x = class extends Polymer.Element {", @@ -2924,12 +2922,12 @@ public void testInvalidTypeAssignment() { " this.isHappy = 7;", " },", "});"), - warningOtiNti(TYPE_MISMATCH_WARNING, MISTYPED_ASSIGN_RHS)); + warning(TYPE_MISMATCH_WARNING)); } public void testFeaturesInFunctionBody() { // Type checker doesn't currently understand ES6 code. Remove when it does. - this.mode = TypeInferenceMode.NEITHER; + this.mode = TypeInferenceMode.DISABLED; test( lines( "var X = Polymer({", @@ -2968,7 +2966,7 @@ public void testFeaturesInFunctionBody() { public void testPolymerElementAnnotation1() { // Type checker doesn't currently understand ES6 code. Remove when it does. - this.mode = TypeInferenceMode.NEITHER; + this.mode = TypeInferenceMode.DISABLED; test( lines( "/** @constructor */", @@ -3021,7 +3019,7 @@ public void testPolymerElementAnnotation1() { public void testPolymerElementAnnotation2() { // Type checker doesn't currently understand ES6 code. Remove when it does. - this.mode = TypeInferenceMode.NEITHER; + this.mode = TypeInferenceMode.DISABLED; test( lines( "/** @constructor */", @@ -3124,7 +3122,7 @@ public void testObjectReflectionAddedToConfigProperties1() { "});")); // Type checker doesn't currently understand ES6 code. Remove when it does. - this.mode = TypeInferenceMode.NEITHER; + this.mode = TypeInferenceMode.DISABLED; test( 2, lines( @@ -3225,7 +3223,7 @@ public void testObjectReflectionAddedToConfigProperties2() { "});")); // Type checker doesn't currently understand ES6 code. Remove when it does. - this.mode = TypeInferenceMode.NEITHER; + this.mode = TypeInferenceMode.DISABLED; test( 2, lines( @@ -3327,7 +3325,7 @@ public void testObjectReflectionAddedToConfigProperties3() { "});")); // Type checker doesn't currently understand ES6 code. Remove when it does. - this.mode = TypeInferenceMode.NEITHER; + this.mode = TypeInferenceMode.DISABLED; test( 2, lines( diff --git a/test/com/google/javascript/jscomp/PureFunctionIdentifierTest.java b/test/com/google/javascript/jscomp/PureFunctionIdentifierTest.java index dff849f8fd3..a7765324378 100644 --- a/test/com/google/javascript/jscomp/PureFunctionIdentifierTest.java +++ b/test/com/google/javascript/jscomp/PureFunctionIdentifierTest.java @@ -577,7 +577,7 @@ public void testAnnotationInExternStubs4() throws Exception { " */", "externObj5.prototype.propWithAnnotatedStubAfter;"); - this.mode = TypeInferenceMode.OTI_ONLY; + this.mode = TypeInferenceMode.CHECKED; testSame( externs(externs), srcs("o.prototype.propWithAnnotatedStubAfter"), @@ -604,7 +604,7 @@ public void testAnnotationInExternStubs5() throws Exception { " */", "externObj5.prototype.propWithAnnotatedStubAfter;"); - this.mode = TypeInferenceMode.OTI_ONLY; + this.mode = TypeInferenceMode.CHECKED; testSame( externs(externs), srcs("o.prototype.propWithAnnotatedStubAfter"), @@ -748,11 +748,11 @@ public void testReturnLocalityMultipleDefinitionsSameName() { } public void testExternCalls() throws Exception { - testExternCallsForTypeInferenceMode(TypeInferenceMode.BOTH); + testExternCallsForTypeInferenceMode(TypeInferenceMode.CHECKED); } public void testExternCallsNoTypeChecking() throws Exception { - testExternCallsForTypeInferenceMode(TypeInferenceMode.NEITHER); + testExternCallsForTypeInferenceMode(TypeInferenceMode.DISABLED); } private void testExternCallsForTypeInferenceMode(TypeInferenceMode typeInferenceMode) { @@ -919,7 +919,7 @@ public void testLocalizedSideEffects4() throws Exception { ImmutableList.of("f")); // TODO(bradfordcsmith): Remove NEITHER when type checker understands let/const - mode = TypeInferenceMode.NEITHER; + mode = TypeInferenceMode.DISABLED; assertPureCallsMarked( lines( "function f() {const x = []; x[0] = 1;}", // preserve newline @@ -950,7 +950,7 @@ public void testLocalizedSideEffects6() throws Exception { ImmutableList.of("f")); // TODO(bradfordcsmith): Remove NEITHER when type checker understands let/const - mode = TypeInferenceMode.NEITHER; + mode = TypeInferenceMode.DISABLED; assertPureCallsMarked( lines( "function f() {", // preserve newline @@ -973,7 +973,7 @@ public void testLocalizedSideEffects7() throws Exception { ImmutableList.of("f")); // TODO(bradfordcsmith): Remove NEITHER when type checker understands let/const - mode = TypeInferenceMode.NEITHER; + mode = TypeInferenceMode.DISABLED; assertPureCallsMarked( lines( "/** @constructor A */ function A() {};", @@ -1059,7 +1059,7 @@ public void testLocalizedSideEffects12() throws Exception { ImmutableList.of("f")); // TODO(bradfordcsmith): Remove NEITHER when type checker understands let/const - mode = TypeInferenceMode.NEITHER; + mode = TypeInferenceMode.DISABLED; assertPureCallsMarked( lines( "function f() {const x = []; { x[0] = 1; } }", // preserve newline @@ -1068,7 +1068,7 @@ public void testLocalizedSideEffects12() throws Exception { } public void testLocalizedSideEffects13() { - this.mode = TypeInferenceMode.NEITHER; + this.mode = TypeInferenceMode.DISABLED; String source = lines( "function f() {var [x, y] = [3, 4]; }", "f()"); @@ -1076,7 +1076,7 @@ public void testLocalizedSideEffects13() { } public void testLocalizedSideEffects14() { - this.mode = TypeInferenceMode.NEITHER; + this.mode = TypeInferenceMode.DISABLED; String source = lines( "function f() {var x; if (true) { [x] = [5]; } }", "f()"); @@ -1084,7 +1084,7 @@ public void testLocalizedSideEffects14() { } public void testLocalizedSideEffects15() { - this.mode = TypeInferenceMode.NEITHER; + this.mode = TypeInferenceMode.DISABLED; String source = lines( "function f() {var {length} = 'a string'; }", "f()"); @@ -1092,7 +1092,7 @@ public void testLocalizedSideEffects15() { } public void testLocalizedSideEffects16() { - this.mode = TypeInferenceMode.NEITHER; + this.mode = TypeInferenceMode.DISABLED; String source = lines( "function f(someArray) {var [a, , b] = someArray; }", "f()"); @@ -1100,7 +1100,7 @@ public void testLocalizedSideEffects16() { } public void testLocalizedSideEffects17() { - this.mode = TypeInferenceMode.NEITHER; + this.mode = TypeInferenceMode.DISABLED; String source = lines( "function f(someObj) {var { very: { nested: { lhs: pattern }} } = someObj; }", "f()"); @@ -1108,7 +1108,7 @@ public void testLocalizedSideEffects17() { } public void testLocalizedSideEffects18() { - this.mode = TypeInferenceMode.NEITHER; + this.mode = TypeInferenceMode.DISABLED; String source = lines( "function SomeCtor() { [this.x, this.y] = getCoordinates(); }", "new SomeCtor()"); @@ -1116,7 +1116,7 @@ public void testLocalizedSideEffects18() { } public void testLocalizedSideEffects19() { - this.mode = TypeInferenceMode.NEITHER; + this.mode = TypeInferenceMode.DISABLED; String source = lines( "function SomeCtor() { [this.x, this.y] = [0, 1]; }", "new SomeCtor()"); @@ -1124,7 +1124,7 @@ public void testLocalizedSideEffects19() { } public void testLocalizedSideEffects20() { - this.mode = TypeInferenceMode.NEITHER; + this.mode = TypeInferenceMode.DISABLED; String source = lines( "function SomeCtor() { this.x += 1; }", "new SomeCtor()"); @@ -1134,13 +1134,13 @@ public void testLocalizedSideEffects20() { public void testLocalizedSideEffects21() { // TODO(bradfordcsmith): Remove NEITHER when type checkers understand destructuring and // let/const. - this.mode = TypeInferenceMode.NEITHER; + this.mode = TypeInferenceMode.DISABLED; String source = lines("function f(values) { const x = {}; [x.y, x.z] = values; }", "f()"); assertPureCallsMarked(source, ImmutableList.of("f")); } public void testLocalizedSideEffects22() { - this.mode = TypeInferenceMode.NEITHER; + this.mode = TypeInferenceMode.DISABLED; String source = lines( "var x = {}; function f(values) { [x.y, x.z] = values; }", "f()"); @@ -1150,7 +1150,7 @@ public void testLocalizedSideEffects22() { public void testLocalizedSideEffects23() { // TODO(bradfordcsmith): Remove NEITHER when type checkers understand destructuring and // let/const. - this.mode = TypeInferenceMode.NEITHER; + this.mode = TypeInferenceMode.DISABLED; String source = lines( "function f(values) { const x = {}; [x.y, x.z = defaultNoSideEffects] = values; }", @@ -1159,7 +1159,7 @@ public void testLocalizedSideEffects23() { } public void testLocalizedSideEffects24() { - this.mode = TypeInferenceMode.NEITHER; + this.mode = TypeInferenceMode.DISABLED; String source = lines( "function f(values) { var x = {}; [x.y, x.z = defaultWithSideEffects()] = values; }", "f()"); @@ -1189,7 +1189,7 @@ public void testUnaryOperators3() throws Exception { ImmutableList.of("f")); // TODO(bradfordcsmith): Remove NEITHER when type checker understands let/const - mode = TypeInferenceMode.NEITHER; + mode = TypeInferenceMode.DISABLED; assertPureCallsMarked( lines( "function f() {const x = {foo : 0}; x.foo++}", // preserve newline @@ -1213,7 +1213,7 @@ public void testUnaryOperators5() throws Exception { ImmutableList.of("f")); // TODO(bradfordcsmith): Remove NEITHER when type checker understands destructured parameters - mode = TypeInferenceMode.NEITHER; + mode = TypeInferenceMode.DISABLED; assertPureCallsMarked( lines( "function f({x}) {x.foo++}", // preserve newline @@ -1513,7 +1513,7 @@ public void testAmbiguousDefinitionsMutatesLocalArgument() throws Exception { ImmutableList.of("C.a", "b")); // TODO(bradfordcsmith): Remove NEITHER when type checker understands destructuring parameters - mode = TypeInferenceMode.NEITHER; + mode = TypeInferenceMode.DISABLED; assertPureCallsMarked( lines( "// Mutates argument", @@ -1692,7 +1692,7 @@ public void testMutatesArguments1() throws Exception { ImmutableList.of("f")); // TODO(bradfordcsmith): Remove NEITHER when type checker understands destructuring parameters - mode = TypeInferenceMode.NEITHER; + mode = TypeInferenceMode.DISABLED; assertPureCallsMarked( lines( "function f([x]) { x.y = 1; }", // preserve newline @@ -1725,7 +1725,7 @@ public void testMutatesArguments4() throws Exception { ImmutableList.of("f", "g")); // TODO(bradfordcsmith): Remove NEITHER when type checker understands destructuring parameters - mode = TypeInferenceMode.NEITHER; + mode = TypeInferenceMode.DISABLED; assertPureCallsMarked( lines( "function f([x]) { x.y = 1; }", // preserve newline @@ -1769,7 +1769,7 @@ public void testMutatesArgumentsArray3() throws Exception { } public void testCallGenerator1() { - this.mode = TypeInferenceMode.NEITHER; // type check for yield not yet implemented + this.mode = TypeInferenceMode.DISABLED; // type check for yield not yet implemented String source = lines( "var x = 0;", @@ -1789,7 +1789,7 @@ public void testCallGenerator1() { } public void testCallGenerator2() { - this.mode = TypeInferenceMode.NEITHER; // type check for yield not yet implemented + this.mode = TypeInferenceMode.DISABLED; // type check for yield not yet implemented String source = lines( "function* f() {", " while (true) {", @@ -1902,19 +1902,19 @@ public void testAnonymousFunction4() throws Exception { } public void testClassMethod1() { - this.mode = TypeInferenceMode.NEITHER; + this.mode = TypeInferenceMode.DISABLED; String source = "class C { m() { alert(1); } }; (new C).m();"; assertNoPureCalls(source); } public void testClassMethod2() { - this.mode = TypeInferenceMode.NEITHER; + this.mode = TypeInferenceMode.DISABLED; String source = "class C { m() { } }; (new C).m();"; assertPureCallsMarked(source, ImmutableList.of("NEW STRING m")); } public void testClassMethod3() { - this.mode = TypeInferenceMode.NEITHER; + this.mode = TypeInferenceMode.DISABLED; String source = "class C { m1() { } m2() { this.m1(); }}; (new C).m2();"; assertPureCallsMarked(source, ImmutableList.of("this.m1", "NEW STRING m2")); } diff --git a/test/com/google/javascript/jscomp/RemoveUnusedCodeClassPropertiesTest.java b/test/com/google/javascript/jscomp/RemoveUnusedCodeClassPropertiesTest.java index e3e129a6e0e..921fe731416 100644 --- a/test/com/google/javascript/jscomp/RemoveUnusedCodeClassPropertiesTest.java +++ b/test/com/google/javascript/jscomp/RemoveUnusedCodeClassPropertiesTest.java @@ -79,8 +79,6 @@ public RemoveUnusedCodeClassPropertiesTest() { super(EXTERNS); } - @Override void checkMinimalExterns(Iterable externs) {} - @Override protected CompilerPass getProcessor(Compiler compiler) { return new RemoveUnusedCode.Builder(compiler) @@ -97,7 +95,7 @@ protected void setUp() throws Exception { enableNormalize(); enableGatherExternProperties(); setAcceptedLanguage(LanguageMode.ECMASCRIPT_2017); - this.mode = TypeInferenceMode.NEITHER; + this.mode = TypeInferenceMode.DISABLED; } public void testSimple1() { @@ -269,7 +267,7 @@ public void testPrototypeProps2() { } public void testConstructorProperty1() { - this.mode = TypeInferenceMode.BOTH; + this.mode = TypeInferenceMode.CHECKED; test( "/** @constructor */ function C() {} C.prop = 1;", @@ -277,7 +275,7 @@ public void testConstructorProperty1() { } public void testConstructorProperty2() { - this.mode = TypeInferenceMode.BOTH; + this.mode = TypeInferenceMode.CHECKED; testSame( lines( @@ -289,7 +287,7 @@ public void testConstructorProperty2() { public void testES6StaticProperty() { // TODO(bradfordcsmith): Neither type checker understands ES6 classes yet. - this.mode = TypeInferenceMode.NEITHER; + this.mode = TypeInferenceMode.DISABLED; test( "class C { static prop() {} }", // preserve newline @@ -297,14 +295,14 @@ public void testES6StaticProperty() { } public void testES6StaticProperty2() { - this.mode = TypeInferenceMode.NEITHER; + this.mode = TypeInferenceMode.DISABLED; // TODO(bradfordcsmith): When NTI understands ES6 classes it will allow removal of `C.prop = 1`. testSame("class C {} C.prop = 1;"); } public void testObjectDefineProperties1() { - this.mode = TypeInferenceMode.BOTH; + this.mode = TypeInferenceMode.CHECKED; testSame( lines( @@ -315,7 +313,7 @@ public void testObjectDefineProperties1() { } public void testObjectDefineProperties2() { - this.mode = TypeInferenceMode.BOTH; + this.mode = TypeInferenceMode.CHECKED; test( lines( @@ -327,7 +325,7 @@ public void testObjectDefineProperties2() { } public void testObjectDefineProperties3() { - this.mode = TypeInferenceMode.BOTH; + this.mode = TypeInferenceMode.CHECKED; test( lines( @@ -344,7 +342,7 @@ public void testObjectDefineProperties3() { // side-effect in definition retains property definition, but doesn't count as a reference public void testObjectDefineProperties4() { - this.mode = TypeInferenceMode.BOTH; + this.mode = TypeInferenceMode.CHECKED; test( lines( @@ -357,7 +355,7 @@ public void testObjectDefineProperties4() { // quoted properties retains property public void testObjectDefineProperties5() { - this.mode = TypeInferenceMode.BOTH; + this.mode = TypeInferenceMode.CHECKED; testSame( lines( @@ -366,7 +364,7 @@ public void testObjectDefineProperties5() { } public void testObjectDefineProperties6() { - this.mode = TypeInferenceMode.BOTH; + this.mode = TypeInferenceMode.CHECKED; // an unknown destination object doesn't prevent removal. test( @@ -375,7 +373,7 @@ public void testObjectDefineProperties6() { } public void testObjectDefineProperties7() { - this.mode = TypeInferenceMode.BOTH; + this.mode = TypeInferenceMode.CHECKED; test( lines( @@ -387,7 +385,7 @@ public void testObjectDefineProperties7() { } public void testObjectDefineProperties8() { - this.mode = TypeInferenceMode.BOTH; + this.mode = TypeInferenceMode.CHECKED; test( lines( @@ -399,7 +397,7 @@ public void testObjectDefineProperties8() { } public void testObjectDefinePropertiesQuotesPreventRemoval() { - this.mode = TypeInferenceMode.BOTH; + this.mode = TypeInferenceMode.CHECKED; testSame( lines( @@ -410,7 +408,7 @@ public void testObjectDefinePropertiesQuotesPreventRemoval() { public void testObjectDefineProperties_used_setter_removed() { // TODO(bradfordcsmith): Either remove, fix this, or document it as a limitation of advanced // mode optimizations. - this.mode = TypeInferenceMode.BOTH; + this.mode = TypeInferenceMode.CHECKED; test( lines( @@ -485,7 +483,7 @@ public void testEs6EnhancedObjLiteralsPropertyShorthand() { } public void testTranspiledEs6GettersRemoval() { - this.mode = TypeInferenceMode.BOTH; + this.mode = TypeInferenceMode.CHECKED; test( // This is the output of ES6->ES5 class getter converter. // See Es6ToEs3ConverterTest.testEs5GettersAndSettersClasses test method. @@ -510,7 +508,7 @@ public void testTranspiledEs6GettersRemoval() { } public void testTranspiledEs6SettersRemoval() { - this.mode = TypeInferenceMode.BOTH; + this.mode = TypeInferenceMode.CHECKED; test( // This is the output of ES6->ES5 class setter converter. // See Es6ToEs3ConverterTest.testEs5GettersAndSettersClasses test method. diff --git a/test/com/google/javascript/jscomp/RemoveUnusedCodeNameAnalyzerTest.java b/test/com/google/javascript/jscomp/RemoveUnusedCodeNameAnalyzerTest.java index 08f91681dd2..4c206ad0cee 100644 --- a/test/com/google/javascript/jscomp/RemoveUnusedCodeNameAnalyzerTest.java +++ b/test/com/google/javascript/jscomp/RemoveUnusedCodeNameAnalyzerTest.java @@ -24,7 +24,7 @@ * aka smartNamePass, which has now been removed. */ -public final class RemoveUnusedCodeNameAnalyzerTest extends TypeICompilerTestCase { +public final class RemoveUnusedCodeNameAnalyzerTest extends CompilerTestCase { private static final String EXTERNS = lines( @@ -73,7 +73,6 @@ protected CompilerPass getProcessor(Compiler compiler) { } private static class MarkNoSideEffectCallsAndRemoveUnusedCodeRunner implements CompilerPass { - VarCheck varCheck; MarkNoSideEffectCalls markNoSideEffectCalls; RemoveUnusedCode removeUnusedCode; @@ -106,8 +105,6 @@ protected void setUp() throws Exception { setAcceptedLanguage(LanguageMode.ECMASCRIPT_2017); enableNormalize(); enableGatherExternProperties(); - // Change this for the test cases that require type information. - this.mode = TypeInferenceMode.NEITHER; } public void testDefaultingAssignmentWithAssignedProperty() { diff --git a/test/com/google/javascript/jscomp/ReplaceCssNamesTest.java b/test/com/google/javascript/jscomp/ReplaceCssNamesTest.java index 9091f782271..da2d14587db 100644 --- a/test/com/google/javascript/jscomp/ReplaceCssNamesTest.java +++ b/test/com/google/javascript/jscomp/ReplaceCssNamesTest.java @@ -136,8 +136,7 @@ private void doNotUseReplacementMap() { assertThat(cssNames).isEqualTo(expected); } - public void testDoNotUseReplacementMapOti() { - this.mode = TypeInferenceMode.OTI_ONLY; + public void testDoNotUseReplacementMap() { doNotUseReplacementMap(); } @@ -172,8 +171,7 @@ private void oneArgWithSimpleStringLiterals() { assertThat(cssNames).isEqualTo(expected); } - public void testOneArgWithSimpleStringLiteralsOti() { - this.mode = TypeInferenceMode.OTI_ONLY; + public void testOneArgWithSimpleStringLiterals() { oneArgWithSimpleStringLiterals(); } @@ -196,8 +194,7 @@ private void oneArgWithCompositeClassNames() { assertThat(cssNames).isEqualTo(expected); } - public void testOneArgWithCompositeClassNamesOti() { - this.mode = TypeInferenceMode.OTI_ONLY; + public void testOneArgWithCompositeClassNames() { oneArgWithCompositeClassNames(); } diff --git a/test/com/google/javascript/jscomp/ReplaceStringsTest.java b/test/com/google/javascript/jscomp/ReplaceStringsTest.java index 11beea6119f..4dede320bad 100644 --- a/test/com/google/javascript/jscomp/ReplaceStringsTest.java +++ b/test/com/google/javascript/jscomp/ReplaceStringsTest.java @@ -91,7 +91,6 @@ protected CompilerOptions getOptions() { @Override protected void setUp() throws Exception { super.setUp(); - this.mode = TypeInferenceMode.BOTH; enableNormalize(); enableParseTypeInfo(); functionsToInspect = defaultFunctionsToInspect; @@ -382,9 +381,6 @@ public void testLoggerOnVar() { } public void testLoggerOnThis() { - // This fails in NTI because NTI doesn't specialize the type of THIS after the assignment; - // THIS remains unknown. Working as intended. - this.mode = TypeInferenceMode.OTI_ONLY; testDebugStrings( "function f() {" + " this.logger_ = goog.debug.Logger.getLogger('foo');" + diff --git a/test/com/google/javascript/jscomp/ScopedAliasesTest.java b/test/com/google/javascript/jscomp/ScopedAliasesTest.java index 68d566e1329..201e0714cb3 100644 --- a/test/com/google/javascript/jscomp/ScopedAliasesTest.java +++ b/test/com/google/javascript/jscomp/ScopedAliasesTest.java @@ -61,7 +61,7 @@ public ScopedAliasesTest() { @Override protected void setUp() throws Exception { super.setUp(); - this.mode = TypeInferenceMode.NEITHER; + this.mode = TypeInferenceMode.DISABLED; enableRunTypeCheckAfterProcessing(); } @@ -407,7 +407,7 @@ public void testObjectLiteralComputedPropertyNames() { } public void testJsDocNotIgnored() { - this.mode = TypeInferenceMode.BOTH; + this.mode = TypeInferenceMode.CHECKED; String externs = lines( @@ -432,8 +432,7 @@ public void testJsDocNotIgnored() { test( externs(externs), srcs(js), - warningOtiNti( - TypeValidator.TYPE_MISMATCH_WARNING, NewTypeInference.INVALID_ARGUMENT_TYPE)); + warning(TypeValidator.TYPE_MISMATCH_WARNING)); js = lines( @@ -447,8 +446,7 @@ public void testJsDocNotIgnored() { test( externs(externs), srcs(js), - warningOtiNti( - TypeValidator.TYPE_MISMATCH_WARNING, NewTypeInference.INVALID_ARGUMENT_TYPE)); + warning(TypeValidator.TYPE_MISMATCH_WARNING)); } public void testUsingObjectLiteralToEscapeScoping() { @@ -578,7 +576,7 @@ public void testJsDocTypedef() { } public void testJsDocRecord() { - this.mode = TypeInferenceMode.BOTH; + this.mode = TypeInferenceMode.CHECKED; test( lines( "/** @const */ var ns = {};", @@ -589,7 +587,7 @@ public void testJsDocRecord() { lines( "/** @const */ var ns = {};", "/** @type {{x: string}} */ ns.y = {'goog.Timer': 'x'};"), - warningOtiNti(TypeValidator.TYPE_MISMATCH_WARNING, NewTypeInference.MISTYPED_ASSIGN_RHS)); + warning(TypeValidator.TYPE_MISMATCH_WARNING)); } public void testArrayJsDoc() { @@ -704,7 +702,7 @@ public void testIssue772() { } public void testInlineJsDoc() { - this.mode = TypeInferenceMode.BOTH; + this.mode = TypeInferenceMode.CHECKED; test( srcs(lines( "/** @const */ var ns = {};", @@ -723,7 +721,7 @@ public void testInlineJsDoc() { } public void testInlineReturn() { - this.mode = TypeInferenceMode.BOTH; + this.mode = TypeInferenceMode.CHECKED; test( srcs(lines( "/** @const */ var ns = {};", @@ -744,7 +742,7 @@ public void testInlineReturn() { } public void testInlineParam() { - this.mode = TypeInferenceMode.BOTH; + this.mode = TypeInferenceMode.CHECKED; test( srcs(lines( "/** @const */ var ns = {};", @@ -1069,7 +1067,7 @@ public void testObjectPattern() { } public void testTypeCheck() { - this.mode = TypeInferenceMode.BOTH; + this.mode = TypeInferenceMode.CHECKED; test( lines( @@ -1082,8 +1080,7 @@ public void testTypeCheck() { "/** @return {$jscomp.scope.F} */", "$jscomp.scope.createFoo = /** @return {$jscomp.scope.F} */ function() { return 1; };", "/** @constructor */ $jscomp.scope.F = /** @constructor */ function() { };"), - warningOtiNti( - TypeValidator.TYPE_MISMATCH_WARNING, NewTypeInference.RETURN_NONDECLARED_TYPE)); + warning(TypeValidator.TYPE_MISMATCH_WARNING)); } // Alias Recording Tests diff --git a/test/com/google/javascript/jscomp/StrictModeCheckTest.java b/test/com/google/javascript/jscomp/StrictModeCheckTest.java index ca40c0bf4d2..bd230364659 100644 --- a/test/com/google/javascript/jscomp/StrictModeCheckTest.java +++ b/test/com/google/javascript/jscomp/StrictModeCheckTest.java @@ -29,7 +29,6 @@ public StrictModeCheckTest() { protected void setUp() throws Exception { super.setUp(); setAcceptedLanguage(LanguageMode.ECMASCRIPT_2017); - this.mode = TypeInferenceMode.OTI_ONLY; } @Override @@ -104,7 +103,7 @@ public void testUnknownVariable3() { } public void testUnknownVariable4() { - this.mode = TypeInferenceMode.NEITHER; + this.mode = TypeInferenceMode.DISABLED; testSameEs6Strict("function foo(a) { let b; a = b; }"); testSameEs6Strict("function foo(a) { const b = 42; a = b; }"); } @@ -132,7 +131,7 @@ public void testArguments5() { } public void testArguments6() { - this.mode = TypeInferenceMode.NEITHER; + this.mode = TypeInferenceMode.DISABLED; testSame("(() => arguments)();"); } @@ -179,7 +178,7 @@ public void testDeleteArgument() { public void testValidDelete() { testSame("var obj = { a: 0 }; delete obj.a;"); testSame("var obj = { a: function() {} }; delete obj.a;"); - this.mode = TypeInferenceMode.NEITHER; + this.mode = TypeInferenceMode.DISABLED; testSameEs6Strict("var obj = { a(){} }; delete obj.a;"); testSameEs6Strict("var obj = { a }; delete obj.a;"); } @@ -214,7 +213,7 @@ public void testDuplicateObjectLiteralKey() { " set appData(data) { this.appData_ = data; }", "};")); - this.mode = TypeInferenceMode.NEITHER; + this.mode = TypeInferenceMode.DISABLED; testError("var x = {a: 2, a(){}}", StrictModeCheck.DUPLICATE_OBJECT_KEY); testError("var x = {a, a(){}}", StrictModeCheck.DUPLICATE_OBJECT_KEY); testError("var x = {a(){}, a(){}}", StrictModeCheck.DUPLICATE_OBJECT_KEY); @@ -238,7 +237,7 @@ public void testFunctionDecl() { } public void testClass() { - this.mode = TypeInferenceMode.NEITHER; + this.mode = TypeInferenceMode.DISABLED; testSame( lines( "class A {", @@ -334,7 +333,7 @@ public void testClass() { } public void testComputedPropInClass() { - this.mode = TypeInferenceMode.NEITHER; + this.mode = TypeInferenceMode.DISABLED; testSame( lines( "class Example {", @@ -344,7 +343,7 @@ public void testComputedPropInClass() { } public void testStaticAndNonstaticMethodWithSameName() { - this.mode = TypeInferenceMode.NEITHER; + this.mode = TypeInferenceMode.DISABLED; testSame( lines( "class Example {", @@ -354,7 +353,7 @@ public void testStaticAndNonstaticMethodWithSameName() { } public void testStaticAndNonstaticGetterWithSameName() { - this.mode = TypeInferenceMode.NEITHER; + this.mode = TypeInferenceMode.DISABLED; testSame( lines( "class Example {", @@ -364,7 +363,7 @@ public void testStaticAndNonstaticGetterWithSameName() { } public void testStaticAndNonstaticSetterWithSameName() { - this.mode = TypeInferenceMode.NEITHER; + this.mode = TypeInferenceMode.DISABLED; testSame( lines( "class Example {", @@ -374,7 +373,7 @@ public void testStaticAndNonstaticSetterWithSameName() { } public void testClassWithEmptyMembers() { - this.mode = TypeInferenceMode.NEITHER; + this.mode = TypeInferenceMode.DISABLED; testError("class Foo { dup() {}; dup() {}; }", StrictModeCheck.DUPLICATE_CLASS_METHODS); } diff --git a/test/com/google/javascript/jscomp/TypeICompilerTestCase.java b/test/com/google/javascript/jscomp/TypeICompilerTestCase.java index a2c4e10b914..0b7605b7506 100644 --- a/test/com/google/javascript/jscomp/TypeICompilerTestCase.java +++ b/test/com/google/javascript/jscomp/TypeICompilerTestCase.java @@ -15,13 +15,11 @@ */ package com.google.javascript.jscomp; -import java.io.IOException; import java.util.List; import java.util.logging.Logger; /** * CompilerTestCase for passes that run after type checking and use type information. - * Allows us to test those passes with both type checkers. * * @author dimvar@google.com (Dimitris Vardoulakis) */ @@ -31,25 +29,19 @@ public abstract class TypeICompilerTestCase extends CompilerTestCase { Logger.getLogger("com.google.javascript.jscomp.TypeICompilerTestCase"); protected static enum TypeInferenceMode { - NEITHER, - OTI_ONLY, - NTI_ONLY, - BOTH; + DISABLED, + CHECKED; - boolean runsOTI() { - return this == OTI_ONLY || this == BOTH; + boolean runsTypeCheck() { + return this == CHECKED; } - boolean runsNTI() { - return this == NTI_ONLY || this == BOTH; - } - - boolean runsNeither() { - return this == NEITHER; + boolean runsWithoutTypeCheck() { + return this == DISABLED; } } - protected TypeInferenceMode mode = TypeInferenceMode.BOTH; + protected TypeInferenceMode mode = TypeInferenceMode.CHECKED; public TypeICompilerTestCase() { super(MINIMAL_EXTERNS); @@ -62,16 +54,9 @@ public TypeICompilerTestCase(String defaultExterns) { @Override protected void setUp() throws Exception { super.setUp(); - this.mode = TypeInferenceMode.BOTH; + this.mode = TypeInferenceMode.CHECKED; } - // NOTE(aravindpg): the idea with these selective overrides is that every `test` call - // in a subclass must go through one and exactly one of the overrides here, which are - // the ones that actually run the test twice (once under OTI and once under NTI). - // The `test` methods in CompilerTestCase overload each other in complicated ways, - // and this is the minimal set of overrides (of visible methods) that essentially - // "post-dominates" any `test` call. - @Override protected void testInternal( Externs externs, @@ -79,16 +64,13 @@ protected void testInternal( Expected expected, Diagnostic diagnostic, List postconditions) { - if (this.mode.runsOTI()) { - logger.info("Running with OTI"); - testOTI(externs, js, expected, diagnostic, postconditions); - } - if (this.mode.runsNTI()) { - logger.info("Running with NTI"); - checkMinimalExterns(externs.externs); - testNTI(externs, js, expected, diagnostic, postconditions); + if (this.mode.runsTypeCheck()) { + logger.info("Running with typechecking"); + enableTypeCheck(); + super.testInternal(externs, js, expected, diagnostic, postconditions); + disableTypeCheck(); } - if (this.mode.runsNeither()) { + if (this.mode.runsWithoutTypeCheck()) { logger.info("Running without typechecking"); super.testInternal(externs, js, expected, diagnostic, postconditions); } @@ -97,110 +79,13 @@ protected void testInternal( @Override protected void testExternChanges(String extern, String input, String expectedExtern, DiagnosticType... warnings) { - if (this.mode.runsOTI()) { + if (this.mode.runsTypeCheck()) { enableTypeCheck(); super.testExternChanges(extern, input, expectedExtern, warnings); disableTypeCheck(); } - if (this.mode.runsNTI()) { - enableNewTypeInference(); - super.testExternChanges(extern, input, expectedExtern, warnings); - disableNewTypeInference(); - } - if (this.mode.runsNeither()) { + if (this.mode.runsWithoutTypeCheck()) { super.testExternChanges(extern, input, expectedExtern, warnings); } } - - // Note: may be overridden to allow different externs if necessary. - void checkMinimalExterns(Iterable externs) { - try { - for (SourceFile extern : externs) { - if (extern.getCode().contains(MINIMAL_EXTERNS)) { - return; - } - } - } catch (IOException e) { - throw new RuntimeException(e); - } - fail("NTI reqires at least the MINIMAL_EXTERNS"); - } - - private void testOTI( - Externs externs, - Sources js, - Expected expected, - Diagnostic diagnostic, - List postconditions) { - TypeInferenceMode saved = this.mode; - this.mode = TypeInferenceMode.OTI_ONLY; - enableTypeCheck(); - Diagnostic oti = - diagnostic instanceof OtiNtiDiagnostic ? ((OtiNtiDiagnostic) diagnostic).oti : diagnostic; - super.testInternal(externs, js, expected, oti, postconditions); - disableTypeCheck(); - this.mode = saved; - } - - private void testNTI( - Externs externs, - Sources js, - Expected expected, - Diagnostic diagnostic, - List postconditions) { - /* - TypeInferenceMode saved = this.mode; - this.mode = TypeInferenceMode.NTI_ONLY; - enableNewTypeInference(); - Diagnostic nti = - diagnostic instanceof OtiNtiDiagnostic ? ((OtiNtiDiagnostic) diagnostic).nti : diagnostic; - super.testInternal(externs, js, expected, nti, postconditions); - disableNewTypeInference(); - this.mode = saved; - */ - } - - void testWarningOtiNti( - String js, DiagnosticType otiWarning, DiagnosticType ntiWarning) { - TypeInferenceMode saved = this.mode; - this.mode = TypeInferenceMode.OTI_ONLY; - testWarning(js, otiWarning); - /* - this.mode = TypeInferenceMode.NTI_ONLY; - testWarning(js, ntiWarning); - */ - this.mode = saved; - } - - @Override - protected Compiler getLastCompiler() { - switch (this.mode) { - case BOTH: - throw new AssertionError("getLastCompiler does not work correctly in BOTH mode."); - default: - return super.getLastCompiler(); - } - } - - // Helpers to test separate warnings/errors with OTI and NTI. - - protected static OtiNtiDiagnostic warningOtiNti(DiagnosticType oti, DiagnosticType nti) { - return new OtiNtiDiagnostic( - oti != null ? warning(oti) : null, nti != null ? warning(nti) : null); - } - - protected static OtiNtiDiagnostic diagnosticOtiNti(Diagnostic oti, Diagnostic nti) { - return new OtiNtiDiagnostic(oti, nti); - } - - protected static class OtiNtiDiagnostic extends Diagnostic { - private final Diagnostic oti; - private final Diagnostic nti; - - private OtiNtiDiagnostic(Diagnostic oti, Diagnostic nti) { - super(null, null, null); - this.oti = oti; - this.nti = nti; - } - } } diff --git a/test/com/google/javascript/jscomp/lint/CheckNullableReturnTest.java b/test/com/google/javascript/jscomp/lint/CheckNullableReturnTest.java index 506fe71c4d4..03946de3e94 100644 --- a/test/com/google/javascript/jscomp/lint/CheckNullableReturnTest.java +++ b/test/com/google/javascript/jscomp/lint/CheckNullableReturnTest.java @@ -75,9 +75,7 @@ public void testNullableReturn() { public void testNotNullableReturn() { // Empty function body. Ignore this case. The remainder of the functions in // this test have non-empty bodies. - this.mode = TypeInferenceMode.OTI_ONLY; testBodyOk(""); - this.mode = TypeInferenceMode.BOTH; // Simple case. testBodyError("return {};"); @@ -98,7 +96,6 @@ public void testFinallyStatements() { testBodyOk("try { } finally { return null; }"); testBodyOk("try { return {}; } finally { return null; }"); testBodyOk("try { return null; } finally { return {}; }"); - this.mode = TypeInferenceMode.OTI_ONLY; testBodyError("try { } catch (e) { return null; } finally { return {}; }"); } @@ -124,7 +121,6 @@ public void testKnownWhileLoop() { testBodyError("while (0) {} return {}"); // Not known. - this.mode = TypeInferenceMode.OTI_ONLY; testBodyError("while(x) { return {}; }"); } @@ -189,7 +185,6 @@ public void testTryCatch() { } public void testNoExplicitReturn() { - this.mode = TypeInferenceMode.OTI_ONLY; testError(lines( "/** @return {SomeType} */", "function f() {", @@ -212,7 +207,6 @@ public void testNoWarningIfCanReturnNull() { } public void testNoWarningOnEmptyFunction() { - this.mode = TypeInferenceMode.OTI_ONLY; testOk(lines( "/** @return {SomeType} */", "function f() {}"));