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

Unified Diff: compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java

Issue 10545029: Issue 3181. Only fields of immediately surrounding class can be initialized (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 6 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/type/TypeAnalyzerCompilerTest.java
diff --git a/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java b/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java
index c6252cbb23a3aa21ff0a1d78f9648f0c8a10c130..bc1de74210c667b9a208356f4aafcc28fa5db2e8 100644
--- a/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java
+++ b/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java
@@ -75,6 +75,25 @@ public class TypeAnalyzerCompilerTest extends CompilerTestCase {
}
/**
+ * It is a compile-time error if initializer list contains an initializer for a variable that
+ * is not an instance variable declared in the immediately surrounding class.
+ * <p>
+ * http://code.google.com/p/dart/issues/detail?id=3181
+ */
+ public void test_initializerForNotField() throws Exception {
+ AnalyzeLibraryResult libraryResult = analyzeLibrary(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "var x;",
+ "class A {",
+ " A() : x = 5 {}",
+ "}",
+ "");
+ assertErrors(
+ libraryResult.getErrors(),
+ errEx(ResolverErrorCode.INIT_FIELD_ONLY_IMMEDIATELY_SURROUNDING_CLASS, 4, 9, 1));
+ }
+
+ /**
* Tests that we correctly provide {@link Element#getEnclosingElement()} for method of class.
*/
public void test_resolveClassMethod() throws Exception {

Powered by Google App Engine
This is Rietveld 408576698