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

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

Issue 9122015: Issue 988: Compile time error missing for const class / non-final instance variables (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Nits Created 8 years, 11 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/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 8ff0774f66f750bd379ed55d6dc33e2e6aa80d1d..6ac64c57d15d05a49e7539949983ab589bfabb18 100644
--- a/compiler/javatests/com/google/dart/compiler/resolver/NegativeResolverTest.java
+++ b/compiler/javatests/com/google/dart/compiler/resolver/NegativeResolverTest.java
@@ -886,7 +886,7 @@ public class NegativeResolverTest extends CompilerTestCase {
"class A {",
" const A(x) : this.foo(x);",
" A.foo(this.x) { }",
- " var x;",
+ " final x;",
"}"),
errEx(ResolverErrorCode.CONST_CONSTRUCTOR_MUST_CALL_CONST_SUPER, 3, 3, 25));
}
@@ -895,6 +895,26 @@ public class NegativeResolverTest extends CompilerTestCase {
checkNumErrors("RawTypesNegativeTest.dart", 6);
}
+ public void testConstConstructorNonFinalFieldsNegativeTest() {
+ checkSourceErrors(
+ makeCode(
+ "class A extends B {",
+ " const A();",
+ " var x;",
+ " final y = 10;",
+ " set z(value) {}",
+ "}",
+ "class B implements C {",
+ " final bar;",
+ " var baz;",
+ "}",
+ "interface C {",
+ " var x;",
+ "}"),
+ errEx(ResolverErrorCode.CONST_CLASS_WITH_NONFINAL_FIELDS, 3, 7, 1),
+ errEx(ResolverErrorCode.CONST_CLASS_WITH_INHERITED_NONFINAL_FIELDS, 9, 7, 3));
+ }
+
private TestCompilerContext getContext() {
return new TestCompilerContext() {
@Override

Powered by Google App Engine
This is Rietveld 408576698