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

Unified Diff: pkg/analyzer/test/src/task/strong/non_null_checker_test.dart

Issue 2302573003: Check for non-null assignment when checking casts (Closed) Base URL: https://github.com/dart-lang/sdk@master
Patch Set: Add tests Created 4 years, 3 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/task/strong/checker.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/src/task/strong/non_null_checker_test.dart
diff --git a/pkg/analyzer/test/src/task/strong/non_null_checker_test.dart b/pkg/analyzer/test/src/task/strong/non_null_checker_test.dart
index 47a022fc42332868359f94c30369d9e59281fb4d..8db9b2442fe6f27dbfb12fcff206389d62865cd3 100644
--- a/pkg/analyzer/test/src/task/strong/non_null_checker_test.dart
+++ b/pkg/analyzer/test/src/task/strong/non_null_checker_test.dart
@@ -106,6 +106,30 @@ main() {
''');
}
+ void test_compoundAssignment() {
+ addFile('''
+void main() {
+ int i = 1;
+ i += 2;
+ /*error:STATIC_TYPE_ERROR*/i += null;
+ print(i);
+}
+''');
+ check(nonnullableTypes: <String>['dart:core,int']);
+ }
+
+ void test_forEach() {
+ addFile('''
+void main() {
+ var ints = <num>[1, 2, 3, null];
+ for (int /*error:INVALID_ASSIGNMENT*/i in ints) {
+ print(i);
+ }
+}
+''');
+ check(nonnullableTypes: <String>['dart:core,int']);
+ }
+
void test_initialize_nonnullable_with_null() {
addFile('int x = /*error:INVALID_ASSIGNMENT*/null;');
check(nonnullableTypes: <String>['dart:core,int']);
« no previous file with comments | « pkg/analyzer/lib/src/task/strong/checker.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698