analyzer: Fix return_of_do_not_store tests
Bug: https://github.com/dart-lang/sdk/issues/48476
Cq-Include-Trybots: luci.dart.try:flutter-analyze-try,analyzer-win-release-try,pkg-win-release-try
Change-Id: I3af9ad950b2ef42717fb84dde4f9b3c22993df05
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/367860
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Auto-Submit: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
diff --git a/pkg/analyzer/test/src/diagnostics/assignment_of_do_not_store_test.dart b/pkg/analyzer/test/src/diagnostics/assignment_of_do_not_store_test.dart
index bb6dd94..f743ff6 100644
--- a/pkg/analyzer/test/src/diagnostics/assignment_of_do_not_store_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/assignment_of_do_not_store_test.dart
@@ -129,24 +129,6 @@
]);
}
- @FailingTest(issue: 'https://github.com/dart-lang/sdk/issues/48476')
- test_classMemberVariable() async {
- await assertErrorsInCode('''
-import 'package:meta/meta.dart';
-
-class A{
- @doNotStore
- final f = '';
-}
-
-class B {
- String f = A().f;
-}
-''', [
- error(WarningCode.ASSIGNMENT_OF_DO_NOT_STORE, 99, 5),
- ]);
- }
-
test_classStaticGetter() async {
await assertErrorsInCode('''
import 'package:meta/meta.dart';
@@ -164,24 +146,6 @@
]);
}
- @FailingTest(issue: 'https://github.com/dart-lang/sdk/issues/48476')
- test_classStaticVariable() async {
- await assertErrorsInCode('''
-import 'package:meta/meta.dart';
-
-class A{
- @doNotStore
- static final f = '';
-}
-
-class B {
- String f = A.f;
-}
-''', [
- error(WarningCode.ASSIGNMENT_OF_DO_NOT_STORE, 106, 3),
- ]);
- }
-
test_functionAssignment() async {
await assertNoErrorsInCode('''
import 'package:meta/meta.dart';
@@ -272,56 +236,23 @@
]);
}
- @FailingTest(issue: 'https://github.com/dart-lang/sdk/issues/48476')
- test_topLevelVariable() async {
+ test_topLevelGetter_binaryExpression() async {
await assertErrorsInCode('''
import 'package:meta/meta.dart';
@doNotStore
-final v = '';
+String? get v => '';
class A {
- final f = v;
+ final f = v ?? v;
}
''', [
- error(WarningCode.ASSIGNMENT_OF_DO_NOT_STORE, 83, 1),
+ error(WarningCode.ASSIGNMENT_OF_DO_NOT_STORE, 90, 1),
+ error(WarningCode.ASSIGNMENT_OF_DO_NOT_STORE, 95, 1),
]);
}
- @FailingTest(issue: 'https://github.com/dart-lang/sdk/issues/48476')
- test_topLevelVariable_assignment_field() async {
- await assertErrorsInCode('''
-import 'package:meta/meta.dart';
-
-String top = A().f;
-
-class A{
- @doNotStore
- final f = '';
-}
-''', [
- error(WarningCode.ASSIGNMENT_OF_DO_NOT_STORE, 47, 5,
- messageContains: ["'f'"]),
- ]);
- }
-
- @FailingTest(issue: 'https://github.com/dart-lang/sdk/issues/48476')
- test_topLevelVariable_assignment_functionExpression() async {
- await assertErrorsInCode('''
-import 'package:meta/meta.dart';
-
-@doNotStore
-String _v = '';
-
-var c = ()=> _v;
-
-String v = c();
-''', [
- error(WarningCode.ASSIGNMENT_OF_DO_NOT_STORE, 76, 2),
- ]);
- }
-
- test_topLevelVariable_assignment_getter() async {
+ test_topLevelGVariable_assignment_getter() async {
await assertErrorsInCode('''
import 'package:meta/meta.dart';
@@ -335,6 +266,37 @@
]);
}
+ test_topLevelVariable_assignment_field() async {
+ await assertErrorsInCode('''
+import 'package:meta/meta.dart';
+
+String top = A().f;
+
+class A{
+ @doNotStore
+ String get f => '';
+}
+''', [
+ error(WarningCode.ASSIGNMENT_OF_DO_NOT_STORE, 47, 5,
+ messageContains: ["'f'"]),
+ ]);
+ }
+
+ test_topLevelVariable_assignment_functionExpression() async {
+ await assertErrorsInCode('''
+import 'package:meta/meta.dart';
+
+@doNotStore
+String get _v => '';
+
+var c = () => _v;
+
+String v = c();
+''', [
+ error(WarningCode.ASSIGNMENT_OF_DO_NOT_STORE, 82, 2),
+ ]);
+ }
+
test_topLevelVariable_assignment_method() async {
await assertErrorsInCode('''
import 'package:meta/meta.dart';
@@ -351,23 +313,6 @@
]);
}
- @FailingTest(issue: 'https://github.com/dart-lang/sdk/issues/48476')
- test_topLevelVariable_binaryExpression() async {
- await assertErrorsInCode('''
-import 'package:meta/meta.dart';
-
-@doNotStore
-final String? v = '';
-
-class A {
- final f = v ?? v;
-}
-''', [
- error(WarningCode.ASSIGNMENT_OF_DO_NOT_STORE, 91, 1),
- error(WarningCode.ASSIGNMENT_OF_DO_NOT_STORE, 96, 1),
- ]);
- }
-
test_topLevelVariable_libraryAnnotation() async {
newFile('$testPackageLibPath/library.dart', '''
@doNotStore
@@ -389,21 +334,20 @@
]);
}
- @FailingTest(issue: 'https://github.com/dart-lang/sdk/issues/48476')
test_topLevelVariable_ternary() async {
await assertErrorsInCode('''
import 'package:meta/meta.dart';
@doNotStore
-final v = '';
+String get v => '';
class A {
static bool c = false;
final f = c ? v : v;
}
''', [
- error(WarningCode.ASSIGNMENT_OF_DO_NOT_STORE, 112, 1),
- error(WarningCode.ASSIGNMENT_OF_DO_NOT_STORE, 116, 1),
+ error(WarningCode.ASSIGNMENT_OF_DO_NOT_STORE, 118, 1),
+ error(WarningCode.ASSIGNMENT_OF_DO_NOT_STORE, 122, 1),
]);
}
}
diff --git a/pkg/analyzer/test/src/diagnostics/inference_failure_on_function_invocation_test.dart b/pkg/analyzer/test/src/diagnostics/inference_failure_on_function_invocation_test.dart
index 8e09d73..f1712cb 100644
--- a/pkg/analyzer/test/src/diagnostics/inference_failure_on_function_invocation_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/inference_failure_on_function_invocation_test.dart
@@ -48,16 +48,6 @@
''');
}
- @FailingTest(issue: 'https://github.com/dart-lang/sdk/issues/48476')
- test_functionType_optionalTypeArgs() async {
- await assertNoErrorsInCode('''
-import 'package:meta/meta.dart';
-void f(@optionalTypeArgs void Function<T>() m) {
- m();
-}
-''');
- }
-
test_genericFunctionExpression_explicitTypeArg() async {
await assertNoErrorsInCode('''
void f(void Function<T>()? m, void Function<T>() n) {
diff --git a/pkg/analyzer/test/src/diagnostics/return_of_do_not_store_test.dart b/pkg/analyzer/test/src/diagnostics/return_of_do_not_store_test.dart
index 58a4b8c..4428b41 100644
--- a/pkg/analyzer/test/src/diagnostics/return_of_do_not_store_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/return_of_do_not_store_test.dart
@@ -22,7 +22,6 @@
writeTestPackageConfigWithMeta();
}
- @FailingTest(issue: 'https://github.com/dart-lang/sdk/issues/48476')
test_noHintsInTestDir() async {
// Code that is in a test dir (the default for PubPackageResolutionTests)
// should not trigger the hint.
@@ -32,7 +31,7 @@
import 'package:meta/meta.dart';
@doNotStore
-String _v = '';
+String get _v => '';
String f() {
var v = () => _v;
@@ -76,30 +75,28 @@
]);
}
- @FailingTest(issue: 'https://github.com/dart-lang/sdk/issues/48476')
test_returnFromClosureInFunction() async {
await assertErrorsInCode('''
import 'package:meta/meta.dart';
@doNotStore
-String _v = '';
+String get _v => '';
String f() {
var v = () => _v;
return v();
}
''', [
- error(WarningCode.RETURN_OF_DO_NOT_STORE, 92, 2),
+ error(WarningCode.RETURN_OF_DO_NOT_STORE, 97, 2),
]);
}
- @FailingTest(issue: 'https://github.com/dart-lang/sdk/issues/48476')
test_returnFromFunction() async {
await assertErrorsInCode('''
import 'package:meta/meta.dart';
@doNotStore
-String v = '';
+String get v => '';
String getV() {
return v;
@@ -110,20 +107,19 @@
@doNotStore
String getV3() => v;
''', [
- error(WarningCode.RETURN_OF_DO_NOT_STORE, 87, 1,
+ error(WarningCode.RETURN_OF_DO_NOT_STORE, 92, 1,
messageContains: ['getV']),
- error(WarningCode.RETURN_OF_DO_NOT_STORE, 111, 1,
+ error(WarningCode.RETURN_OF_DO_NOT_STORE, 116, 1,
messageContains: ['getV2']),
]);
}
- @FailingTest(issue: 'https://github.com/dart-lang/sdk/issues/48476')
test_returnFromGetter() async {
await assertErrorsInCode('''
import 'package:meta/meta.dart';
@doNotStore
-String _v = '';
+String get _v => '';
String get v {
return _v;
@@ -134,60 +130,57 @@
@doNotStore
String get v3 => _v;
''', [
- error(WarningCode.RETURN_OF_DO_NOT_STORE, 87, 2, messageContains: ['v']),
- error(WarningCode.RETURN_OF_DO_NOT_STORE, 111, 2,
+ error(WarningCode.RETURN_OF_DO_NOT_STORE, 92, 2, messageContains: ['v']),
+ error(WarningCode.RETURN_OF_DO_NOT_STORE, 116, 2,
messageContains: ['v2']),
]);
}
- @FailingTest(issue: 'https://github.com/dart-lang/sdk/issues/48476')
test_returnFromGetter_binaryExpression() async {
await assertErrorsInCode('''
import 'package:meta/meta.dart';
@doNotStore
-String? _v = '';
+String? get _v => '';
@doNotStore
-String? _v2 = '';
+String? get _v2 => '';
String? get v => _v ?? _v2;
''', [
- error(WarningCode.RETURN_OF_DO_NOT_STORE, 112, 2,
+ error(WarningCode.RETURN_OF_DO_NOT_STORE, 122, 2,
messageContains: ['_v']),
- error(WarningCode.RETURN_OF_DO_NOT_STORE, 118, 3,
+ error(WarningCode.RETURN_OF_DO_NOT_STORE, 128, 3,
messageContains: ['_v2']),
]);
}
- @FailingTest(issue: 'https://github.com/dart-lang/sdk/issues/48476')
test_returnFromGetter_ternary() async {
await assertErrorsInCode('''
import 'package:meta/meta.dart';
@doNotStore
-String _v = '';
+String get _v => '';
@doNotStore
-String _v2 = '';
+String get _v2 => '';
var b = true;
String get v => b ? _v : _v2;
''', [
- error(WarningCode.RETURN_OF_DO_NOT_STORE, 128, 2),
- error(WarningCode.RETURN_OF_DO_NOT_STORE, 133, 3),
+ error(WarningCode.RETURN_OF_DO_NOT_STORE, 138, 2),
+ error(WarningCode.RETURN_OF_DO_NOT_STORE, 143, 3),
]);
}
- @FailingTest(issue: 'https://github.com/dart-lang/sdk/issues/48476')
test_returnFromMethod() async {
await assertErrorsInCode('''
import 'package:meta/meta.dart';
class A {
@doNotStore
- String _v = '';
+ String get _v => '';
String getV() {
return _v;
@@ -199,9 +192,9 @@
String getV3() => _v;
}
''', [
- error(WarningCode.RETURN_OF_DO_NOT_STORE, 106, 2,
+ error(WarningCode.RETURN_OF_DO_NOT_STORE, 111, 2,
messageContains: ['getV']),
- error(WarningCode.RETURN_OF_DO_NOT_STORE, 135, 2,
+ error(WarningCode.RETURN_OF_DO_NOT_STORE, 140, 2,
messageContains: ['getV2']),
]);
}