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

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

Issue 1042133002: Generate warnings for assignment to a type. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 9 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
Index: pkg/analyzer/test/generated/static_warning_code_test.dart
diff --git a/pkg/analyzer/test/generated/static_warning_code_test.dart b/pkg/analyzer/test/generated/static_warning_code_test.dart
index 0ad381f9e0a1aa34906c462ef7e3a367339bab9a..6df4785a2bf39394eedc1d301f1b442a268d8c06 100644
--- a/pkg/analyzer/test/generated/static_warning_code_test.dart
+++ b/pkg/analyzer/test/generated/static_warning_code_test.dart
@@ -598,6 +598,17 @@ main() {
verify([source]);
}
+ void test_assignmentToClass() {
+ Source source = addSource('''
+class C {}
+main() {
+ C = null;
+}
+''');
+ resolve(source);
+ assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_TYPE]);
+ }
+
void test_assignmentToConst_instanceVariable() {
Source source = addSource(r'''
class A {
@@ -646,6 +657,17 @@ f() {
verify([source]);
}
+ void test_assignmentToEnumType() {
+ Source source = addSource('''
+enum E { e }
+main() {
+ E = null;
+}
+''');
+ resolve(source);
+ assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_TYPE]);
+ }
+
void test_assignmentToFinal_instanceVariable() {
Source source = addSource(r'''
class A {
@@ -825,6 +847,29 @@ f(A a) {
verify([source]);
}
+ void test_assignmentToTypedef() {
+ Source source = addSource('''
+typedef void F();
+main() {
+ F = null;
+}
+''');
+ resolve(source);
+ assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_TYPE]);
+ }
+
+ void test_assignmentToTypeParameter() {
+ Source source = addSource('''
+class C<T> {
+ f() {
+ T = null;
+ }
+}
+''');
+ resolve(source);
+ assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_TYPE]);
+ }
+
void test_caseBlockNotTerminated() {
Source source = addSource(r'''
f(int p) {

Powered by Google App Engine
This is Rietveld 408576698