Chromium Code Reviews| Index: pkg/analyzer/test/generated/resolver_test.dart |
| diff --git a/pkg/analyzer/test/generated/resolver_test.dart b/pkg/analyzer/test/generated/resolver_test.dart |
| index 9c305940ab13b5c77efe722fc726d5cee48f324c..cd692a707c48090914a8ffccf954721edfe8d45a 100644 |
| --- a/pkg/analyzer/test/generated/resolver_test.dart |
| +++ b/pkg/analyzer/test/generated/resolver_test.dart |
| @@ -8054,6 +8054,17 @@ class ResolverTestCase extends EngineTestCase { |
| } |
| /** |
| + * @param code the code that iterates using variable "v". We check that |
| + * "v" has expected static and propagated type. |
| + */ |
| + void _assertPropagatedIterationType(String code, DartType expectedStaticType, |
| + DartType expectedPropagatedType) { |
| + SimpleIdentifier identifier = _findMarkedIdentifier(code, "v in "); |
| + expect(identifier.staticType, same(expectedStaticType)); |
| + expect(identifier.propagatedType, same(expectedPropagatedType)); |
| + } |
| + |
| + /** |
| * @param code the code that assigns the value to the variable "v", no matter how. We check that |
| * "v" has expected static and propagated type. |
| */ |
| @@ -13738,6 +13749,60 @@ main() { |
| _assertTypeOfMarkedExpression( |
| code, typeProvider.dynamicType, typeProvider.intType); |
| } |
| + |
| + void test_foreachInference_var() { |
| + String code = r''' |
| +main() { |
| + var list = <int>[]; |
| + for (var v in list) { |
| + v; // marker |
| + } |
| +}'''; |
| + _assertPropagatedIterationType( |
| + code, typeProvider.intType, typeProvider.intType); |
|
Brian Wilkerson
2015/08/28 20:59:33
I might be misreading the test, but it looks like
Leaf
2015/09/01 21:21:02
I changed visitForEachStatementInScope as discusse
|
| + _assertTypeOfMarkedExpression(code, typeProvider.intType, null); |
| + } |
| + |
| + void test_foreachInference_dynamic_disabled() { |
| + String code = r''' |
| +main() { |
| + var list = <int>[]; |
| + for (dynamic v in list) { |
| + v; // marker |
| + } |
| +}'''; |
| + _assertPropagatedIterationType( |
| + code, typeProvider.dynamicType, typeProvider.intType); |
| + _assertTypeOfMarkedExpression( |
| + code, typeProvider.dynamicType, typeProvider.intType); |
| + } |
| + |
| + void test_foreachInference_reusedVar_disabled() { |
| + String code = r''' |
| +main() { |
| + var list = <int>[]; |
| + var v; |
| + for (v in list) { |
| + v; // marker |
| + } |
| +}'''; |
| + _assertPropagatedIterationType( |
| + code, typeProvider.dynamicType, typeProvider.intType); |
| + _assertTypeOfMarkedExpression( |
| + code, typeProvider.dynamicType, typeProvider.intType); |
| + } |
| + |
| + void fail_foreachInference_var_map() { |
| + String code = r''' |
| +main() { |
| + Map<int, String> map = <int, String>{}; |
| + for (var v in map) { |
| + v; // marker |
| + } |
| +}'''; |
| + _assertPropagatedIterationType(code, typeProvider.intType, null); |
| + _assertTypeOfMarkedExpression(code, typeProvider.intType, null); |
| + } |
| } |
| @reflectiveTest |