Version 2.14.0-262.0.dev
Merge commit 'c019575d48ed052a03758aa8d1e57beacdf000b7' into 'dev'
diff --git a/pkg/analysis_server/test/src/services/correction/fix/bulk/create_method_test.dart b/pkg/analysis_server/test/src/services/correction/fix/bulk/create_method_test.dart
deleted file mode 100644
index cf17881..0000000
--- a/pkg/analysis_server/test/src/services/correction/fix/bulk/create_method_test.dart
+++ /dev/null
@@ -1,56 +0,0 @@
-// Copyright (c) 2020, 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:analysis_server/src/services/linter/lint_names.dart';
-import 'package:test_reflective_loader/test_reflective_loader.dart';
-
-import 'bulk_fix_processor.dart';
-
-void main() {
- defineReflectiveSuite(() {
- defineReflectiveTests(AddMissingHashOrEqualsTest);
- });
-}
-
-@reflectiveTest
-class AddMissingHashOrEqualsTest extends BulkFixProcessorTest {
- @override
- String get lintCode => LintNames.hash_and_equals;
-
- Future<void> test_singleFile() async {
- await resolveTestCode('''
-class C {
- @override
- int get hashCode => 13;
-}
-
-class D {
- @override
- bool operator ==(Object other) => false;
-}
-''');
- await assertHasFix('''
-class C {
- @override
- int get hashCode => 13;
-
- @override
- bool operator ==(Object other) {
- // TODO: implement ==
- return super == other;
- }
-}
-
-class D {
- @override
- bool operator ==(Object other) => false;
-
- @override
- // TODO: implement hashCode
- int get hashCode => super.hashCode;
-
-}
-''');
- }
-}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/bulk/inline_invocation_test.dart b/pkg/analysis_server/test/src/services/correction/fix/bulk/inline_invocation_test.dart
deleted file mode 100644
index b34d124..0000000
--- a/pkg/analysis_server/test/src/services/correction/fix/bulk/inline_invocation_test.dart
+++ /dev/null
@@ -1,33 +0,0 @@
-// Copyright (c) 2020, 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:analysis_server/src/services/linter/lint_names.dart';
-import 'package:test_reflective_loader/test_reflective_loader.dart';
-
-import 'bulk_fix_processor.dart';
-
-void main() {
- defineReflectiveSuite(() {
- defineReflectiveTests(InlineInvocationTest);
- });
-}
-
-@reflectiveTest
-class InlineInvocationTest extends BulkFixProcessorTest {
- @override
- String get lintCode => LintNames.prefer_inlined_adds;
-
- Future<void> test_singleFile() async {
- await resolveTestCode('''
-var l = []..add('a')..add('b');
-var l2 = ['a', 'b']..add('c');
-var l3 = ['a']..addAll(['b', 'c']);
-''');
- await assertHasFix('''
-var l = ['a']..add('b');
-var l2 = ['a', 'b', 'c'];
-var l3 = ['a', 'b', 'c'];
-''');
- }
-}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/bulk/inline_typedef_test.dart b/pkg/analysis_server/test/src/services/correction/fix/bulk/inline_typedef_test.dart
deleted file mode 100644
index c2612f9..0000000
--- a/pkg/analysis_server/test/src/services/correction/fix/bulk/inline_typedef_test.dart
+++ /dev/null
@@ -1,34 +0,0 @@
-// Copyright (c) 2021, 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:analysis_server/src/services/linter/lint_names.dart';
-import 'package:test_reflective_loader/test_reflective_loader.dart';
-
-import 'bulk_fix_processor.dart';
-
-void main() {
- defineReflectiveSuite(() {
- defineReflectiveTests(InlineTypedefTest);
- });
-}
-
-@reflectiveTest
-class InlineTypedefTest extends BulkFixProcessorTest {
- @override
- String get lintCode => LintNames.avoid_private_typedef_functions;
-
- Future<void> test_singleFile() async {
- await resolveTestCode('''
-typedef _F1 = void Function(int);
-typedef _F2<T> = void Function(T);
-void g(_F2<_F1> f) {}
-''');
- // Eventually both fixes will be applied but for now we're satisfied that
- // the results are clean.
- await assertHasFix('''
-typedef _F2<T> = void Function(T);
-void g(_F2<void Function(int)> f) {}
-''');
- }
-}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/bulk/make_final_test.dart b/pkg/analysis_server/test/src/services/correction/fix/bulk/make_final_test.dart
deleted file mode 100644
index 21724f2..0000000
--- a/pkg/analysis_server/test/src/services/correction/fix/bulk/make_final_test.dart
+++ /dev/null
@@ -1,61 +0,0 @@
-// Copyright (c) 2020, 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:analysis_server/src/services/linter/lint_names.dart';
-import 'package:test_reflective_loader/test_reflective_loader.dart';
-
-import 'bulk_fix_processor.dart';
-
-void main() {
- defineReflectiveSuite(() {
- defineReflectiveTests(PreferFinalFieldsTest);
- defineReflectiveTests(PreferFinalLocalsTest);
- });
-}
-
-@reflectiveTest
-class PreferFinalFieldsTest extends BulkFixProcessorTest {
- @override
- String get lintCode => LintNames.prefer_final_fields;
-
- Future<void> test_singleFile() async {
- await resolveTestCode('''
-class C {
- int _f = 2;
- var _f2 = 2;
- int get g => _f;
- int get g2 => _f2;
-}
-''');
- await assertHasFix('''
-class C {
- final int _f = 2;
- final _f2 = 2;
- int get g => _f;
- int get g2 => _f2;
-}
-''');
- }
-}
-
-@reflectiveTest
-class PreferFinalLocalsTest extends BulkFixProcessorTest {
- @override
- String get lintCode => LintNames.prefer_final_locals;
-
- Future<void> test_singleFile() async {
- await resolveTestCode('''
-f() {
- var x = 0;
- var y = x;
-}
-''');
- await assertHasFix('''
-f() {
- final x = 0;
- final y = x;
-}
-''');
- }
-}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/bulk/remove_argument_test.dart b/pkg/analysis_server/test/src/services/correction/fix/bulk/remove_argument_test.dart
deleted file mode 100644
index 7d87ea4..0000000
--- a/pkg/analysis_server/test/src/services/correction/fix/bulk/remove_argument_test.dart
+++ /dev/null
@@ -1,41 +0,0 @@
-// Copyright (c) 2020, 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:analysis_server/src/services/linter/lint_names.dart';
-import 'package:test_reflective_loader/test_reflective_loader.dart';
-
-import 'bulk_fix_processor.dart';
-
-void main() {
- defineReflectiveSuite(() {
- defineReflectiveTests(RemoveArgumentTest);
- });
-}
-
-@reflectiveTest
-class RemoveArgumentTest extends BulkFixProcessorTest {
- @override
- String get lintCode => LintNames.avoid_redundant_argument_values;
-
- Future<void> test_singleFile() async {
- await resolveTestCode('''
-void f({bool valWithDefault = true, bool val}) {}
-void f2({bool valWithDefault = true, bool val}) {}
-
-void main() {
- f(valWithDefault: true);
- f2(valWithDefault: true, val: false);
-}
-''');
- await assertHasFix('''
-void f({bool valWithDefault = true, bool val}) {}
-void f2({bool valWithDefault = true, bool val}) {}
-
-void main() {
- f();
- f2(val: false);
-}
-''');
- }
-}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/bulk/remove_await_test.dart b/pkg/analysis_server/test/src/services/correction/fix/bulk/remove_await_test.dart
deleted file mode 100644
index b1c9f97..0000000
--- a/pkg/analysis_server/test/src/services/correction/fix/bulk/remove_await_test.dart
+++ /dev/null
@@ -1,41 +0,0 @@
-// Copyright (c) 2020, 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:analysis_server/src/services/linter/lint_names.dart';
-import 'package:test_reflective_loader/test_reflective_loader.dart';
-
-import 'bulk_fix_processor.dart';
-
-void main() {
- defineReflectiveSuite(() {
- defineReflectiveTests(RemoveAwaitTest);
- });
-}
-
-@reflectiveTest
-class RemoveAwaitTest extends BulkFixProcessorTest {
- @override
- String get lintCode => LintNames.await_only_futures;
-
- Future<void> test_singleFile() async {
- await resolveTestCode('''
-f() async {
- print(await 23);
-}
-
-f2() async {
- print(await 'hola');
-}
-''');
- await assertHasFix('''
-f() async {
- print(23);
-}
-
-f2() async {
- print('hola');
-}
-''');
- }
-}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/bulk/remove_duplicate_case_test.dart b/pkg/analysis_server/test/src/services/correction/fix/bulk/remove_duplicate_case_test.dart
deleted file mode 100644
index 76d7a91..0000000
--- a/pkg/analysis_server/test/src/services/correction/fix/bulk/remove_duplicate_case_test.dart
+++ /dev/null
@@ -1,51 +0,0 @@
-// Copyright (c) 2020, 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:analysis_server/src/services/linter/lint_names.dart';
-import 'package:test_reflective_loader/test_reflective_loader.dart';
-
-import 'bulk_fix_processor.dart';
-
-void main() {
- defineReflectiveSuite(() {
- defineReflectiveTests(RemoveDuplicateCaseTest);
- });
-}
-
-@reflectiveTest
-class RemoveDuplicateCaseTest extends BulkFixProcessorTest {
- @override
- String get lintCode => LintNames.no_duplicate_case_values;
-
- Future<void> test_singleFile() async {
- await resolveTestCode('''
-void switchInt() {
- switch (2) {
- case 1:
- print('a');
- break;
- case 2:
- case 2:
- case 3:
- case 3:
- default:
- print('?');
- }
-}
-''');
- await assertHasFix('''
-void switchInt() {
- switch (2) {
- case 1:
- print('a');
- break;
- case 2:
- case 3:
- default:
- print('?');
- }
-}
-''');
- }
-}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/bulk/remove_empty_catch_test.dart b/pkg/analysis_server/test/src/services/correction/fix/bulk/remove_empty_catch_test.dart
deleted file mode 100644
index a6a0897d..0000000
--- a/pkg/analysis_server/test/src/services/correction/fix/bulk/remove_empty_catch_test.dart
+++ /dev/null
@@ -1,49 +0,0 @@
-// Copyright (c) 2020, 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:analysis_server/src/services/linter/lint_names.dart';
-import 'package:test_reflective_loader/test_reflective_loader.dart';
-
-import 'bulk_fix_processor.dart';
-
-void main() {
- defineReflectiveSuite(() {
- defineReflectiveTests(RemoveEmptyCatchTest);
- });
-}
-
-@reflectiveTest
-class RemoveEmptyCatchTest extends BulkFixProcessorTest {
- @override
- String get lintCode => LintNames.empty_catches;
-
- Future<void> test_singleFile() async {
- await resolveTestCode('''
-void f() {
- try {
- try {
- 1;
- } catch (e) {} finally {}
- } catch (e) {} finally {}
-}
-
-void f2() {
- try {} catch (e) {} finally {}
-}
-''');
- await assertHasFix('''
-void f() {
- try {
- try {
- 1;
- } finally {}
- } finally {}
-}
-
-void f2() {
- try {} finally {}
-}
-''');
- }
-}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/bulk/remove_empty_constructor_body_test.dart b/pkg/analysis_server/test/src/services/correction/fix/bulk/remove_empty_constructor_body_test.dart
deleted file mode 100644
index 9469973..0000000
--- a/pkg/analysis_server/test/src/services/correction/fix/bulk/remove_empty_constructor_body_test.dart
+++ /dev/null
@@ -1,41 +0,0 @@
-// Copyright (c) 2020, 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:analysis_server/src/services/linter/lint_names.dart';
-import 'package:test_reflective_loader/test_reflective_loader.dart';
-
-import 'bulk_fix_processor.dart';
-
-void main() {
- defineReflectiveSuite(() {
- defineReflectiveTests(RemoveEmptyConstructorBodyTest);
- });
-}
-
-@reflectiveTest
-class RemoveEmptyConstructorBodyTest extends BulkFixProcessorTest {
- @override
- String get lintCode => LintNames.empty_constructor_bodies;
-
- Future<void> test_singleFile() async {
- await resolveTestCode('''
-class C {
- C() {}
-}
-
-class D {
- D() {}
-}
-''');
- await assertHasFix('''
-class C {
- C();
-}
-
-class D {
- D();
-}
-''');
- }
-}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/bulk/remove_empty_else_test.dart b/pkg/analysis_server/test/src/services/correction/fix/bulk/remove_empty_else_test.dart
deleted file mode 100644
index 5c967e2..0000000
--- a/pkg/analysis_server/test/src/services/correction/fix/bulk/remove_empty_else_test.dart
+++ /dev/null
@@ -1,50 +0,0 @@
-// Copyright (c) 2020, 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:analysis_server/src/services/linter/lint_names.dart';
-import 'package:test_reflective_loader/test_reflective_loader.dart';
-
-import 'bulk_fix_processor.dart';
-
-void main() {
- defineReflectiveSuite(() {
- defineReflectiveTests(RemoveUnnecessaryElseTest);
- });
-}
-
-@reflectiveTest
-class RemoveUnnecessaryElseTest extends BulkFixProcessorTest {
- @override
- String get lintCode => LintNames.avoid_empty_else;
-
- Future<void> test_singleFile() async {
- await resolveTestCode('''
-void f(bool cond) {
- if (cond) {
- //
- }
- else ;
-}
-
-void f2(bool cond) {
- if (cond) {
- //
- } else ;
-}
-''');
- await assertHasFix('''
-void f(bool cond) {
- if (cond) {
- //
- }
-}
-
-void f2(bool cond) {
- if (cond) {
- //
- }
-}
-''');
- }
-}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/bulk/remove_empty_statement_test.dart b/pkg/analysis_server/test/src/services/correction/fix/bulk/remove_empty_statement_test.dart
deleted file mode 100644
index fbf7b39..0000000
--- a/pkg/analysis_server/test/src/services/correction/fix/bulk/remove_empty_statement_test.dart
+++ /dev/null
@@ -1,46 +0,0 @@
-// Copyright (c) 2020, 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:analysis_server/src/services/linter/lint_names.dart';
-import 'package:test_reflective_loader/test_reflective_loader.dart';
-
-import 'bulk_fix_processor.dart';
-
-void main() {
- defineReflectiveSuite(() {
- defineReflectiveTests(RemoveEmptyStatementTest);
- });
-}
-
-@reflectiveTest
-class RemoveEmptyStatementTest extends BulkFixProcessorTest {
- @override
- String get lintCode => LintNames.empty_statements;
-
- Future<void> test_singleFile() async {
- // Note that ReplaceWithEmptyBrackets is not supported.
- // for example: `if (true) ;` ...
- await resolveTestCode('''
-void f() {
- while(true) {
- ;
- }
-}
-
-void f2() {
- while(true) { ; }
-}
-''');
- await assertHasFix('''
-void f() {
- while(true) {
- }
-}
-
-void f2() {
- while(true) { }
-}
-''');
- }
-}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/bulk/remove_if_null_operator_test.dart b/pkg/analysis_server/test/src/services/correction/fix/bulk/remove_if_null_operator_test.dart
deleted file mode 100644
index 0003079..0000000
--- a/pkg/analysis_server/test/src/services/correction/fix/bulk/remove_if_null_operator_test.dart
+++ /dev/null
@@ -1,50 +0,0 @@
-// Copyright (c) 2021, 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:analysis_server/src/services/linter/lint_names.dart';
-import 'package:test_reflective_loader/test_reflective_loader.dart';
-
-import 'bulk_fix_processor.dart';
-
-void main() {
- defineReflectiveSuite(() {
- defineReflectiveTests(UnnecessaryNullInIfNullOperatorsTest);
- });
-}
-
-@reflectiveTest
-class UnnecessaryNullInIfNullOperatorsTest extends BulkFixProcessorTest {
- @override
- String get lintCode => LintNames.unnecessary_null_in_if_null_operators;
-
- @failingTest
- Future<void> test_null_null_left() async {
- // The fix only addresses one null and results in:
- //
- // var b = null ?? a;
- //
- // (not incorrect but not complete).
- await resolveTestCode('''
-var a = '';
-var b = null ?? null ?? a;
-''');
- await assertHasFix('''
-var a = '';
-var b = a;
-''');
- }
-
- Future<void> test_singleFile() async {
- await resolveTestCode('''
-var a = '';
-var b = null ?? a ?? null;
-var c = a ?? null ?? null;
-''');
- await assertHasFix('''
-var a = '';
-var b = a;
-var c = a;
-''');
- }
-}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/bulk/remove_initializer_test.dart b/pkg/analysis_server/test/src/services/correction/fix/bulk/remove_initializer_test.dart
deleted file mode 100644
index 1722e18..0000000
--- a/pkg/analysis_server/test/src/services/correction/fix/bulk/remove_initializer_test.dart
+++ /dev/null
@@ -1,41 +0,0 @@
-// Copyright (c) 2020, 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:analysis_server/src/services/linter/lint_names.dart';
-import 'package:test_reflective_loader/test_reflective_loader.dart';
-
-import 'bulk_fix_processor.dart';
-
-void main() {
- defineReflectiveSuite(() {
- defineReflectiveTests(RemoveInitializerTest);
- });
-}
-
-@reflectiveTest
-class RemoveInitializerTest extends BulkFixProcessorTest {
- @override
- String get lintCode => LintNames.avoid_init_to_null;
-
- Future<void> test_singleFile() async {
- await resolveTestCode('''
-class T {
- int? x = null;
-}
-
-class T2 {
- int? x = null;
-}
-''');
- await assertHasFix('''
-class T {
- int? x;
-}
-
-class T2 {
- int? x;
-}
-''');
- }
-}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/bulk/remove_interpolation_braces_test.dart b/pkg/analysis_server/test/src/services/correction/fix/bulk/remove_interpolation_braces_test.dart
deleted file mode 100644
index a291bf1..0000000
--- a/pkg/analysis_server/test/src/services/correction/fix/bulk/remove_interpolation_braces_test.dart
+++ /dev/null
@@ -1,35 +0,0 @@
-// Copyright (c) 2020, 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:analysis_server/src/services/linter/lint_names.dart';
-import 'package:test_reflective_loader/test_reflective_loader.dart';
-
-import 'bulk_fix_processor.dart';
-
-void main() {
- defineReflectiveSuite(() {
- defineReflectiveTests(RemoveInterpolationBracesTest);
- });
-}
-
-@reflectiveTest
-class RemoveInterpolationBracesTest extends BulkFixProcessorTest {
- @override
- String get lintCode => LintNames.unnecessary_brace_in_string_interps;
-
- Future<void> test_singleFile() async {
- await resolveTestCode(r'''
-main() {
- var v = 42;
- print('v: ${ v}, ${ v}');
-}
-''');
- await assertHasFix(r'''
-main() {
- var v = 42;
- print('v: $v, $v');
-}
-''');
- }
-}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/bulk/remove_method_declaration_test.dart b/pkg/analysis_server/test/src/services/correction/fix/bulk/remove_method_declaration_test.dart
deleted file mode 100644
index 65f7918..0000000
--- a/pkg/analysis_server/test/src/services/correction/fix/bulk/remove_method_declaration_test.dart
+++ /dev/null
@@ -1,45 +0,0 @@
-// Copyright (c) 2020, 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:analysis_server/src/services/linter/lint_names.dart';
-import 'package:test_reflective_loader/test_reflective_loader.dart';
-
-import 'bulk_fix_processor.dart';
-
-void main() {
- defineReflectiveSuite(() {
- defineReflectiveTests(RemoveMethodDeclarationTest);
- });
-}
-
-@reflectiveTest
-class RemoveMethodDeclarationTest extends BulkFixProcessorTest {
- @override
- String get lintCode => LintNames.unnecessary_overrides;
-
- Future<void> test_singleFile() async {
- await resolveTestCode('''
-class A {
- int foo;
- int bar() => 0;
-}
-
-class B extends A {
- @override
- int get foo => super.foo;
- @override
- int bar() => super.bar();
-}
-''');
- await assertHasFix('''
-class A {
- int foo;
- int bar() => 0;
-}
-
-class B extends A {
-}
-''');
- }
-}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/bulk/remove_non_null_assertion_test.dart b/pkg/analysis_server/test/src/services/correction/fix/bulk/remove_non_null_assertion_test.dart
deleted file mode 100644
index eeacfbc..0000000
--- a/pkg/analysis_server/test/src/services/correction/fix/bulk/remove_non_null_assertion_test.dart
+++ /dev/null
@@ -1,31 +0,0 @@
-// Copyright (c) 2020, 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:test_reflective_loader/test_reflective_loader.dart';
-
-import '../../../../../abstract_context.dart';
-import 'bulk_fix_processor.dart';
-
-void main() {
- defineReflectiveSuite(() {
- defineReflectiveTests(RemoveNonNullAssertionWithNullSafetyTest);
- });
-}
-
-@reflectiveTest
-class RemoveNonNullAssertionWithNullSafetyTest extends BulkFixProcessorTest
- with WithNullSafetyMixin {
- Future<void> test_singleFile() async {
- await resolveTestCode('''
-void f(String a) {
- print(a!!);
-}
-''');
- await assertHasFix('''
-void f(String a) {
- print(a);
-}
-''');
- }
-}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/bulk/remove_operator_test.dart b/pkg/analysis_server/test/src/services/correction/fix/bulk/remove_operator_test.dart
deleted file mode 100644
index f876196..0000000
--- a/pkg/analysis_server/test/src/services/correction/fix/bulk/remove_operator_test.dart
+++ /dev/null
@@ -1,31 +0,0 @@
-// Copyright (c) 2020, 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:analysis_server/src/services/linter/lint_names.dart';
-import 'package:test_reflective_loader/test_reflective_loader.dart';
-
-import 'bulk_fix_processor.dart';
-
-void main() {
- defineReflectiveSuite(() {
- defineReflectiveTests(RemoveOperatorTest);
- });
-}
-
-@reflectiveTest
-class RemoveOperatorTest extends BulkFixProcessorTest {
- @override
- String get lintCode => LintNames.prefer_adjacent_string_concatenation;
-
- Future<void> test_singleFile() async {
- await resolveTestCode('''
-var s = 'a' + 'b';
-var s1 = 'b' + 'c';
-''');
- await assertHasFix('''
-var s = 'a' 'b';
-var s1 = 'b' 'c';
-''');
- }
-}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/bulk/remove_question_mark_test.dart b/pkg/analysis_server/test/src/services/correction/fix/bulk/remove_question_mark_test.dart
deleted file mode 100644
index 48706e9..0000000
--- a/pkg/analysis_server/test/src/services/correction/fix/bulk/remove_question_mark_test.dart
+++ /dev/null
@@ -1,39 +0,0 @@
-// Copyright (c) 2021, 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:analysis_server/src/services/linter/lint_names.dart';
-import 'package:test_reflective_loader/test_reflective_loader.dart';
-
-import 'bulk_fix_processor.dart';
-
-void main() {
- defineReflectiveSuite(() {
- defineReflectiveTests(RemoveQuestionMarkTest);
- });
-}
-
-@reflectiveTest
-class RemoveQuestionMarkTest extends BulkFixProcessorTest {
- @override
- String get lintCode =>
- LintNames.unnecessary_nullable_for_final_variable_declarations;
-
- @override
- String get testPackageLanguageVersion => latestLanguageVersion;
-
- Future<void> test_singleFile() async {
- await resolveTestCode('''
-class C {
- static final int? x = 0;
- static final int? y = 0;
-}
-''');
- await assertHasFix('''
-class C {
- static final int x = 0;
- static final int y = 0;
-}
-''');
- }
-}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/bulk/remove_this_expression_test.dart b/pkg/analysis_server/test/src/services/correction/fix/bulk/remove_this_expression_test.dart
deleted file mode 100644
index eb9eb5c..0000000
--- a/pkg/analysis_server/test/src/services/correction/fix/bulk/remove_this_expression_test.dart
+++ /dev/null
@@ -1,41 +0,0 @@
-// Copyright (c) 2020, 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:analysis_server/src/services/linter/lint_names.dart';
-import 'package:test_reflective_loader/test_reflective_loader.dart';
-
-import 'bulk_fix_processor.dart';
-
-void main() {
- defineReflectiveSuite(() {
- defineReflectiveTests(RemoveThisExpressionTest);
- });
-}
-
-@reflectiveTest
-class RemoveThisExpressionTest extends BulkFixProcessorTest {
- @override
- String get lintCode => LintNames.unnecessary_this;
-
- Future<void> test_singleFile() async {
- await resolveTestCode('''
-class A {
- int x;
- A(int x) : this.x = x;
- void foo() {
- this.foo();
- }
-}
-''');
- await assertHasFix('''
-class A {
- int x;
- A(int x) : x = x;
- void foo() {
- foo();
- }
-}
-''');
- }
-}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/bulk/test_all.dart b/pkg/analysis_server/test/src/services/correction/fix/bulk/test_all.dart
index db092c5..288509d 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/bulk/test_all.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/bulk/test_all.dart
@@ -6,27 +6,7 @@
import 'bulk_fix_processor_test.dart' as bulk_fix_processor;
import 'convert_to_is_not_test.dart' as convert_to_is_not;
-import 'create_method_test.dart' as create_method;
import 'data_driven_test.dart' as data_driven;
-import 'inline_invocation_test.dart' as inline_invocation;
-import 'inline_typedef_test.dart' as inline_typedef;
-import 'make_final_test.dart' as make_final;
-import 'remove_argument_test.dart' as remove_argument;
-import 'remove_await_test.dart' as remove_await;
-import 'remove_duplicate_case_test.dart' as remove_duplicate_case;
-import 'remove_empty_catch_test.dart' as remove_empty_catch;
-import 'remove_empty_constructor_body_test.dart'
- as remove_empty_constructor_body;
-import 'remove_empty_else_test.dart' as remove_empty_else;
-import 'remove_empty_statement_test.dart' as remove_empty_statement;
-import 'remove_if_null_operator_test.dart' as remove_if_null_operator;
-import 'remove_initializer_test.dart' as remove_initializer;
-import 'remove_interpolation_braces_test.dart' as remove_interpolation_braces;
-import 'remove_method_declaration_test.dart' as remove_method_declaration;
-import 'remove_non_null_assertion_test.dart' as remove_non_null_assertion;
-import 'remove_operator_test.dart' as remove_operator;
-import 'remove_question_mark_test.dart' as remove_question_mark;
-import 'remove_this_expression_test.dart' as remove_this_expression;
import 'remove_type_annotation_test.dart' as remove_type_annotation;
import 'remove_unnecessary_const_test.dart' as remove_unnecessary_const;
import 'remove_unnecessary_new_test.dart' as remove_unnecessary_new;
@@ -51,26 +31,7 @@
defineReflectiveSuite(() {
bulk_fix_processor.main();
convert_to_is_not.main();
- create_method.main();
data_driven.main();
- inline_invocation.main();
- inline_typedef.main();
- make_final.main();
- remove_argument.main();
- remove_await.main();
- remove_duplicate_case.main();
- remove_initializer.main();
- remove_empty_catch.main();
- remove_empty_constructor_body.main();
- remove_empty_else.main();
- remove_empty_statement.main();
- remove_if_null_operator.main();
- remove_interpolation_braces.main();
- remove_method_declaration.main();
- remove_non_null_assertion.main();
- remove_operator.main();
- remove_question_mark.main();
- remove_this_expression.main();
remove_type_annotation.main();
remove_unnecessary_const.main();
remove_unnecessary_new.main();
diff --git a/pkg/analysis_server/test/src/services/correction/fix/create_method_test.dart b/pkg/analysis_server/test/src/services/correction/fix/create_method_test.dart
index 97f550f..24e8030 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/create_method_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/create_method_test.dart
@@ -8,10 +8,12 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
+import 'bulk/bulk_fix_processor.dart';
import 'fix_processor.dart';
void main() {
defineReflectiveSuite(() {
+ defineReflectiveTests(AddMissingHashOrEqualsBulkTest);
defineReflectiveTests(AddMissingHashOrEqualsTest);
defineReflectiveTests(CreateMethodMixinTest);
defineReflectiveTests(CreateMethodTest);
@@ -19,6 +21,48 @@
}
@reflectiveTest
+class AddMissingHashOrEqualsBulkTest extends BulkFixProcessorTest {
+ @override
+ String get lintCode => LintNames.hash_and_equals;
+
+ Future<void> test_singleFile() async {
+ await resolveTestCode('''
+class C {
+ @override
+ int get hashCode => 13;
+}
+
+class D {
+ @override
+ bool operator ==(Object other) => false;
+}
+''');
+ await assertHasFix('''
+class C {
+ @override
+ int get hashCode => 13;
+
+ @override
+ bool operator ==(Object other) {
+ // TODO: implement ==
+ return super == other;
+ }
+}
+
+class D {
+ @override
+ bool operator ==(Object other) => false;
+
+ @override
+ // TODO: implement hashCode
+ int get hashCode => super.hashCode;
+
+}
+''');
+ }
+}
+
+@reflectiveTest
class AddMissingHashOrEqualsTest extends FixProcessorLintTest {
@override
FixKind get kind => DartFixKind.CREATE_METHOD;
diff --git a/pkg/analysis_server/test/src/services/correction/fix/inline_invocation_test.dart b/pkg/analysis_server/test/src/services/correction/fix/inline_invocation_test.dart
index bb8dc37..b9da3df 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/inline_invocation_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/inline_invocation_test.dart
@@ -7,15 +7,36 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
+import 'bulk/bulk_fix_processor.dart';
import 'fix_processor.dart';
void main() {
defineReflectiveSuite(() {
+ defineReflectiveTests(InlineInvocationBulkTest);
defineReflectiveTests(InlineInvocationTest);
});
}
@reflectiveTest
+class InlineInvocationBulkTest extends BulkFixProcessorTest {
+ @override
+ String get lintCode => LintNames.prefer_inlined_adds;
+
+ Future<void> test_singleFile() async {
+ await resolveTestCode('''
+var l = []..add('a')..add('b');
+var l2 = ['a', 'b']..add('c');
+var l3 = ['a']..addAll(['b', 'c']);
+''');
+ await assertHasFix('''
+var l = ['a']..add('b');
+var l2 = ['a', 'b', 'c'];
+var l3 = ['a', 'b', 'c'];
+''');
+ }
+}
+
+@reflectiveTest
class InlineInvocationTest extends FixProcessorLintTest {
@override
FixKind get kind => DartFixKind.INLINE_INVOCATION;
diff --git a/pkg/analysis_server/test/src/services/correction/fix/inline_typedef_test.dart b/pkg/analysis_server/test/src/services/correction/fix/inline_typedef_test.dart
index 39d4fdb..3ee2db1 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/inline_typedef_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/inline_typedef_test.dart
@@ -7,16 +7,38 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
+import 'bulk/bulk_fix_processor.dart';
import 'fix_processor.dart';
void main() {
defineReflectiveSuite(() {
+ defineReflectiveTests(InlineTypedefBulkTest);
defineReflectiveTests(InlineTypedefTest);
defineReflectiveTests(InlineTypedefWithNullSafetyTest);
});
}
@reflectiveTest
+class InlineTypedefBulkTest extends BulkFixProcessorTest {
+ @override
+ String get lintCode => LintNames.avoid_private_typedef_functions;
+
+ Future<void> test_singleFile() async {
+ await resolveTestCode('''
+typedef _F1 = void Function(int);
+typedef _F2<T> = void Function(T);
+void g(_F2<_F1> f) {}
+''');
+ // Eventually both fixes will be applied but for now we're satisfied that
+ // the results are clean.
+ await assertHasFix('''
+typedef _F2<T> = void Function(T);
+void g(_F2<void Function(int)> f) {}
+''');
+ }
+}
+
+@reflectiveTest
class InlineTypedefTest extends FixProcessorLintTest {
@override
FixKind get kind => DartFixKind.INLINE_TYPEDEF;
diff --git a/pkg/analysis_server/test/src/services/correction/fix/make_final_test.dart b/pkg/analysis_server/test/src/services/correction/fix/make_final_test.dart
index fbee41d..83c4c70 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/make_final_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/make_final_test.dart
@@ -7,17 +7,45 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
+import 'bulk/bulk_fix_processor.dart';
import 'fix_processor.dart';
void main() {
defineReflectiveSuite(() {
- defineReflectiveTests(PreferFinalInForEachTest);
+ defineReflectiveTests(PreferFinalFieldsBulkTest);
defineReflectiveTests(PreferFinalFieldsTest);
defineReflectiveTests(PreferFinalFieldsWithNullSafetyTest);
+ defineReflectiveTests(PreferFinalInForEachTest);
+ defineReflectiveTests(PreferFinalLocalsBulkTest);
});
}
@reflectiveTest
+class PreferFinalFieldsBulkTest extends BulkFixProcessorTest {
+ @override
+ String get lintCode => LintNames.prefer_final_fields;
+
+ Future<void> test_singleFile() async {
+ await resolveTestCode('''
+class C {
+ int _f = 2;
+ var _f2 = 2;
+ int get g => _f;
+ int get g2 => _f2;
+}
+''');
+ await assertHasFix('''
+class C {
+ final int _f = 2;
+ final _f2 = 2;
+ int get g => _f;
+ int get g2 => _f2;
+}
+''');
+ }
+}
+
+@reflectiveTest
class PreferFinalFieldsTest extends FixProcessorLintTest {
@override
FixKind get kind => DartFixKind.MAKE_FINAL;
@@ -138,3 +166,24 @@
''');
}
}
+
+@reflectiveTest
+class PreferFinalLocalsBulkTest extends BulkFixProcessorTest {
+ @override
+ String get lintCode => LintNames.prefer_final_locals;
+
+ Future<void> test_singleFile() async {
+ await resolveTestCode('''
+f() {
+ var x = 0;
+ var y = x;
+}
+''');
+ await assertHasFix('''
+f() {
+ final x = 0;
+ final y = x;
+}
+''');
+ }
+}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/remove_argument_test.dart b/pkg/analysis_server/test/src/services/correction/fix/remove_argument_test.dart
index d1bb307..51a36e8 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/remove_argument_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/remove_argument_test.dart
@@ -7,15 +7,44 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
+import 'bulk/bulk_fix_processor.dart';
import 'fix_processor.dart';
void main() {
defineReflectiveSuite(() {
+ defineReflectiveTests(RemoveArgumentBulkTest);
defineReflectiveTests(RemoveArgumentTest);
});
}
@reflectiveTest
+class RemoveArgumentBulkTest extends BulkFixProcessorTest {
+ @override
+ String get lintCode => LintNames.avoid_redundant_argument_values;
+
+ Future<void> test_singleFile() async {
+ await resolveTestCode('''
+void f({bool valWithDefault = true, bool val}) {}
+void f2({bool valWithDefault = true, bool val}) {}
+
+void main() {
+ f(valWithDefault: true);
+ f2(valWithDefault: true, val: false);
+}
+''');
+ await assertHasFix('''
+void f({bool valWithDefault = true, bool val}) {}
+void f2({bool valWithDefault = true, bool val}) {}
+
+void main() {
+ f();
+ f2(val: false);
+}
+''');
+ }
+}
+
+@reflectiveTest
class RemoveArgumentTest extends FixProcessorLintTest {
@override
FixKind get kind => DartFixKind.REMOVE_ARGUMENT;
diff --git a/pkg/analysis_server/test/src/services/correction/fix/remove_await_test.dart b/pkg/analysis_server/test/src/services/correction/fix/remove_await_test.dart
index 97d8bf8..67c0552 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/remove_await_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/remove_await_test.dart
@@ -7,15 +7,44 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
+import 'bulk/bulk_fix_processor.dart';
import 'fix_processor.dart';
void main() {
defineReflectiveSuite(() {
+ defineReflectiveTests(RemoveAwaitBulkTest);
defineReflectiveTests(RemoveAwaitTest);
});
}
@reflectiveTest
+class RemoveAwaitBulkTest extends BulkFixProcessorTest {
+ @override
+ String get lintCode => LintNames.await_only_futures;
+
+ Future<void> test_singleFile() async {
+ await resolveTestCode('''
+f() async {
+ print(await 23);
+}
+
+f2() async {
+ print(await 'hola');
+}
+''');
+ await assertHasFix('''
+f() async {
+ print(23);
+}
+
+f2() async {
+ print('hola');
+}
+''');
+ }
+}
+
+@reflectiveTest
class RemoveAwaitTest extends FixProcessorLintTest {
@override
FixKind get kind => DartFixKind.REMOVE_AWAIT;
diff --git a/pkg/analysis_server/test/src/services/correction/fix/remove_duplicate_case_test.dart b/pkg/analysis_server/test/src/services/correction/fix/remove_duplicate_case_test.dart
index 0d8a6b1..37a0e90 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/remove_duplicate_case_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/remove_duplicate_case_test.dart
@@ -7,15 +7,54 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
+import 'bulk/bulk_fix_processor.dart';
import 'fix_processor.dart';
void main() {
defineReflectiveSuite(() {
+ defineReflectiveTests(RemoveDuplicateCaseBulkTest);
defineReflectiveTests(RemoveDuplicateCaseTest);
});
}
@reflectiveTest
+class RemoveDuplicateCaseBulkTest extends BulkFixProcessorTest {
+ @override
+ String get lintCode => LintNames.no_duplicate_case_values;
+
+ Future<void> test_singleFile() async {
+ await resolveTestCode('''
+void switchInt() {
+ switch (2) {
+ case 1:
+ print('a');
+ break;
+ case 2:
+ case 2:
+ case 3:
+ case 3:
+ default:
+ print('?');
+ }
+}
+''');
+ await assertHasFix('''
+void switchInt() {
+ switch (2) {
+ case 1:
+ print('a');
+ break;
+ case 2:
+ case 3:
+ default:
+ print('?');
+ }
+}
+''');
+ }
+}
+
+@reflectiveTest
class RemoveDuplicateCaseTest extends FixProcessorLintTest {
@override
FixKind get kind => DartFixKind.REMOVE_DUPLICATE_CASE;
diff --git a/pkg/analysis_server/test/src/services/correction/fix/remove_empty_catch_test.dart b/pkg/analysis_server/test/src/services/correction/fix/remove_empty_catch_test.dart
index ff75a69..ddc26fe 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/remove_empty_catch_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/remove_empty_catch_test.dart
@@ -7,15 +7,52 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
+import 'bulk/bulk_fix_processor.dart';
import 'fix_processor.dart';
void main() {
defineReflectiveSuite(() {
+ defineReflectiveTests(RemoveEmptyCatchBulkTest);
defineReflectiveTests(RemoveEmptyCatchTest);
});
}
@reflectiveTest
+class RemoveEmptyCatchBulkTest extends BulkFixProcessorTest {
+ @override
+ String get lintCode => LintNames.empty_catches;
+
+ Future<void> test_singleFile() async {
+ await resolveTestCode('''
+void f() {
+ try {
+ try {
+ 1;
+ } catch (e) {} finally {}
+ } catch (e) {} finally {}
+}
+
+void f2() {
+ try {} catch (e) {} finally {}
+}
+''');
+ await assertHasFix('''
+void f() {
+ try {
+ try {
+ 1;
+ } finally {}
+ } finally {}
+}
+
+void f2() {
+ try {} finally {}
+}
+''');
+ }
+}
+
+@reflectiveTest
class RemoveEmptyCatchTest extends FixProcessorLintTest {
@override
FixKind get kind => DartFixKind.REMOVE_EMPTY_CATCH;
diff --git a/pkg/analysis_server/test/src/services/correction/fix/remove_empty_constructor_body_test.dart b/pkg/analysis_server/test/src/services/correction/fix/remove_empty_constructor_body_test.dart
index 3f93785..477e58e 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/remove_empty_constructor_body_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/remove_empty_constructor_body_test.dart
@@ -8,15 +8,44 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
+import 'bulk/bulk_fix_processor.dart';
import 'fix_processor.dart';
void main() {
defineReflectiveSuite(() {
+ defineReflectiveTests(RemoveEmptyConstructorBodyBulkTest);
defineReflectiveTests(RemoveEmptyConstructorBodyTest);
});
}
@reflectiveTest
+class RemoveEmptyConstructorBodyBulkTest extends BulkFixProcessorTest {
+ @override
+ String get lintCode => LintNames.empty_constructor_bodies;
+
+ Future<void> test_singleFile() async {
+ await resolveTestCode('''
+class C {
+ C() {}
+}
+
+class D {
+ D() {}
+}
+''');
+ await assertHasFix('''
+class C {
+ C();
+}
+
+class D {
+ D();
+}
+''');
+ }
+}
+
+@reflectiveTest
class RemoveEmptyConstructorBodyTest extends FixProcessorLintTest {
@override
FixKind get kind => DartFixKind.REMOVE_EMPTY_CONSTRUCTOR_BODY;
diff --git a/pkg/analysis_server/test/src/services/correction/fix/remove_empty_else_test.dart b/pkg/analysis_server/test/src/services/correction/fix/remove_empty_else_test.dart
index b7521b3..7302532 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/remove_empty_else_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/remove_empty_else_test.dart
@@ -7,15 +7,53 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
+import 'bulk/bulk_fix_processor.dart';
import 'fix_processor.dart';
void main() {
defineReflectiveSuite(() {
+ defineReflectiveTests(RemoveEmptyElseBulkTest);
defineReflectiveTests(RemoveEmptyElseTest);
});
}
@reflectiveTest
+class RemoveEmptyElseBulkTest extends BulkFixProcessorTest {
+ @override
+ String get lintCode => LintNames.avoid_empty_else;
+
+ Future<void> test_singleFile() async {
+ await resolveTestCode('''
+void f(bool cond) {
+ if (cond) {
+ //
+ }
+ else ;
+}
+
+void f2(bool cond) {
+ if (cond) {
+ //
+ } else ;
+}
+''');
+ await assertHasFix('''
+void f(bool cond) {
+ if (cond) {
+ //
+ }
+}
+
+void f2(bool cond) {
+ if (cond) {
+ //
+ }
+}
+''');
+ }
+}
+
+@reflectiveTest
class RemoveEmptyElseTest extends FixProcessorLintTest {
@override
FixKind get kind => DartFixKind.REMOVE_EMPTY_ELSE;
diff --git a/pkg/analysis_server/test/src/services/correction/fix/remove_empty_statement_test.dart b/pkg/analysis_server/test/src/services/correction/fix/remove_empty_statement_test.dart
index 0b28f0f..b66d6ce 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/remove_empty_statement_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/remove_empty_statement_test.dart
@@ -7,15 +7,49 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
+import 'bulk/bulk_fix_processor.dart';
import 'fix_processor.dart';
void main() {
defineReflectiveSuite(() {
+ defineReflectiveTests(RemoveEmptyStatementBulkTest);
defineReflectiveTests(RemoveEmptyStatementTest);
});
}
@reflectiveTest
+class RemoveEmptyStatementBulkTest extends BulkFixProcessorTest {
+ @override
+ String get lintCode => LintNames.empty_statements;
+
+ Future<void> test_singleFile() async {
+ // Note that ReplaceWithEmptyBrackets is not supported.
+ // for example: `if (true) ;` ...
+ await resolveTestCode('''
+void f() {
+ while(true) {
+ ;
+ }
+}
+
+void f2() {
+ while(true) { ; }
+}
+''');
+ await assertHasFix('''
+void f() {
+ while(true) {
+ }
+}
+
+void f2() {
+ while(true) { }
+}
+''');
+ }
+}
+
+@reflectiveTest
class RemoveEmptyStatementTest extends FixProcessorLintTest {
@override
FixKind get kind => DartFixKind.REMOVE_EMPTY_STATEMENT;
diff --git a/pkg/analysis_server/test/src/services/correction/fix/remove_if_null_operator_test.dart b/pkg/analysis_server/test/src/services/correction/fix/remove_if_null_operator_test.dart
index df0b810..e73f4f7 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/remove_if_null_operator_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/remove_if_null_operator_test.dart
@@ -8,12 +8,14 @@
import 'package:test_reflective_loader/test_reflective_loader.dart';
import '../../../../abstract_context.dart';
+import 'bulk/bulk_fix_processor.dart';
import 'fix_processor.dart';
void main() {
defineReflectiveSuite(() {
defineReflectiveTests(DeadNullAwareAssignmentExpressionTest);
defineReflectiveTests(DeadNullAwareExpressionTest);
+ defineReflectiveTests(UnnecessaryNullInIfNullOperatorsBulkTest);
defineReflectiveTests(UnnecessaryNullInIfNullOperatorsTest);
});
}
@@ -109,6 +111,42 @@
}
@reflectiveTest
+class UnnecessaryNullInIfNullOperatorsBulkTest extends BulkFixProcessorTest {
+ @override
+ String get lintCode => LintNames.unnecessary_null_in_if_null_operators;
+
+ @failingTest
+ Future<void> test_null_null_left() async {
+ // The fix only addresses one null and results in:
+ //
+ // var b = null ?? a;
+ //
+ // (not incorrect but not complete).
+ await resolveTestCode('''
+var a = '';
+var b = null ?? null ?? a;
+''');
+ await assertHasFix('''
+var a = '';
+var b = a;
+''');
+ }
+
+ Future<void> test_singleFile() async {
+ await resolveTestCode('''
+var a = '';
+var b = null ?? a ?? null;
+var c = a ?? null ?? null;
+''');
+ await assertHasFix('''
+var a = '';
+var b = a;
+var c = a;
+''');
+ }
+}
+
+@reflectiveTest
class UnnecessaryNullInIfNullOperatorsTest extends FixProcessorLintTest {
@override
FixKind get kind => DartFixKind.REMOVE_IF_NULL_OPERATOR;
diff --git a/pkg/analysis_server/test/src/services/correction/fix/remove_initializer_test.dart b/pkg/analysis_server/test/src/services/correction/fix/remove_initializer_test.dart
index b78dedb..c28a1f8 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/remove_initializer_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/remove_initializer_test.dart
@@ -7,15 +7,44 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
+import 'bulk/bulk_fix_processor.dart';
import 'fix_processor.dart';
void main() {
defineReflectiveSuite(() {
+ defineReflectiveTests(RemoveInitializerBulkTest);
defineReflectiveTests(RemoveInitializerTest);
});
}
@reflectiveTest
+class RemoveInitializerBulkTest extends BulkFixProcessorTest {
+ @override
+ String get lintCode => LintNames.avoid_init_to_null;
+
+ Future<void> test_singleFile() async {
+ await resolveTestCode('''
+class T {
+ int? x = null;
+}
+
+class T2 {
+ int? x = null;
+}
+''');
+ await assertHasFix('''
+class T {
+ int? x;
+}
+
+class T2 {
+ int? x;
+}
+''');
+ }
+}
+
+@reflectiveTest
class RemoveInitializerTest extends FixProcessorLintTest {
@override
FixKind get kind => DartFixKind.REMOVE_INITIALIZER;
diff --git a/pkg/analysis_server/test/src/services/correction/fix/remove_interpolation_braces_test.dart b/pkg/analysis_server/test/src/services/correction/fix/remove_interpolation_braces_test.dart
index eaf6bc0..73128de 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/remove_interpolation_braces_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/remove_interpolation_braces_test.dart
@@ -7,15 +7,38 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
+import 'bulk/bulk_fix_processor.dart';
import 'fix_processor.dart';
void main() {
defineReflectiveSuite(() {
+ defineReflectiveTests(RemoveInterpolationBracesBulkTest);
defineReflectiveTests(RemoveInterpolationBracesTest);
});
}
@reflectiveTest
+class RemoveInterpolationBracesBulkTest extends BulkFixProcessorTest {
+ @override
+ String get lintCode => LintNames.unnecessary_brace_in_string_interps;
+
+ Future<void> test_singleFile() async {
+ await resolveTestCode(r'''
+main() {
+ var v = 42;
+ print('v: ${ v}, ${ v}');
+}
+''');
+ await assertHasFix(r'''
+main() {
+ var v = 42;
+ print('v: $v, $v');
+}
+''');
+ }
+}
+
+@reflectiveTest
class RemoveInterpolationBracesTest extends FixProcessorLintTest {
@override
FixKind get kind => DartFixKind.REMOVE_INTERPOLATION_BRACES;
diff --git a/pkg/analysis_server/test/src/services/correction/fix/remove_method_declaration_test.dart b/pkg/analysis_server/test/src/services/correction/fix/remove_method_declaration_test.dart
index ba17776..3c2a19e 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/remove_method_declaration_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/remove_method_declaration_test.dart
@@ -7,15 +7,48 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
+import 'bulk/bulk_fix_processor.dart';
import 'fix_processor.dart';
void main() {
defineReflectiveSuite(() {
+ defineReflectiveTests(RemoveMethodDeclarationBulkTest);
defineReflectiveTests(RemoveMethodDeclarationTest);
});
}
@reflectiveTest
+class RemoveMethodDeclarationBulkTest extends BulkFixProcessorTest {
+ @override
+ String get lintCode => LintNames.unnecessary_overrides;
+
+ Future<void> test_singleFile() async {
+ await resolveTestCode('''
+class A {
+ int foo;
+ int bar() => 0;
+}
+
+class B extends A {
+ @override
+ int get foo => super.foo;
+ @override
+ int bar() => super.bar();
+}
+''');
+ await assertHasFix('''
+class A {
+ int foo;
+ int bar() => 0;
+}
+
+class B extends A {
+}
+''');
+ }
+}
+
+@reflectiveTest
class RemoveMethodDeclarationTest extends FixProcessorLintTest {
@override
FixKind get kind => DartFixKind.REMOVE_METHOD_DECLARATION;
diff --git a/pkg/analysis_server/test/src/services/correction/fix/remove_non_null_assertion_test.dart b/pkg/analysis_server/test/src/services/correction/fix/remove_non_null_assertion_test.dart
index d66f1b8..cbbd31a 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/remove_non_null_assertion_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/remove_non_null_assertion_test.dart
@@ -7,16 +7,35 @@
import 'package:test_reflective_loader/test_reflective_loader.dart';
import '../../../../abstract_context.dart';
+import 'bulk/bulk_fix_processor.dart';
import 'fix_processor.dart';
void main() {
defineReflectiveSuite(() {
- defineReflectiveTests(RemoveNonNullAssertionWithNullSafetyTest);
+ defineReflectiveTests(RemoveNonNullAssertionBulkTest);
+ defineReflectiveTests(RemoveNonNullAssertionTest);
});
}
@reflectiveTest
-class RemoveNonNullAssertionWithNullSafetyTest extends FixProcessorTest
+class RemoveNonNullAssertionBulkTest extends BulkFixProcessorTest
+ with WithNullSafetyMixin {
+ Future<void> test_singleFile() async {
+ await resolveTestCode('''
+void f(String a) {
+ print(a!!);
+}
+''');
+ await assertHasFix('''
+void f(String a) {
+ print(a);
+}
+''');
+ }
+}
+
+@reflectiveTest
+class RemoveNonNullAssertionTest extends FixProcessorTest
with WithNullSafetyMixin {
@override
FixKind get kind => DartFixKind.REMOVE_NON_NULL_ASSERTION;
diff --git a/pkg/analysis_server/test/src/services/correction/fix/remove_operator_test.dart b/pkg/analysis_server/test/src/services/correction/fix/remove_operator_test.dart
index 22aa7e5..4d35f93 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/remove_operator_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/remove_operator_test.dart
@@ -7,15 +7,34 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
+import 'bulk/bulk_fix_processor.dart';
import 'fix_processor.dart';
void main() {
defineReflectiveSuite(() {
+ defineReflectiveTests(RemoveOperatorBulkTest);
defineReflectiveTests(RemoveOperatorTest);
});
}
@reflectiveTest
+class RemoveOperatorBulkTest extends BulkFixProcessorTest {
+ @override
+ String get lintCode => LintNames.prefer_adjacent_string_concatenation;
+
+ Future<void> test_singleFile() async {
+ await resolveTestCode('''
+var s = 'a' + 'b';
+var s1 = 'b' + 'c';
+''');
+ await assertHasFix('''
+var s = 'a' 'b';
+var s1 = 'b' 'c';
+''');
+ }
+}
+
+@reflectiveTest
class RemoveOperatorTest extends FixProcessorLintTest {
@override
FixKind get kind => DartFixKind.REMOVE_OPERATOR;
diff --git a/pkg/analysis_server/test/src/services/correction/fix/remove_question_mark_test.dart b/pkg/analysis_server/test/src/services/correction/fix/remove_question_mark_test.dart
index 286b5d3..3668822 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/remove_question_mark_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/remove_question_mark_test.dart
@@ -3,20 +3,48 @@
// BSD-style license that can be found in the LICENSE file.
import 'package:analysis_server/src/services/correction/fix.dart';
+import 'package:analysis_server/src/services/linter/lint_names.dart';
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
import '../../../../abstract_context.dart';
+import 'bulk/bulk_fix_processor.dart';
import 'fix_processor.dart';
void main() {
defineReflectiveSuite(() {
+ defineReflectiveTests(RemoveQuestionMarkBulkTest);
defineReflectiveTests(RemoveQuestionMarkTest);
defineReflectiveTests(UnnecessaryNullableForFinalVariableDeclarationsTest);
});
}
@reflectiveTest
+class RemoveQuestionMarkBulkTest extends BulkFixProcessorTest {
+ @override
+ String get lintCode =>
+ LintNames.unnecessary_nullable_for_final_variable_declarations;
+
+ @override
+ String get testPackageLanguageVersion => latestLanguageVersion;
+
+ Future<void> test_singleFile() async {
+ await resolveTestCode('''
+class C {
+ static final int? x = 0;
+ static final int? y = 0;
+}
+''');
+ await assertHasFix('''
+class C {
+ static final int x = 0;
+ static final int y = 0;
+}
+''');
+ }
+}
+
+@reflectiveTest
class RemoveQuestionMarkTest extends FixProcessorTest with WithNullSafetyMixin {
@override
FixKind get kind => DartFixKind.REMOVE_QUESTION_MARK;
diff --git a/pkg/analysis_server/test/src/services/correction/fix/remove_this_expression_test.dart b/pkg/analysis_server/test/src/services/correction/fix/remove_this_expression_test.dart
index 7600576..626c668 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/remove_this_expression_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/remove_this_expression_test.dart
@@ -7,15 +7,44 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
+import 'bulk/bulk_fix_processor.dart';
import 'fix_processor.dart';
void main() {
defineReflectiveSuite(() {
+ defineReflectiveTests(RemoveThisExpressionBulkTest);
defineReflectiveTests(RemoveThisExpressionTest);
});
}
@reflectiveTest
+class RemoveThisExpressionBulkTest extends BulkFixProcessorTest {
+ @override
+ String get lintCode => LintNames.unnecessary_this;
+
+ Future<void> test_singleFile() async {
+ await resolveTestCode('''
+class A {
+ int x;
+ A(int x) : this.x = x;
+ void foo() {
+ this.foo();
+ }
+}
+''');
+ await assertHasFix('''
+class A {
+ int x;
+ A(int x) : x = x;
+ void foo() {
+ foo();
+ }
+}
+''');
+ }
+}
+
+@reflectiveTest
class RemoveThisExpressionTest extends FixProcessorLintTest {
@override
FixKind get kind => DartFixKind.REMOVE_THIS_EXPRESSION;
diff --git a/pkg/kernel/lib/ast.dart b/pkg/kernel/lib/ast.dart
index 4a2284a..a8a2a04 100644
--- a/pkg/kernel/lib/ast.dart
+++ b/pkg/kernel/lib/ast.dart
@@ -13025,15 +13025,19 @@
if (other.tearOffConstant != tearOffConstant) return false;
if (other.parameters.length != parameters.length) return false;
if (parameters.isNotEmpty) {
- Map<TypeParameter, DartType> substitutionMap =
- <TypeParameter, DartType>{};
- for (int i = 0; i < parameters.length; ++i) {
- substitutionMap[parameters[i]] = new TypeParameterType.forAlphaRenaming(
- other.parameters[i], parameters[i]);
+ Assumptions assumptions = new Assumptions();
+ for (int index = 0; index < parameters.length; index++) {
+ assumptions.assume(parameters[index], other.parameters[index]);
}
- Substitution substitution = Substitution.fromMap(substitutionMap);
- for (int i = 0; i < parameters.length; ++i) {
- if (types[i] != substitution.substituteType(other.types[i])) {
+ for (int index = 0; index < parameters.length; index++) {
+ if (!parameters[index]
+ .bound
+ .equals(other.parameters[index].bound, assumptions)) {
+ return false;
+ }
+ }
+ for (int i = 0; i < types.length; ++i) {
+ if (!types[i].equals(other.types[i], assumptions)) {
return false;
}
}
diff --git a/pkg/kernel/test/constant_equals_test.dart b/pkg/kernel/test/constant_equals_test.dart
new file mode 100644
index 0000000..689ae71
--- /dev/null
+++ b/pkg/kernel/test/constant_equals_test.dart
@@ -0,0 +1,165 @@
+// Copyright (c) 2021, 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:kernel/ast.dart';
+
+testEquals(Constant a, Constant b) {
+ if (a != b) {
+ throw 'Expected $a and $b to be equal.';
+ }
+}
+
+testNotEquals(Constant a, Constant b) {
+ if (a == b) {
+ throw 'Expected $a and $b to be not equal.';
+ }
+}
+
+main() {
+ Uri uri = Uri.parse('test:uri');
+ Procedure procedure1 = new Procedure(
+ new Name('foo'), ProcedureKind.Method, new FunctionNode(null),
+ fileUri: uri, isStatic: true);
+ Procedure procedure2 = new Procedure(
+ new Name('foo'), ProcedureKind.Method, new FunctionNode(null),
+ fileUri: uri, isStatic: true);
+ Procedure procedure3 = new Procedure(
+ new Name('foo'),
+ ProcedureKind.Method,
+ new FunctionNode(null, typeParameters: [
+ new TypeParameter('X', const DynamicType(), const DynamicType())
+ ]),
+ fileUri: uri,
+ isStatic: true);
+
+ TearOffConstant tearOffConstant1a = new StaticTearOffConstant(procedure1);
+ TearOffConstant tearOffConstant1b = new StaticTearOffConstant(procedure1);
+ TearOffConstant tearOffConstant2 = new StaticTearOffConstant(procedure2);
+ TearOffConstant tearOffConstant3 = new StaticTearOffConstant(procedure3);
+
+ // foo() {}
+ // const a = foo;
+ // const b = foo;
+ // a == b
+ testEquals(tearOffConstant1a, tearOffConstant1b);
+
+ // foo() {} // from lib1;
+ // foo() {} // from lib2;
+ // lib1.foo != lib2.foo
+ testNotEquals(tearOffConstant1a, tearOffConstant2);
+
+ // foo() {}
+ // typedef F = foo;
+ // typedef G = foo;
+ // F == G
+ testEquals(new TypedefTearOffConstant([], tearOffConstant1a, []),
+ new TypedefTearOffConstant([], tearOffConstant1b, []));
+
+ // foo() {} // from lib1;
+ // foo() {} // from lib2;
+ // typedef F = lib1.foo;
+ // typedef G = lib2.foo;
+ // F != G
+ testNotEquals(new TypedefTearOffConstant([], tearOffConstant1a, []),
+ new TypedefTearOffConstant([], tearOffConstant2, []));
+
+ // foo() {}
+ // typedef F<T> = foo;
+ // typedef G<S> = foo;
+ // F == G
+ testEquals(
+ new TypedefTearOffConstant(
+ [new TypeParameter('T', const DynamicType(), const DynamicType())],
+ tearOffConstant1a,
+ []),
+ new TypedefTearOffConstant(
+ [new TypeParameter('S', const DynamicType(), const DynamicType())],
+ tearOffConstant1b,
+ []));
+
+ // foo() {}
+ // typedef F<T1, T2> = foo;
+ // typedef G<S> = foo;
+ // F != G
+ testNotEquals(
+ new TypedefTearOffConstant(
+ [
+ new TypeParameter('T1', const DynamicType(), const DynamicType()),
+ new TypeParameter('T2', const DynamicType(), const DynamicType())
+ ],
+ tearOffConstant1a,
+ []),
+ new TypedefTearOffConstant(
+ [new TypeParameter('S', const DynamicType(), const DynamicType())],
+ tearOffConstant1b,
+ []));
+
+ // foo() {}
+ // typedef F<T extends void> = foo;
+ // typedef G<S> = foo;
+ // F != G
+ testNotEquals(
+ new TypedefTearOffConstant(
+ [new TypeParameter('T', const VoidType(), const DynamicType())],
+ tearOffConstant1a,
+ []),
+ new TypedefTearOffConstant(
+ [new TypeParameter('S', const DynamicType(), const DynamicType())],
+ tearOffConstant1b,
+ []));
+ {
+ TypeParameter typeParameter1 =
+ new TypeParameter('T', const DynamicType(), const DynamicType());
+ TypeParameter typeParameter2 =
+ new TypeParameter('S', const DynamicType(), const DynamicType());
+
+ // foo<X>() {}
+ // typedef F<T> = foo<T>;
+ // typedef G<S> = foo<S>;
+ // F == G
+ testEquals(
+ new TypedefTearOffConstant([typeParameter1], tearOffConstant3,
+ [new TypeParameterType(typeParameter1, Nullability.nullable)]),
+ new TypedefTearOffConstant([typeParameter2], tearOffConstant3,
+ [new TypeParameterType(typeParameter2, Nullability.nullable)]));
+ }
+ {
+ TypeParameter typeParameter1a =
+ new TypeParameter('T1', const DynamicType(), const DynamicType());
+ TypeParameter typeParameter1b =
+ new TypeParameter('T2', const DynamicType(), const DynamicType());
+ TypeParameter typeParameter2a =
+ new TypeParameter('S1', const DynamicType(), const DynamicType());
+ TypeParameter typeParameter2b =
+ new TypeParameter('S2', const DynamicType(), const DynamicType());
+
+ // foo<X>() {}
+ // typedef F<T1, T2> = foo<T1>;
+ // typedef G<S1, S2> = foo<S1>;
+ // F == G
+ testEquals(
+ new TypedefTearOffConstant(
+ [typeParameter1a, typeParameter1b],
+ tearOffConstant3,
+ [new TypeParameterType(typeParameter1a, Nullability.nullable)]),
+ new TypedefTearOffConstant(
+ [typeParameter2a, typeParameter2b],
+ tearOffConstant3,
+ [new TypeParameterType(typeParameter2a, Nullability.nullable)]));
+
+ // foo<X>() {}
+ // typedef F<T1, T2> = foo<T1>;
+ // typedef G<S1, S2> = foo<S2>;
+ // F != G
+ testNotEquals(
+ new TypedefTearOffConstant(
+ [typeParameter1a, typeParameter1b],
+ tearOffConstant3,
+ [new TypeParameterType(typeParameter1a, Nullability.nullable)]),
+ new TypedefTearOffConstant(
+ [typeParameter2a, typeParameter2b],
+ tearOffConstant3,
+ [new TypeParameterType(typeParameter2b, Nullability.nullable)]));
+ }
+}
diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc
index 99c2957..119e5a2 100644
--- a/runtime/vm/object.cc
+++ b/runtime/vm/object.cc
@@ -15499,13 +15499,12 @@
}
intptr_t ICData::NumArgsTested() const {
- return NumArgsTestedBits::decode(untag()->state_bits_);
+ return untag()->state_bits_.Read<NumArgsTestedBits>();
}
void ICData::SetNumArgsTested(intptr_t value) const {
ASSERT(Utils::IsUint(2, value));
- StoreNonPointer(&untag()->state_bits_,
- NumArgsTestedBits::update(value, untag()->state_bits_));
+ untag()->state_bits_.Update<NumArgsTestedBits>(value);
}
intptr_t CallSiteData::TypeArgsLen() const {
@@ -15534,12 +15533,11 @@
}
uint32_t ICData::DeoptReasons() const {
- return DeoptReasonBits::decode(untag()->state_bits_);
+ return untag()->state_bits_.Read<DeoptReasonBits>();
}
void ICData::SetDeoptReasons(uint32_t reasons) const {
- StoreNonPointer(&untag()->state_bits_,
- DeoptReasonBits::update(reasons, untag()->state_bits_));
+ untag()->state_bits_.Update<DeoptReasonBits>(reasons);
}
bool ICData::HasDeoptReason(DeoptReasonId reason) const {
@@ -15549,7 +15547,7 @@
void ICData::AddDeoptReason(DeoptReasonId reason) const {
if (reason <= kLastRecordedDeoptReason) {
- SetDeoptReasons(DeoptReasons() | (1 << reason));
+ untag()->state_bits_.FetchOr<DeoptReasonBits>(1 << reason);
}
}
@@ -15577,20 +15575,19 @@
}
ICData::RebindRule ICData::rebind_rule() const {
- return (ICData::RebindRule)RebindRuleBits::decode(untag()->state_bits_);
+ return RebindRule(untag()->state_bits_.Read<RebindRuleBits>());
}
void ICData::set_rebind_rule(uint32_t rebind_rule) const {
- StoreNonPointer(&untag()->state_bits_,
- RebindRuleBits::update(rebind_rule, untag()->state_bits_));
+ untag()->state_bits_.Update<ICData::RebindRuleBits>(rebind_rule);
}
bool ICData::is_static_call() const {
return rebind_rule() != kInstance;
}
-void ICData::set_state_bits(uint32_t bits) const {
- StoreNonPointer(&untag()->state_bits_, bits);
+void ICData::clear_state_bits() const {
+ untag()->state_bits_ = 0;
}
intptr_t ICData::TestEntryLengthFor(intptr_t num_args,
@@ -16341,7 +16338,7 @@
result.set_target_name(target_name);
result.set_arguments_descriptor(arguments_descriptor);
NOT_IN_PRECOMPILED(result.set_deopt_id(deopt_id));
- result.set_state_bits(0);
+ result.clear_state_bits();
result.set_rebind_rule(rebind_rule);
result.SetNumArgsTested(num_args_tested);
NOT_IN_PRECOMPILED(result.SetReceiversStaticType(receivers_static_type));
@@ -16363,7 +16360,7 @@
result ^= raw;
}
result.set_deopt_id(DeoptId::kNone);
- result.set_state_bits(0);
+ result.clear_state_bits();
return result.ptr();
}
diff --git a/runtime/vm/object.h b/runtime/vm/object.h
index f2e14f4..10d2874 100644
--- a/runtime/vm/object.h
+++ b/runtime/vm/object.h
@@ -2044,7 +2044,7 @@
return untag()->receivers_static_type();
}
bool is_tracking_exactness() const {
- return TrackingExactnessBit::decode(untag()->state_bits_);
+ return untag()->state_bits_.Read<TrackingExactnessBit>();
}
#else
bool is_tracking_exactness() const { return false; }
@@ -2116,14 +2116,8 @@
RebindRule rebind_rule() const;
void set_is_megamorphic(bool value) const {
- // We don't have concurrent RW access to [state_bits_].
- const uint32_t updated_bits =
- MegamorphicBit::update(value, untag()->state_bits_);
-
- // Though we ensure that once the state bits are updated, all other previous
- // writes to the IC are visible as well.
- StoreNonPointer<uint32_t, uint32_t, std::memory_order_release>(
- &untag()->state_bits_, updated_bits);
+ untag()->state_bits_.UpdateBool<MegamorphicBit, std::memory_order_release>(
+ value);
}
// The length of the array. This includes all sentinel entries including
@@ -2342,13 +2336,11 @@
}
bool receiver_cannot_be_smi() const {
- return ReceiverCannotBeSmiBit::decode(
- LoadNonPointer(&untag()->state_bits_));
+ return untag()->state_bits_.Read<ReceiverCannotBeSmiBit>();
}
void set_receiver_cannot_be_smi(bool value) const {
- set_state_bits(ReceiverCannotBeSmiBit::encode(value) |
- LoadNonPointer(&untag()->state_bits_));
+ untag()->state_bits_.UpdateBool<ReceiverCannotBeSmiBit>(value);
}
private:
@@ -2362,10 +2354,9 @@
void set_entries(const Array& value) const;
void set_owner(const Function& value) const;
void set_rebind_rule(uint32_t rebind_rule) const;
- void set_state_bits(uint32_t bits) const;
+ void clear_state_bits() const;
void set_tracking_exactness(bool value) const {
- StoreNonPointer(&untag()->state_bits_,
- TrackingExactnessBit::update(value, untag()->state_bits_));
+ untag()->state_bits_.UpdateBool<TrackingExactnessBit>(value);
}
// Does entry |index| contain the sentinel value?
@@ -2394,9 +2385,8 @@
bool is_megamorphic() const {
// Ensure any following load instructions do not get performed before this
// one.
- const uint32_t bits = LoadNonPointer<uint32_t, std::memory_order_acquire>(
- &untag()->state_bits_);
- return MegamorphicBit::decode(bits);
+ return untag()
+ ->state_bits_.Read<MegamorphicBit, std::memory_order_acquire>();
}
bool ValidateInterceptor(const Function& target) const;
diff --git a/runtime/vm/raw_object.h b/runtime/vm/raw_object.h
index 0738f31..6e0e5eb 100644
--- a/runtime/vm/raw_object.h
+++ b/runtime/vm/raw_object.h
@@ -280,9 +280,10 @@
return tags_.compare_exchange_weak(old_tags, new_tags, order);
}
- template <class TagBitField>
+ template <class TagBitField,
+ std::memory_order order = std::memory_order_relaxed>
typename TagBitField::Type Read() const {
- return TagBitField::decode(tags_.load(std::memory_order_relaxed));
+ return TagBitField::decode(tags_.load(order));
}
template <class TagBitField>
@@ -301,6 +302,11 @@
}
template <class TagBitField>
+ void FetchOr(typename TagBitField::Type value) {
+ tags_.fetch_or(TagBitField::encode(value), std::memory_order_relaxed);
+ }
+
+ template <class TagBitField>
void Update(typename TagBitField::Type value) {
T old_tags = tags_.load(std::memory_order_relaxed);
T new_tags;
@@ -2462,7 +2468,8 @@
return NULL;
}
NOT_IN_PRECOMPILED(int32_t deopt_id_);
- uint32_t state_bits_; // Number of arguments tested in IC, deopt reasons.
+ // Number of arguments tested in IC, deopt reasons.
+ Tags<uint32_t> state_bits_;
};
class UntaggedMegamorphicCache : public UntaggedCallSiteData {
diff --git a/tools/VERSION b/tools/VERSION
index d53fa3f..e796ecf 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
MAJOR 2
MINOR 14
PATCH 0
-PRERELEASE 261
+PRERELEASE 262
PRERELEASE_PATCH 0
\ No newline at end of file