Remove dart2jsHint option, verifier, and tests.
R=brianwilkerson@google.com, devoncarew@google.com
Change-Id: I95b88940c862d463af03e85fcdf0f4bf81c2fbd5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/157641
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
diff --git a/pkg/analysis_server/lib/src/domain_analysis.dart b/pkg/analysis_server/lib/src/domain_analysis.dart
index 1612bb1..b237a10 100644
--- a/pkg/analysis_server/lib/src/domain_analysis.dart
+++ b/pkg/analysis_server/lib/src/domain_analysis.dart
@@ -443,11 +443,6 @@
var params = AnalysisUpdateOptionsParams.fromRequest(request);
var newOptions = params.options;
var updaters = <OptionUpdater>[];
- if (newOptions.generateDart2jsHints != null) {
- updaters.add((engine.AnalysisOptionsImpl options) {
- options.dart2jsHint = newOptions.generateDart2jsHints;
- });
- }
if (newOptions.generateHints != null) {
updaters.add((engine.AnalysisOptionsImpl options) {
options.hint = newOptions.generateHints;
diff --git a/pkg/analysis_server/lib/src/status/diagnostics.dart b/pkg/analysis_server/lib/src/status/diagnostics.dart
index de1b34ac..6c165e4 100644
--- a/pkg/analysis_server/lib/src/status/diagnostics.dart
+++ b/pkg/analysis_server/lib/src/status/diagnostics.dart
@@ -446,7 +446,6 @@
b.write(writeOption('Feature set', options.contextFeatures.toString()));
b.write('<br>');
- b.write(writeOption('Generate dart2js hints', options.dart2jsHint));
b.write(writeOption('Generate hints', options.hint));
return b.toString();
diff --git a/pkg/analyzer/lib/error/error.dart b/pkg/analyzer/lib/error/error.dart
index a0780e0..cdcfeb7 100644
--- a/pkg/analyzer/lib/error/error.dart
+++ b/pkg/analyzer/lib/error/error.dart
@@ -509,10 +509,6 @@
HintCode.INVALID_USE_OF_VISIBLE_FOR_TEMPLATE_MEMBER,
HintCode.INVALID_USE_OF_VISIBLE_FOR_TESTING_MEMBER,
HintCode.INVALID_VISIBILITY_ANNOTATION,
- HintCode.IS_DOUBLE,
- HintCode.IS_INT,
- HintCode.IS_NOT_DOUBLE,
- HintCode.IS_NOT_INT,
HintCode.MISSING_JS_LIB_ANNOTATION,
HintCode.MISSING_REQUIRED_PARAM,
HintCode.MISSING_REQUIRED_PARAM_WITH_DETAILS,
diff --git a/pkg/analyzer/lib/src/dart/analysis/library_analyzer.dart b/pkg/analyzer/lib/src/dart/analysis/library_analyzer.dart
index a60d615..1e14234 100644
--- a/pkg/analyzer/lib/src/dart/analysis/library_analyzer.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/library_analyzer.dart
@@ -26,7 +26,6 @@
import 'package:analyzer/src/dart/resolver/resolution_visitor.dart';
import 'package:analyzer/src/error/best_practices_verifier.dart';
import 'package:analyzer/src/error/codes.dart';
-import 'package:analyzer/src/error/dart2js_verifier.dart';
import 'package:analyzer/src/error/dead_code_verifier.dart';
import 'package:analyzer/src/error/imports_verifier.dart';
import 'package:analyzer/src/error/inheritance_override.dart';
@@ -272,11 +271,6 @@
unit.accept(DeadCodeVerifier(errorReporter));
- // Dart2js analysis.
- if (_analysisOptions.dart2jsHint) {
- unit.accept(Dart2JSVerifier(errorReporter));
- }
-
unit.accept(
BestPracticesVerifier(
errorReporter,
diff --git a/pkg/analyzer/lib/src/dart/error/hint_codes.dart b/pkg/analyzer/lib/src/dart/error/hint_codes.dart
index 9645945..70cc4ba 100644
--- a/pkg/analyzer/lib/src/dart/error/hint_codes.dart
+++ b/pkg/analyzer/lib/src/dart/error/hint_codes.dart
@@ -995,46 +995,6 @@
hasPublishedDocs: true);
/**
- * Hint for the `x is double` type checks.
- */
- static const HintCode IS_DOUBLE = HintCode(
- 'IS_DOUBLE',
- "When compiled to JS, this test might return true when the left hand "
- "side is an int.",
- correction: "Try testing for 'num' instead.");
-
- /**
- * Hint for the `x is int` type checks.
- */
- // TODO(brianwilkerson) This hint isn't being generated. Decide whether to
- // generate it or remove it.
- static const HintCode IS_INT = HintCode(
- 'IS_INT',
- "When compiled to JS, this test might return true when the left hand "
- "side is a double.",
- correction: "Try testing for 'num' instead.");
-
- /**
- * Hint for the `x is! double` type checks.
- */
- static const HintCode IS_NOT_DOUBLE = HintCode(
- 'IS_NOT_DOUBLE',
- "When compiled to JS, this test might return false when the left hand "
- "side is an int.",
- correction: "Try testing for 'num' instead.");
-
- /**
- * Hint for the `x is! int` type checks.
- */
- // TODO(brianwilkerson) This hint isn't being generated. Decide whether to
- // generate it or remove it.
- static const HintCode IS_NOT_INT = HintCode(
- 'IS_NOT_INT',
- "When compiled to JS, this test might return false when the left hand "
- "side is a double.",
- correction: "Try testing for 'num' instead.");
-
- /**
* Generate a hint for an element that is annotated with `@JS(...)` whose
* library declaration is not similarly annotated.
*/
diff --git a/pkg/analyzer/lib/src/dart/micro/library_analyzer.dart b/pkg/analyzer/lib/src/dart/micro/library_analyzer.dart
index a029dc9..5e5d888 100644
--- a/pkg/analyzer/lib/src/dart/micro/library_analyzer.dart
+++ b/pkg/analyzer/lib/src/dart/micro/library_analyzer.dart
@@ -26,7 +26,6 @@
import 'package:analyzer/src/dart/resolver/resolution_visitor.dart';
import 'package:analyzer/src/error/best_practices_verifier.dart';
import 'package:analyzer/src/error/codes.dart';
-import 'package:analyzer/src/error/dart2js_verifier.dart';
import 'package:analyzer/src/error/dead_code_verifier.dart';
import 'package:analyzer/src/error/imports_verifier.dart';
import 'package:analyzer/src/error/inheritance_override.dart';
@@ -266,11 +265,6 @@
unit.accept(DeadCodeVerifier(errorReporter));
- // Dart2js analysis.
- if (_analysisOptions.dart2jsHint) {
- unit.accept(Dart2JSVerifier(errorReporter));
- }
-
var content = getFileContent(file);
unit.accept(
BestPracticesVerifier(
diff --git a/pkg/analyzer/lib/src/error/dart2js_verifier.dart b/pkg/analyzer/lib/src/error/dart2js_verifier.dart
deleted file mode 100644
index 78d8f86..0000000
--- a/pkg/analyzer/lib/src/error/dart2js_verifier.dart
+++ /dev/null
@@ -1,70 +0,0 @@
-// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-import 'package:analyzer/dart/ast/ast.dart';
-import 'package:analyzer/dart/ast/visitor.dart';
-import 'package:analyzer/dart/element/element.dart';
-import 'package:analyzer/dart/element/type.dart';
-import 'package:analyzer/error/listener.dart';
-import 'package:analyzer/src/error/codes.dart';
-
-/// Instances of the class `Dart2JSVerifier` traverse an AST structure looking
-/// for hints for code that will be compiled to JS, such as
-/// [HintCode.IS_DOUBLE].
-class Dart2JSVerifier extends RecursiveAstVisitor<void> {
- /// The name of the `double` type.
- static const String _DOUBLE_TYPE_NAME = "double";
-
- /// The error reporter by which errors will be reported.
- final ErrorReporter _errorReporter;
-
- /// Create a new instance of the [Dart2JSVerifier].
- ///
- /// @param errorReporter the error reporter
- Dart2JSVerifier(this._errorReporter);
-
- @override
- void visitIsExpression(IsExpression node) {
- _checkForIsDoubleHints(node);
- super.visitIsExpression(node);
- }
-
- /// Check for instances of `x is double`, `x is int`, `x is! double` and
- /// `x is! int`.
- ///
- /// @param node the is expression to check
- /// @return `true` if and only if a hint code is generated on the passed node
- /// See [HintCode.IS_DOUBLE],
- /// [HintCode.IS_INT],
- /// [HintCode.IS_NOT_DOUBLE], and
- /// [HintCode.IS_NOT_INT].
- bool _checkForIsDoubleHints(IsExpression node) {
- DartType type = node.type.type;
- Element element = type?.element;
- if (element != null) {
- String typeNameStr = element.name;
- LibraryElement libraryElement = element.library;
- // if (typeNameStr.equals(INT_TYPE_NAME) && libraryElement != null
- // && libraryElement.isDartCore()) {
- // if (node.getNotOperator() == null) {
- // errorReporter.reportError(HintCode.IS_INT, node);
- // } else {
- // errorReporter.reportError(HintCode.IS_NOT_INT, node);
- // }
- // return true;
- // } else
- if (typeNameStr == _DOUBLE_TYPE_NAME &&
- libraryElement != null &&
- libraryElement.isDartCore) {
- if (node.notOperator == null) {
- _errorReporter.reportErrorForNode(HintCode.IS_DOUBLE, node);
- } else {
- _errorReporter.reportErrorForNode(HintCode.IS_NOT_DOUBLE, node);
- }
- return true;
- }
- }
- return false;
- }
-}
diff --git a/pkg/analyzer/lib/src/generated/engine.dart b/pkg/analyzer/lib/src/generated/engine.dart
index 387f3d4..7907567 100644
--- a/pkg/analyzer/lib/src/generated/engine.dart
+++ b/pkg/analyzer/lib/src/generated/engine.dart
@@ -235,9 +235,6 @@
/// The set of features that are globally enabled for this context.
FeatureSet get contextFeatures;
- /// Return `true` if analysis is to generate dart2js related hint results.
- bool get dart2jsHint;
-
/// Return `true` if cache flushing should be disabled. Setting this option to
/// `true` can improve analysis speed at the expense of memory usage. It may
/// also be useful for working around bugs.
@@ -429,9 +426,6 @@
@deprecated
int cacheSize = 64;
- @override
- bool dart2jsHint = false;
-
ExperimentStatus _contextFeatures = ExperimentStatus();
/// The set of features to use for libraries that are not in a package.
@@ -535,7 +529,6 @@
AnalysisOptionsImpl.from(AnalysisOptions options) {
// ignore: deprecated_member_use_from_same_package
analyzeFunctionBodiesPredicate = options.analyzeFunctionBodiesPredicate;
- dart2jsHint = options.dart2jsHint;
contextFeatures = options.contextFeatures;
enabledPluginNames = options.enabledPluginNames;
// ignore: deprecated_member_use_from_same_package
@@ -832,7 +825,6 @@
@override
void resetToDefaults() {
contextFeatures = ExperimentStatus();
- dart2jsHint = false;
disableCacheFlushing = false;
enabledPluginNames = const <String>[];
enableLazyAssignmentOperators = false;
diff --git a/pkg/analyzer/test/src/context/builder_test.dart b/pkg/analyzer/test/src/context/builder_test.dart
index 214bf41..73e1ad7 100644
--- a/pkg/analyzer/test/src/context/builder_test.dart
+++ b/pkg/analyzer/test/src/context/builder_test.dart
@@ -214,7 +214,7 @@
// Invert a subset of the options to ensure that the default options are
// being returned.
AnalysisOptionsImpl defaultOptions = AnalysisOptionsImpl();
- defaultOptions.dart2jsHint = !defaultOptions.dart2jsHint;
+ defaultOptions.implicitCasts = !defaultOptions.implicitCasts;
builderOptions.defaultOptions = defaultOptions;
AnalysisOptions options = builder.createDefaultOptions();
_expectEqualOptions(options, defaultOptions);
@@ -759,7 +759,6 @@
void _expectEqualOptions(
AnalysisOptionsImpl actual, AnalysisOptionsImpl expected) {
// TODO(brianwilkerson) Consider moving this to AnalysisOptionsImpl.==.
- expect(actual.dart2jsHint, expected.dart2jsHint);
expect(actual.enableTiming, expected.enableTiming);
expect(actual.hint, expected.hint);
expect(actual.lint, expected.lint);
diff --git a/pkg/analyzer/test/src/diagnostics/is_double_test.dart b/pkg/analyzer/test/src/diagnostics/is_double_test.dart
deleted file mode 100644
index 5192cab..0000000
--- a/pkg/analyzer/test/src/diagnostics/is_double_test.dart
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-import 'package:analyzer/src/dart/error/hint_codes.dart';
-import 'package:analyzer/src/generated/engine.dart';
-import 'package:test_reflective_loader/test_reflective_loader.dart';
-
-import '../dart/resolution/driver_resolution.dart';
-
-main() {
- defineReflectiveSuite(() {
- defineReflectiveTests(IsDoubleTest);
- });
-}
-
-@reflectiveTest
-class IsDoubleTest extends DriverResolutionTest {
- @override
- AnalysisOptionsImpl get analysisOptions =>
- AnalysisOptionsImpl()..dart2jsHint = true;
-
- test_use() async {
- await assertErrorsInCode('''
-var v = 1 is double;
-''', [
- error(HintCode.IS_DOUBLE, 8, 11),
- ]);
- }
-}
diff --git a/pkg/analyzer/test/src/diagnostics/is_int_test.dart b/pkg/analyzer/test/src/diagnostics/is_int_test.dart
deleted file mode 100644
index c9d5083..0000000
--- a/pkg/analyzer/test/src/diagnostics/is_int_test.dart
+++ /dev/null
@@ -1,31 +0,0 @@
-// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-import 'package:analyzer/src/dart/error/hint_codes.dart';
-import 'package:analyzer/src/generated/engine.dart';
-import 'package:test_reflective_loader/test_reflective_loader.dart';
-
-import '../dart/resolution/driver_resolution.dart';
-
-main() {
- defineReflectiveSuite(() {
- defineReflectiveTests(IsIntTest);
- });
-}
-
-@reflectiveTest
-class IsIntTest extends DriverResolutionTest {
- @override
- AnalysisOptionsImpl get analysisOptions =>
- AnalysisOptionsImpl()..dart2jsHint = true;
-
- @failingTest
- test_use() async {
- await assertErrorsInCode('''
-var v = 1 is int;
-''', [
- error(HintCode.IS_INT, 8, 8),
- ]);
- }
-}
diff --git a/pkg/analyzer/test/src/diagnostics/is_not_double_test.dart b/pkg/analyzer/test/src/diagnostics/is_not_double_test.dart
deleted file mode 100644
index 0a100593..0000000
--- a/pkg/analyzer/test/src/diagnostics/is_not_double_test.dart
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-import 'package:analyzer/src/dart/error/hint_codes.dart';
-import 'package:analyzer/src/generated/engine.dart';
-import 'package:test_reflective_loader/test_reflective_loader.dart';
-
-import '../dart/resolution/driver_resolution.dart';
-
-main() {
- defineReflectiveSuite(() {
- defineReflectiveTests(IsNotDoubleTest);
- });
-}
-
-@reflectiveTest
-class IsNotDoubleTest extends DriverResolutionTest {
- @override
- AnalysisOptionsImpl get analysisOptions =>
- AnalysisOptionsImpl()..dart2jsHint = true;
-
- test_use() async {
- await assertErrorsInCode('''
-var v = 1 is! double;
-''', [
- error(HintCode.IS_NOT_DOUBLE, 8, 12),
- ]);
- }
-}
diff --git a/pkg/analyzer/test/src/diagnostics/is_not_int_test.dart b/pkg/analyzer/test/src/diagnostics/is_not_int_test.dart
deleted file mode 100644
index 31f6d6f..0000000
--- a/pkg/analyzer/test/src/diagnostics/is_not_int_test.dart
+++ /dev/null
@@ -1,31 +0,0 @@
-// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-import 'package:analyzer/src/dart/error/hint_codes.dart';
-import 'package:analyzer/src/generated/engine.dart';
-import 'package:test_reflective_loader/test_reflective_loader.dart';
-
-import '../dart/resolution/driver_resolution.dart';
-
-main() {
- defineReflectiveSuite(() {
- defineReflectiveTests(IsNotIntTest);
- });
-}
-
-@reflectiveTest
-class IsNotIntTest extends DriverResolutionTest {
- @override
- AnalysisOptionsImpl get analysisOptions =>
- AnalysisOptionsImpl()..dart2jsHint = true;
-
- @failingTest
- test_use() async {
- await assertErrorsInCode('''
-var v = 1 is! int;
-''', [
- error(HintCode.IS_NOT_INT, 8, 9),
- ]);
- }
-}
diff --git a/pkg/analyzer/test/src/diagnostics/test_all.dart b/pkg/analyzer/test/src/diagnostics/test_all.dart
index c166314..1f0b6d6 100644
--- a/pkg/analyzer/test/src/diagnostics/test_all.dart
+++ b/pkg/analyzer/test/src/diagnostics/test_all.dart
@@ -324,10 +324,6 @@
as invocation_of_extension_without_call;
import 'invocation_of_non_function_expression_test.dart'
as invocation_of_non_function_expression;
-import 'is_double_test.dart' as is_double;
-import 'is_int_test.dart' as is_int;
-import 'is_not_double_test.dart' as is_not_double;
-import 'is_not_int_test.dart' as is_not_int;
import 'label_in_outer_scope_test.dart' as label_in_outer_scope;
import 'label_undefined_test.dart' as label_undefined;
import 'late_final_field_with_const_constructor_test.dart'
@@ -844,10 +840,6 @@
invalid_visibility_annotation.main();
invocation_of_extension_without_call.main();
invocation_of_non_function_expression.main();
- is_double.main();
- is_int.main();
- is_not_double.main();
- is_not_int.main();
label_in_outer_scope.main();
label_undefined.main();
late_final_field_with_const_constructor.main();