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

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

Issue 644283002: Type check field assignments during constant evaluation. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 2 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 618c33aa405fb9766e1b9e58aa3b1adbf8ea1136..7373b87d84755f344aa68304d9ab28931e0221d8 100644
--- a/pkg/analyzer/test/generated/resolver_test.dart
+++ b/pkg/analyzer/test/generated/resolver_test.dart
@@ -735,6 +735,31 @@ class CheckedModeCompileTimeErrorCodeTest extends ResolverTestCase {
verify([source]);
}
+ void test_fieldTypeMismatch() {
+ Source source = addSource(EngineTestCase.createSource([
+ "class A {",
+ " const A(x) : y = x;",
+ " final int y;",
+ "}",
+ "var v = const A('foo');"]));
+ resolve(source);
+ assertErrors(source, [
+ CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_FIELD_TYPE_MISMATCH]);
+ verify([source]);
+ }
+
+ void test_fieldTypeOk_null() {
+ Source source = addSource(EngineTestCase.createSource([
+ "class A {",
+ " const A(x) : y = x;",
+ " final int y;",
+ "}",
+ "var v = const A(null);"]));
+ resolve(source);
+ assertNoErrors(source);
+ verify([source]);
+ }
+
void test_listElementTypeNotAssignable() {
Source source = addSource(EngineTestCase.createSource(["var v = const <String> [42];"]));
resolve(source);

Powered by Google App Engine
This is Rietveld 408576698