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

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

Issue 11140011: Infer function expression parameter types what it is assigned to element with known type (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 2 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
« no previous file with comments | « compiler/java/com/google/dart/compiler/type/TypeAnalyzer.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 961a981ee6f01a012049a91c7c0f631021526936..3bfd3fad45c32974828bc440a821ed8c69ed5e90 100644
--- a/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java
+++ b/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java
@@ -3074,7 +3074,65 @@ public class TypeAnalyzerCompilerTest extends CompilerTestCase {
"");
assertInferredElementTypeString(testUnit, "v", "Event");
}
-
+
+ public void test_typesPropagation_parameterOfClosure_assignVariable() throws Exception {
+ analyzeLibrary(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "class Event {}",
+ "typedef void EventListener(Event event);",
+ "main() {",
+ " // local variable assign",
+ " {",
+ " EventListener listener;",
+ " listener = (e) {",
+ " var v1 = e;",
+ " };",
+ " }",
+ " // local variable declare",
+ " {",
+ " EventListener listener = (e) {",
+ " var v2 = e;",
+ " };",
+ " }",
+ "}",
+ "");
+ assertInferredElementTypeString(testUnit, "v1", "Event");
+ assertInferredElementTypeString(testUnit, "v2", "Event");
+ }
+
+ public void test_typesPropagation_parameterOfClosure_assignField() throws Exception {
+ analyzeLibrary(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "class Event {}",
+ "typedef void EventListener(Event event);",
+ "class Button {",
+ " EventListener listener;",
+ "}",
+ "EventListener topLevelListener;",
+ "main() {",
+ " // top-level field",
+ " {",
+ " topLevelListener = (e) {",
+ " var v1 = e;",
+ " };",
+ " }",
+ " // member field",
+ " {",
+ " Button button = new Button();",
+ " button.listener = (e) {",
+ " var v2 = e;",
+ " };",
+ " }",
+ "}",
+ "EventListener topLevelListener2 = (e) {",
+ " var v3 = e;",
+ "};",
+ "");
+ assertInferredElementTypeString(testUnit, "v1", "Event");
+ assertInferredElementTypeString(testUnit, "v2", "Event");
+ assertInferredElementTypeString(testUnit, "v3", "Event");
+ }
+
/**
* Helpful (but not perfectly satisfying Specification) type of "conditional" is intersection of
* then/else types, not just their "least upper bounds". And this corresponds runtime behavior.
« no previous file with comments | « compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698