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

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

Issue 10665018: Issue 2477. Can not reference instance method from initializer (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/resolver/ResolverTest.java
diff --git a/compiler/javatests/com/google/dart/compiler/resolver/ResolverTest.java b/compiler/javatests/com/google/dart/compiler/resolver/ResolverTest.java
index f1c287972691cdad6080d6cce642b527a7c794e6..7730fcf1797107113a4b017ebb1b9250bc14c965 100644
--- a/compiler/javatests/com/google/dart/compiler/resolver/ResolverTest.java
+++ b/compiler/javatests/com/google/dart/compiler/resolver/ResolverTest.java
@@ -4,6 +4,8 @@
package com.google.dart.compiler.resolver;
+import static com.google.dart.compiler.common.ErrorExpectation.errEx;
+
import com.google.common.base.Joiner;
import com.google.dart.compiler.DartCompilationError;
import com.google.dart.compiler.ErrorCode;
@@ -14,8 +16,6 @@ import com.google.dart.compiler.type.InterfaceType;
import com.google.dart.compiler.type.Type;
import com.google.dart.compiler.type.Types;
-import static com.google.dart.compiler.common.ErrorExpectation.errEx;
-
import junit.framework.Assert;
import java.util.List;
@@ -1329,6 +1329,44 @@ public class ResolverTest extends ResolverTestCase {
errEx(ResolverErrorCode.NAMED_PARAMETERS_CANNOT_START_WITH_UNDER, 2, 22, 4));
}
+ /**
+ * "this" is not accessible to initializers, so invocation of instance method is error.
+ * <p>
+ * http://code.google.com/p/dart/issues/detail?id=2477
+ */
+ public void test_callInstanceMethod_fromInitializer() throws Exception {
+ resolveAndTest(
+ Joiner.on("\n").join(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "class Object {}",
+ "class A {",
+ " var x;",
+ " A() : x = foo() {}",
+ " foo() {}",
+ "}",
+ ""),
+ errEx(ResolverErrorCode.INSTANCE_METHOD_FROM_INITIALIZER, 5, 13, 5));
+ }
+
+ /**
+ * "this" is not accessible to initializers, so reference of instance method is error.
+ * <p>
+ * http://code.google.com/p/dart/issues/detail?id=2477
+ */
+ public void test_referenceInstanceMethod_fromInitializer() throws Exception {
+ resolveAndTest(
+ Joiner.on("\n").join(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "class Object {}",
+ "class A {",
+ " var x;",
+ " A() : x = foo {}",
+ " foo() {}",
+ "}",
+ ""),
+ errEx(ResolverErrorCode.INSTANCE_METHOD_FROM_INITIALIZER, 5, 13, 3));
+ }
+
public void testRedirectConstructor() {
resolveAndTest(Joiner.on("\n").join(
"class Object {}",

Powered by Google App Engine
This is Rietveld 408576698