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

Unified Diff: editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/resolver/CompileTimeErrorCodeTest.java

Issue 397823004: Detect invalid const constructor due to non-const initializer in field declaration. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Comment fix Created 6 years, 5 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: editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/resolver/CompileTimeErrorCodeTest.java
diff --git a/editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/resolver/CompileTimeErrorCodeTest.java b/editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/resolver/CompileTimeErrorCodeTest.java
index cdd7f519eeecf2c6ed015b3aba5499852002ca1e..a402596b362329a5cf6001af812c0cb1440638ca 100644
--- a/editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/resolver/CompileTimeErrorCodeTest.java
+++ b/editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/resolver/CompileTimeErrorCodeTest.java
@@ -439,6 +439,34 @@ public class CompileTimeErrorCodeTest extends ResolverTestCase {
verify(source);
}
+ public void test_constConstructorWithFieldInitializedByNonConst() throws Exception {
+ Source source = addSource(createSource(//
+ "class A {",
+ " final int i = f();",
+ " const A();",
+ "}",
+ "int f() {",
+ " return 3;",
+ "}"));
+ resolve(source);
+ assertErrors(source, CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_FIELD_INITIALIZED_BY_NON_CONST);
+ verify(source);
+ }
+
+ public void test_constConstructorWithFieldInitializedByNonConst_static() throws Exception {
+ Source source = addSource(createSource(//
+ "class A {",
+ " static final int i = f();",
+ " const A();",
+ "}",
+ "int f() {",
+ " return 3;",
+ "}"));
+ resolve(source);
+ assertNoErrors(source);
+ verify(source);
+ }
+
public void test_constConstructorWithMixin() throws Exception {
Source source = addSource(createSource(//
"class M {",

Powered by Google App Engine
This is Rietveld 408576698