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

Side by Side Diff: pkg/analyzer/test/generated/resolver_test.dart

Issue 1049303002: Issue 19929. Record the propagated type into LHS of the assignment. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/analyzer/lib/src/generated/static_type_analyzer.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library engine.resolver_test; 5 library engine.resolver_test;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 8
9 import 'package:analyzer/src/generated/ast.dart'; 9 import 'package:analyzer/src/generated/ast.dart';
10 import 'package:analyzer/src/generated/element.dart'; 10 import 'package:analyzer/src/generated/element.dart';
(...skipping 12742 matching lines...) Expand 10 before | Expand all | Expand 10 after
12753 SimpleIdentifier identifier = statement.expression as SimpleIdentifier; 12753 SimpleIdentifier identifier = statement.expression as SimpleIdentifier;
12754 InterfaceType propagatedType = identifier.propagatedType as InterfaceType; 12754 InterfaceType propagatedType = identifier.propagatedType as InterfaceType;
12755 expect(propagatedType.element, same(typeProvider.mapType.element)); 12755 expect(propagatedType.element, same(typeProvider.mapType.element));
12756 List<DartType> typeArguments = propagatedType.typeArguments; 12756 List<DartType> typeArguments = propagatedType.typeArguments;
12757 expect(typeArguments, hasLength(2)); 12757 expect(typeArguments, hasLength(2));
12758 expect(typeArguments[0], same(typeProvider.dynamicType)); 12758 expect(typeArguments[0], same(typeProvider.dynamicType));
12759 expect(typeArguments[1], same(typeProvider.dynamicType)); 12759 expect(typeArguments[1], same(typeProvider.dynamicType));
12760 } 12760 }
12761 12761
12762 void test_mergePropagatedTypes_afterIfThen_different() { 12762 void test_mergePropagatedTypes_afterIfThen_different() {
12763 _assertTypeOfMarkedExpression(r''' 12763 String code = r'''
12764 main() { 12764 main() {
12765 var v = 0; 12765 var v = 0;
12766 if (v != null) { 12766 if (v != null) {
12767 v = ''; 12767 v = '';
12768 } 12768 }
12769 return v; // marker 12769 return v;
12770 }''', null, null); 12770 }''';
12771 {
12772 SimpleIdentifier identifier = _findMarkedIdentifier(code, "v;");
12773 expect(identifier.propagatedType, null);
12774 }
12775 {
12776 SimpleIdentifier identifier = _findMarkedIdentifier(code, "v = '';");
12777 expect(identifier.propagatedType, typeProvider.stringType);
12778 }
12771 } 12779 }
12772 12780
12773 void test_mergePropagatedTypes_afterIfThen_same() { 12781 void test_mergePropagatedTypes_afterIfThen_same() {
12774 _assertTypeOfMarkedExpression(r''' 12782 _assertTypeOfMarkedExpression(r'''
12775 main() { 12783 main() {
12776 var v = 1; 12784 var v = 1;
12777 if (v != null) { 12785 if (v != null) {
12778 v = 2; 12786 v = 2;
12779 } 12787 }
12780 return v; // marker 12788 return v; // marker
(...skipping 963 matching lines...) Expand 10 before | Expand all | Expand 10 after
13744 // check propagated type 13752 // check propagated type
13745 FunctionType propagatedType = node.propagatedType as FunctionType; 13753 FunctionType propagatedType = node.propagatedType as FunctionType;
13746 expect(propagatedType.returnType, test.typeProvider.stringType); 13754 expect(propagatedType.returnType, test.typeProvider.stringType);
13747 } on AnalysisException catch (e, stackTrace) { 13755 } on AnalysisException catch (e, stackTrace) {
13748 thrownException[0] = new CaughtException(e, stackTrace); 13756 thrownException[0] = new CaughtException(e, stackTrace);
13749 } 13757 }
13750 } 13758 }
13751 return null; 13759 return null;
13752 } 13760 }
13753 } 13761 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/static_type_analyzer.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698