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

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

Issue 10826249: Issue 3084. Generate warning, not error, for 'Unknown.unknown' (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 4 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 d6163c32385a4991e95f01587eea74a722f62eaf..75cb4798a4fa4ad89d60f9be75005c2cbd4a57df 100644
--- a/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java
+++ b/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java
@@ -3355,6 +3355,66 @@ public class TypeAnalyzerCompilerTest extends CompilerTestCase {
assertTrue(libraryResult.getErrors().size() != 0);
}
+ /**
+ * If "unknown" is separate identifier, it is handled as "this.unknown", but "this" is not
+ * accessible in static context.
+ * <p>
+ * http://code.google.com/p/dart/issues/detail?id=3084
+ */
+ public void test_unresolvedIdentifier_inStatic_notPropertyAccess() throws Exception {
+ AnalyzeLibraryResult libraryResult = analyzeLibrary(makeCode(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "process(x) {}",
+ "main() {",
+ " unknown = 0;",
+ " process(unknown);",
+ "}"));
+ assertErrors(
+ libraryResult.getErrors(),
+ errEx(ResolverErrorCode.CANNOT_BE_RESOLVED, 4, 3, 7),
+ errEx(ResolverErrorCode.CANNOT_BE_RESOLVED, 5, 11, 7));
+ }
+
+ /**
+ * If "unknown" is separate identifier, it is handled as "this.unknown", but "this" is not
+ * accessible in static context.
+ * <p>
+ * http://code.google.com/p/dart/issues/detail?id=3084
+ */
+ public void test_unresolvedIdentifier_inInstance_notPropertyAccess() throws Exception {
+ AnalyzeLibraryResult libraryResult = analyzeLibrary(makeCode(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "process(x) {}",
+ "class A {",
+ " foo() {",
+ " unknown = 0;",
+ " process(unknown);",
+ " }",
+ "}"));
+ assertErrors(
+ libraryResult.getErrors(),
+ errEx(TypeErrorCode.CANNOT_BE_RESOLVED, 5, 5, 7),
+ errEx(TypeErrorCode.CANNOT_BE_RESOLVED, 6, 13, 7));
+ }
+
+ /**
+ * <p>
+ * http://code.google.com/p/dart/issues/detail?id=3084
+ */
+ public void test_unresolvedIdentifier_inStatic_inPropertyAccess() throws Exception {
+ AnalyzeLibraryResult libraryResult = analyzeLibrary(makeCode(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "process(x) {}",
+ "main() {",
+ " Unknown.foo = 0;",
+ " process(Unknown.foo);",
+ "}"));
+ assertErrors(
+ libraryResult.getErrors(),
+ errEx(TypeErrorCode.CANNOT_BE_RESOLVED, 4, 3, 7),
+ errEx(TypeErrorCode.CANNOT_BE_RESOLVED, 5, 11, 7));
+ }
+
private static <T extends DartNode> T findNode(
AnalyzeLibraryResult libraryResult,
final Class<T> clazz,
« no previous file with comments | « compiler/javatests/com/google/dart/compiler/resolver/ResolverTest.java ('k') | tests/co19/co19-compiler.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698