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

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

Issue 11442061: Issue 7271. If class has method call() with type F, class should be considered as subtype of functi… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years 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
« no previous file with comments | « compiler/java/com/google/dart/compiler/type/Types.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 9f8cd3cafe9d8b246f2194e6d480d16bc39a0e4c..a59223fb126cbfa890b63aee1ab5de748a5634d2 100644
--- a/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java
+++ b/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java
@@ -158,6 +158,44 @@ public class TypeAnalyzerCompilerTest extends CompilerTestCase {
}
/**
+ * If a type I includes a method named call(), and the type of call() is the function type F, then
+ * I is considered to be a subtype of F.
+ * <p>
+ * http://code.google.com/p/dart/issues/detail?id=7271
+ */
+ public void test_classWithCallMethod_isFunction() throws Exception {
+ AnalyzeLibraryResult libraryResult = analyzeLibrary(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "class X {",
+ " call() => 42;",
+ "}",
+ "",
+ "class Y {",
+ " call(int x) => 87;",
+ "}",
+ "",
+ "typedef F(int x);",
+ "typedef G(String y);",
+ "",
+ "main() {",
+ " X x = new X();",
+ " Y y = new Y();",
+ " Function f = x;", // OK
+ " Function g = y;", // OK
+ " F f0 = x;", // WARN
+ " F f1 = y;", // OK
+ " G g0 = x;", // WARN
+ " G g1 = y;", // WARN
+ "}",
+ "");
+ assertErrors(
+ libraryResult.getErrors(),
+ errEx(TypeErrorCode.TYPE_NOT_ASSIGNMENT_COMPATIBLE, 18, 10, 1),
+ errEx(TypeErrorCode.TYPE_NOT_ASSIGNMENT_COMPATIBLE, 20, 10, 1),
+ errEx(TypeErrorCode.TYPE_NOT_ASSIGNMENT_COMPATIBLE, 21, 10, 1));
+ }
+
+ /**
* It is a compile-time error if a typedef refers to itself via a chain of references that does
* not include a class or interface type.
* <p>
« no previous file with comments | « compiler/java/com/google/dart/compiler/type/Types.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698