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

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

Issue 10991064: Issue 5350. Type variable should be accessible in instance field (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 3 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 40bf5f25dd73d2141f33fe2b1775d167092a5000..ba575f15ecbd0f7f2ab2764e5f54c7011179b0bf 100644
--- a/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java
+++ b/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java
@@ -5251,6 +5251,56 @@ public class TypeAnalyzerCompilerTest extends CompilerTestCase {
assertErrors(result.getErrors(), errEx(TypeErrorCode.CANNOT_BE_RESOLVED, 5, 5, 1));
}
+ public void test_typeVariableScope_staticField() throws Exception {
+ AnalyzeLibraryResult result = analyzeLibrary(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "class A<T> {",
+ " static T v;",
+ "}",
+ "");
+ assertErrors(
+ result.getErrors(),
+ errEx(ResolverErrorCode.TYPE_VARIABLE_IN_STATIC_CONTEXT, 3, 10, 1));
+ }
+
+ public void test_typeVariableScope_staticMethod() throws Exception {
+ AnalyzeLibraryResult result = analyzeLibrary(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "class A<T> {",
+ " static foo() {",
+ " T v = null;",
+ " }",
+ "}",
+ "");
+ assertErrors(
+ result.getErrors(),
+ errEx(ResolverErrorCode.TYPE_VARIABLE_IN_STATIC_CONTEXT, 4, 5, 1));
+ }
+
+ public void test_typeVariableScope_instanceField() throws Exception {
+ AnalyzeLibraryResult result = analyzeLibrary(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "class A<T> {",
+ " final List<T> values = new List<T>();",
+ "}",
+ "");
+ assertErrors(result.getErrors());
+ }
+
+ public void test_unresolvedMethod_inFactoryConstructor() throws Exception {
+ AnalyzeLibraryResult result = analyzeLibrary(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "class A {",
+ " factory A() {",
+ " foo();",
+ " }",
+ "}",
+ "");
+ assertErrors(
+ result.getErrors(),
+ errEx(ResolverErrorCode.CANNOT_RESOLVE_METHOD, 4, 5, 3));
+ }
+
private <T extends DartNode> T findNode(final Class<T> clazz, String pattern) {
final int index = testSource.indexOf(pattern);
assertTrue(index != -1);
« no previous file with comments | « compiler/java/com/google/dart/compiler/resolver/ResolverErrorCode.java ('k') | tests/language/language.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698