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

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

Issue 10536203: Issue 2373. 'v is Unknown' is compile-time warning, not error (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 150b4b83f271310ef43d43fa28e813363d85bea7..323622dc52cd3356d413a5d8b124a8f103e15dff 100644
--- a/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java
+++ b/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java
@@ -2643,6 +2643,59 @@ public class TypeAnalyzerCompilerTest extends CompilerTestCase {
errEx(TypeErrorCode.CANNOT_BE_RESOLVED, 8, 4, 2));
}
+ /**
+ * It is a static warning if T does not denote a type available in the current lexical scope.
+ * <p>
+ * http://code.google.com/p/dart/issues/detail?id=2373
+ */
+ public void test_asType_unknown() throws Exception {
+ AnalyzeLibraryResult libraryResult = analyzeLibrary(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "main() {",
+ " null as T;",
+ "}",
+ "");
+ assertErrors(
+ libraryResult.getErrors(),
+ errEx(TypeErrorCode.NO_SUCH_TYPE, 3, 11, 1));
+ }
+
+ /**
+ * It is a compile-time error if T is a parameterized type of the form G < T1; : : : ; Tn > and G
+ * is not a generic type with n type parameters.
+ * <p>
+ * http://code.google.com/p/dart/issues/detail?id=2373
+ */
+ public void test_asType_wrongNumberOfTypeArguments() throws Exception {
+ AnalyzeLibraryResult libraryResult = analyzeLibrary(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "class A {}",
+ "main() {",
+ " null as A<int, bool>;",
+ "}",
+ "");
+ assertErrors(
+ libraryResult.getErrors(),
+ errEx(ResolverErrorCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS, 4, 11, 12));
+ }
+
+ /**
+ * It is a static warning if T does not denote a type available in the current lexical scope.
+ * <p>
+ * http://code.google.com/p/dart/issues/detail?id=2373
+ */
+ public void test_unknownIsType() throws Exception {
Brian Wilkerson 2012/06/19 16:16:51 nit: I would prefer to see this named "test_isType
+ AnalyzeLibraryResult libraryResult = analyzeLibrary(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "main() {",
+ " null is T;",
+ "}",
+ "");
+ assertErrors(
+ libraryResult.getErrors(),
+ errEx(TypeErrorCode.NO_SUCH_TYPE, 3, 11, 1));
+ }
+
private AnalyzeLibraryResult analyzeLibrary(String... lines) throws Exception {
return analyzeLibrary(getName(), makeCode(lines));
}
« 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