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

Unified Diff: editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/resolver/CompileTimeErrorCodeTest.java

Issue 15085012: Report CompileTimeErrorCode.INVALID_REFERENCE_TO_THIS (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Tweak for review comments. Created 7 years, 7 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: editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/resolver/CompileTimeErrorCodeTest.java
diff --git a/editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/resolver/CompileTimeErrorCodeTest.java b/editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/resolver/CompileTimeErrorCodeTest.java
index 4ba39dcddbb9d40ce4140cc8943870b0658a1a70..1f6a9cadfb44f1dbfeefcaf34b0f403fb3ef1e73 100644
--- a/editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/resolver/CompileTimeErrorCodeTest.java
+++ b/editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/resolver/CompileTimeErrorCodeTest.java
@@ -237,32 +237,6 @@ public class CompileTimeErrorCodeTest extends ResolverTestCase {
verify(source);
}
- public void fail_invalidReferenceToThis_staticMethod() throws Exception {
- Source source = addSource(createSource(//
- "class A {",
- " static m() { return this; }",
- "}"));
- resolve(source);
- assertErrors(CompileTimeErrorCode.INVALID_REFERENCE_TO_THIS);
- verify(source);
- }
-
- public void fail_invalidReferenceToThis_topLevelFunction() throws Exception {
- Source source = addSource(createSource(//
- "f() { return this; }"));
- resolve(source);
- assertErrors(CompileTimeErrorCode.INVALID_REFERENCE_TO_THIS);
- verify(source);
- }
-
- public void fail_invalidReferenceToThis_variableInitializer() throws Exception {
- Source source = addSource(createSource(//
- "int x = this;"));
- resolve(source);
- assertErrors(CompileTimeErrorCode.INVALID_REFERENCE_TO_THIS);
- verify(source);
- }
-
public void fail_mixinDeclaresConstructor() throws Exception {
Source source = addSource(createSource(//
"class A {",
@@ -1583,6 +1557,73 @@ public class CompileTimeErrorCodeTest extends ResolverTestCase {
verify(source);
}
+ public void test_invalidReferenceToThis_factoryConstructor() throws Exception {
+ Source source = addSource(createSource(//
+ "class A {",
+ " factory A() { return this; }",
+ "}"));
+ resolve(source);
+ assertErrors(CompileTimeErrorCode.INVALID_REFERENCE_TO_THIS);
+ verify(source);
+ }
+
+ public void test_invalidReferenceToThis_instanceVariableInitializer_inConstructor()
+ throws Exception {
+ Source source = addSource(createSource(//
+ "class A {",
+ " var f;",
+ " A() : f = this;",
+ "}"));
+ resolve(source);
+ assertErrors(CompileTimeErrorCode.INVALID_REFERENCE_TO_THIS);
+ verify(source);
+ }
+
+ public void test_invalidReferenceToThis_instanceVariableInitializer_inDeclaration()
+ throws Exception {
+ Source source = addSource(createSource(//
+ "class A {",
+ " var f = this;",
+ "}"));
+ resolve(source);
+ assertErrors(CompileTimeErrorCode.INVALID_REFERENCE_TO_THIS);
+ verify(source);
+ }
+
+ public void test_invalidReferenceToThis_staticMethod() throws Exception {
+ Source source = addSource(createSource(//
+ "class A {",
+ " static m() { return this; }",
+ "}"));
+ resolve(source);
+ assertErrors(CompileTimeErrorCode.INVALID_REFERENCE_TO_THIS);
+ verify(source);
+ }
+
+ public void test_invalidReferenceToThis_staticVariableInitializer() throws Exception {
+ Source source = addSource(createSource(//
+ "class A {",
+ " static f = this;",
+ "}"));
+ resolve(source);
+ assertErrors(CompileTimeErrorCode.INVALID_REFERENCE_TO_THIS);
+ verify(source);
+ }
+
+ public void test_invalidReferenceToThis_topLevelFunction() throws Exception {
+ Source source = addSource("f() { return this; }");
+ resolve(source);
+ assertErrors(CompileTimeErrorCode.INVALID_REFERENCE_TO_THIS);
+ verify(source);
+ }
+
+ public void test_invalidReferenceToThis_variableInitializer() throws Exception {
+ Source source = addSource("int x = this;");
+ resolve(source);
+ assertErrors(CompileTimeErrorCode.INVALID_REFERENCE_TO_THIS);
+ verify(source);
+ }
+
public void test_invalidTypeArgumentForKey() throws Exception {
Source source = addSource(createSource(//
"class A {",

Powered by Google App Engine
This is Rietveld 408576698