Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(812)

Unified Diff: pkg/analyzer/test/generated/hint_code_test.dart

Issue 2832013002: Issue 29393. Consider 'v ??= doSomething()' as usage of 'v'. (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer/lib/src/generated/resolver.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/test/generated/hint_code_test.dart
diff --git a/pkg/analyzer/test/generated/hint_code_test.dart b/pkg/analyzer/test/generated/hint_code_test.dart
index f0852ba7191d6869b03c49dad8c2b1e3f635adb0..5a28cffc2e5effb04008d9ff8cd60107af26de50 100644
--- a/pkg/analyzer/test/generated/hint_code_test.dart
+++ b/pkg/analyzer/test/generated/hint_code_test.dart
@@ -2007,45 +2007,45 @@ class A {
verify([source]);
}
- test_mustBeImmutable_instance() async {
+ test_mustBeImmutable_extends() async {
Source source = addSource(r'''
import 'package:meta/meta.dart';
@immutable
-class A {
- static int x;
+class A {}
+class B extends A {
+ int x;
}
''');
await computeAnalysisResult(source);
- assertErrors(source, []);
+ assertErrors(source, [HintCode.MUST_BE_IMMUTABLE]);
verify([source]);
}
- test_mustBeImmutable_extends() async {
+ test_mustBeImmutable_fromMixin() async {
Source source = addSource(r'''
import 'package:meta/meta.dart';
@immutable
class A {}
-class B extends A {
+class B {
int x;
}
+class C extends A with B {}
''');
await computeAnalysisResult(source);
assertErrors(source, [HintCode.MUST_BE_IMMUTABLE]);
verify([source]);
}
- test_mustBeImmutable_fromMixin() async {
+ test_mustBeImmutable_instance() async {
Source source = addSource(r'''
import 'package:meta/meta.dart';
@immutable
-class A {}
-class B {
- int x;
+class A {
+ static int x;
}
-class C extends A with B {}
''');
await computeAnalysisResult(source);
- assertErrors(source, [HintCode.MUST_BE_IMMUTABLE]);
+ assertErrors(source, []);
verify([source]);
}
@@ -3742,6 +3742,22 @@ class A {
verify([source]);
}
+ test_unusedField_notUsed_nullAssign() async {
+ enableUnusedElement = true;
+ Source source = addSource(r'''
+class A {
+ var _f;
+ m() {
+ _f ??= doSomething();
+ }
+}
+doSomething() => 0;
+''');
+ await computeAnalysisResult(source);
+ assertNoErrors(source);
+ verify([source]);
+ }
+
test_unusedField_notUsed_postfixExpr() async {
enableUnusedElement = true;
Source source = addSource(r'''
@@ -4014,6 +4030,21 @@ main() {
verify([source]);
}
+ test_unusedLocalVariable_isNullAssigned() async {
+ enableUnusedLocalVariable = true;
+ Source source = addSource(r'''
+typedef Foo();
+main() {
+ var v;
+ v ??= doSomething();
+}
+doSomething() => 42;
+''');
+ await computeAnalysisResult(source);
+ assertErrors(source);
+ verify([source]);
+ }
+
test_unusedLocalVariable_isRead_notUsed_compoundAssign() async {
enableUnusedLocalVariable = true;
Source source = addSource(r'''
« no previous file with comments | « pkg/analyzer/lib/src/generated/resolver.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698