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

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

Issue 10544068: Issue 3307. Report error when built-in identifier used as type annotation (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Status file changes after new co19 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 2aad3a98d61271131c39d77c19e080cdfdd1a5f4..6881dc825708e500f27c1424a6f014829d1e6ea9 100644
--- a/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java
+++ b/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java
@@ -2093,6 +2093,64 @@ public class TypeAnalyzerCompilerTest extends CompilerTestCase {
errEx(TypeErrorCode.SUPERTYPE_HAS_METHOD, 8, 7, 3),
errEx(TypeErrorCode.SUPERTYPE_HAS_METHOD, 9, 7, 3));
}
+
+ /**
+ * Ensure that "operator call()" is parsed, and "operator" is not considered as return type. This
+ * too weak test, but for now we are interested only in parsing.
+ */
+ public void test_callOperator_parsing() throws Exception {
+ AnalyzeLibraryResult libraryResult = analyzeLibrary(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "class A {",
+ " operator call() => 42;",
+ "}",
+ "");
+ assertErrors(libraryResult.getErrors());
+ }
+
+ /**
+ * The spec in the section 10.28 says:
+ * "It is a compile-time error to use a built-in identifier other than Dynamic as a type annotation."
+ * <p>
+ * http://code.google.com/p/dart/issues/detail?id=3307
+ */
+ public void test_builtInIdentifier_asTypeAnnotation() throws Exception {
+ AnalyzeLibraryResult libraryResult = analyzeLibrary(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "main() {",
+ " abstract v01;",
+ " assert v02;",
+ " call v03;",
+ " Dynamic v04;",
+ " equals v05;",
+ " factory v06;",
+ " get v07;",
+ " implements v08;",
+ "// interface v09;",
+ " negate v10;",
+ " operator v11;",
+ " set v12;",
+ " static v13;",
+ "// typedef v14;",
+ "}",
+ "");
+ assertErrors(
+ libraryResult.getErrors(),
+ errEx(ResolverErrorCode.BUILT_IN_IDENTIFIER_AS_TYPE, 3, 3, 8),
+ errEx(ResolverErrorCode.BUILT_IN_IDENTIFIER_AS_TYPE, 4, 3, 6),
+ errEx(ResolverErrorCode.BUILT_IN_IDENTIFIER_AS_TYPE, 5, 3, 4),
+ errEx(ResolverErrorCode.BUILT_IN_IDENTIFIER_AS_TYPE, 7, 3, 6),
+ errEx(ResolverErrorCode.BUILT_IN_IDENTIFIER_AS_TYPE, 8, 3, 7),
+ errEx(ResolverErrorCode.BUILT_IN_IDENTIFIER_AS_TYPE, 9, 3, 3),
+ errEx(ResolverErrorCode.BUILT_IN_IDENTIFIER_AS_TYPE, 10, 3, 10),
+// errEx(ResolverErrorCode.BUILT_IN_IDENTIFIER_AS_TYPE, 11, 3, 8),
+ errEx(ResolverErrorCode.BUILT_IN_IDENTIFIER_AS_TYPE, 12, 3, 6),
+ errEx(ResolverErrorCode.BUILT_IN_IDENTIFIER_AS_TYPE, 13, 3, 8),
+ errEx(ResolverErrorCode.BUILT_IN_IDENTIFIER_AS_TYPE, 14, 3, 3),
+ errEx(ResolverErrorCode.BUILT_IN_IDENTIFIER_AS_TYPE, 15, 3, 6)
+// ,errEx(ResolverErrorCode.BUILT_IN_IDENTIFIER_AS_TYPE, 16, 3, 7)
+ );
+ }
public void test_supertypeHasField() throws Exception {
AnalyzeLibraryResult libraryResult = analyzeLibrary(
« no previous file with comments | « compiler/java/com/google/dart/compiler/resolver/ResolverErrorCode.java ('k') | tests/co19/co19-compiler.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698