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

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

Issue 1099953004: In constant evaluation, handle final vars initialized at declaration site. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 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
Index: pkg/analyzer/test/generated/resolver_test.dart
diff --git a/pkg/analyzer/test/generated/resolver_test.dart b/pkg/analyzer/test/generated/resolver_test.dart
index 37c0d6bb90c03112f77ab6f27bee66ff39dfa908..738291692958af66976db6ddd7f651501281efd6 100644
--- a/pkg/analyzer/test/generated/resolver_test.dart
+++ b/pkg/analyzer/test/generated/resolver_test.dart
@@ -913,6 +913,23 @@ var v = const A('foo');''');
verify([source]);
}
+ void test_fieldTypeMismatch_generic() {
+ Source source = addSource(r'''
+class C<T> {
+ final T x = y;
+ const C();
+}
+const y = 1;
+var v = const C<String>();
+''');
+ resolve(source);
+ assertErrors(source, [
+ CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_FIELD_TYPE_MISMATCH,
+ HintCode.INVALID_ASSIGNMENT
+ ]);
+ verify([source]);
+ }
+
void test_fieldTypeMismatch_unresolved() {
Source source = addSource(r'''
class A {
@@ -928,6 +945,20 @@ var v = const A('foo');''');
verify([source]);
}
+ void test_fieldTypeOk_generic() {
+ Source source = addSource(r'''
+class C<T> {
+ final T x = y;
+ const C();
+}
+const y = 1;
+var v = const C<int>();
+''');
+ resolve(source);
+ assertErrors(source, [HintCode.INVALID_ASSIGNMENT]);
+ verify([source]);
+ }
+
void test_fieldTypeOk_null() {
Source source = addSource(r'''
class A {

Powered by Google App Engine
This is Rietveld 408576698