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

Side by Side Diff: pkg/analyzer/lib/src/task/strong/checker.dart

Issue 2807103003: Fix compilation errors (Closed)
Patch Set: Created 3 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
« no previous file with comments | « no previous file | 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) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 // TODO(jmesserly): this was ported from package:dev_compiler, and needs to be 5 // TODO(jmesserly): this was ported from package:dev_compiler, and needs to be
6 // refactored to fit into analyzer. 6 // refactored to fit into analyzer.
7 library analyzer.src.task.strong.checker; 7 library analyzer.src.task.strong.checker;
8 8
9 import 'package:analyzer/analyzer.dart'; 9 import 'package:analyzer/analyzer.dart';
10 import 'package:analyzer/dart/ast/ast.dart'; 10 import 'package:analyzer/dart/ast/ast.dart';
(...skipping 825 matching lines...) Expand 10 before | Expand all | Expand 10 after
836 var type = functionType.returnType; 836 var type = functionType.returnType;
837 837
838 InterfaceType expectedType = null; 838 InterfaceType expectedType = null;
839 if (body.isAsynchronous) { 839 if (body.isAsynchronous) {
840 if (body.isGenerator) { 840 if (body.isGenerator) {
841 // Stream<T> -> T 841 // Stream<T> -> T
842 expectedType = typeProvider.streamType; 842 expectedType = typeProvider.streamType;
843 } else { 843 } else {
844 // Future<T> -> FutureOr<T> 844 // Future<T> -> FutureOr<T>
845 var typeArg = (type.element == typeProvider.futureType.element) 845 var typeArg = (type.element == typeProvider.futureType.element)
846 ? type.typeArguments[0] 846 ? (type as InterfaceType).typeArguments[0]
847 : typeProvider.dynamicType; 847 : typeProvider.dynamicType;
848 return typeProvider.futureOrType.instantiate([typeArg]); 848 return typeProvider.futureOrType.instantiate([typeArg]);
849 } 849 }
850 } else { 850 } else {
851 if (body.isGenerator) { 851 if (body.isGenerator) {
852 // Iterable<T> -> T 852 // Iterable<T> -> T
853 expectedType = typeProvider.iterableType; 853 expectedType = typeProvider.iterableType;
854 } else { 854 } else {
855 // T -> T 855 // T -> T
856 return type; 856 return type;
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
923 923
924 // fromT <: toT, no coercion needed. 924 // fromT <: toT, no coercion needed.
925 if (rules.isSubtypeOf(from, to)) return false; 925 if (rules.isSubtypeOf(from, to)) return false;
926 926
927 // Down cast or legal sideways cast, coercion needed. 927 // Down cast or legal sideways cast, coercion needed.
928 if (rules.isAssignableTo(from, to)) return true; 928 if (rules.isAssignableTo(from, to)) return true;
929 929
930 // Special case for FutureOr to handle returned values from async functions. 930 // Special case for FutureOr to handle returned values from async functions.
931 // In this case, we're more permissive than assignability. 931 // In this case, we're more permissive than assignability.
932 if (to.element == typeProvider.futureOrType.element) { 932 if (to.element == typeProvider.futureOrType.element) {
933 var to1 = to.typeArguments[0]; 933 var to1 = (to as InterfaceType).typeArguments[0];
934 var to2 = typeProvider.futureType.instantiate([to1]); 934 var to2 = typeProvider.futureType.instantiate([to1]);
935 return _needsImplicitCast(expr, to1, from: from) == true || 935 return _needsImplicitCast(expr, to1, from: from) == true ||
936 _needsImplicitCast(expr, to2, from: from) == true; 936 _needsImplicitCast(expr, to2, from: from) == true;
937 } 937 }
938 938
939 // Anything else is an illegal sideways cast. 939 // Anything else is an illegal sideways cast.
940 // However, these will have been reported already in error_verifier, so we 940 // However, these will have been reported already in error_verifier, so we
941 // don't need to report them again. 941 // don't need to report them again.
942 return null; 942 return null;
943 } 943 }
(...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after
1564 var visited = new Set<InterfaceType>(); 1564 var visited = new Set<InterfaceType>();
1565 do { 1565 do {
1566 visited.add(current); 1566 visited.add(current);
1567 current.mixins.reversed.forEach( 1567 current.mixins.reversed.forEach(
1568 (m) => _checkIndividualOverridesFromClass(node, m, seen, true)); 1568 (m) => _checkIndividualOverridesFromClass(node, m, seen, true));
1569 _checkIndividualOverridesFromClass(node, current.superclass, seen, true); 1569 _checkIndividualOverridesFromClass(node, current.superclass, seen, true);
1570 current = current.superclass; 1570 current = current.superclass;
1571 } while (!current.isObject && !visited.contains(current)); 1571 } while (!current.isObject && !visited.contains(current));
1572 } 1572 }
1573 } 1573 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698