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

Unified Diff: compiler/javatests/com/google/dart/compiler/resolver/CompileTimeConstantTest.java

Issue 10919290: Issue 3476. Final variables don't have to have constant initializers (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 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
Index: compiler/javatests/com/google/dart/compiler/resolver/CompileTimeConstantTest.java
diff --git a/compiler/javatests/com/google/dart/compiler/resolver/CompileTimeConstantTest.java b/compiler/javatests/com/google/dart/compiler/resolver/CompileTimeConstantTest.java
index 8763508634144238176a5fd1380b514c2643e15e..5b2d316612be923e78b5bc40d416f70d736616b1 100644
--- a/compiler/javatests/com/google/dart/compiler/resolver/CompileTimeConstantTest.java
+++ b/compiler/javatests/com/google/dart/compiler/resolver/CompileTimeConstantTest.java
@@ -39,6 +39,30 @@ public class CompileTimeConstantTest extends ResolverTestCase {
" var f = new Object();",
"}"));
}
+
+ /**
+ * Final variable does not have to have constant initializer.
+ */
+ public void test_finalIsNoConst() {
+ resolveAndTestCtConstExpectErrors(Joiner.on("\n").join(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "class Object {}",
+ "class int {}",
+ "",
+ "foo() => 10;",
+ "final g1 = foo();",
+ "var g2 = foo();",
+ "",
+ "class A {",
+ " static final f1 = bar();",
+ " static var f2 = bar();",
+ " bar() => 20;",
+ "}",
+ "main() {",
+ " final v1 = foo();",
+ "}",
+ ""));
+ }
/**
* We can not reference "this" directly or indirectly as reference to other fields.
@@ -377,7 +401,7 @@ public class CompileTimeConstantTest extends ResolverTestCase {
" m() {}",
" static const V1 = m;",
"}",
- "final V2 = A.m;",
+ "const V2 = A.m;",
""),
errEx(ResolverErrorCode.ILLEGAL_METHOD_ACCESS_FROM_STATIC, 5, 21, 1),
errEx(ResolverErrorCode.NOT_A_STATIC_METHOD, 7, 14, 1),

Powered by Google App Engine
This is Rietveld 408576698