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

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

Issue 11369050: Issue 6489. Report error when static method attempts to access const instance field. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 1 month 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/NegativeResolverTest.java
diff --git a/compiler/javatests/com/google/dart/compiler/resolver/NegativeResolverTest.java b/compiler/javatests/com/google/dart/compiler/resolver/NegativeResolverTest.java
index 28d4dc586a13d81399d94def9cbbb3a11d6c707d..9eeab098ae0ca4f919d878fdab428f3aba4af7b8 100644
--- a/compiler/javatests/com/google/dart/compiler/resolver/NegativeResolverTest.java
+++ b/compiler/javatests/com/google/dart/compiler/resolver/NegativeResolverTest.java
@@ -1147,4 +1147,38 @@ public class NegativeResolverTest extends CompilerTestCase {
errEx(ResolverErrorCode.CANNOT_ASSIGN_TO_FINAL, 7, 7, 1),
errEx(ResolverErrorCode.CANNOT_ASSIGN_TO_FINAL, 8, 7, 1));
}
+
+ /**
+ * <p>
+ * http://code.google.com/p/dart/issues/detail?id=5987
+ */
+ public void test_accessConstInstanceField_fromConstStaticField() throws Exception {
+ checkSourceErrors(
+ makeCode(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "class A {",
+ " const x = 499;",
+ " static const bar = x;",
+ "}",
+ ""),
+ errEx(ResolverErrorCode.ILLEGAL_FIELD_ACCESS_FROM_STATIC, 4, 22, 1));
+ }
+
+ /**
+ * <p>
+ * http://code.google.com/p/dart/issues/detail?id=6489
+ */
+ public void test_accessConstInstanceField_fromConstStaticMethod() throws Exception {
+ checkSourceErrors(
+ makeCode(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "class A {",
+ " const CONST = 26;",
+ " static int foo() {",
+ " return CONST;",
+ " }",
+ "}",
+ ""),
+ errEx(ResolverErrorCode.ILLEGAL_FIELD_ACCESS_FROM_STATIC, 5, 12, 5));
+ }
}

Powered by Google App Engine
This is Rietveld 408576698