| OLD | NEW |
| 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 library analyzer.src.generated.type_system; | 5 library analyzer.src.generated.type_system; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 import 'dart:math' as math; | 8 import 'dart:math' as math; |
| 9 | 9 |
| 10 import 'package:analyzer/dart/ast/ast.dart' show AstNode; | 10 import 'package:analyzer/dart/ast/ast.dart' show AstNode; |
| (...skipping 1577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1588 // | 1588 // |
| 1589 // We need to track in `inferGenericFunctionCall` whether we are going up | 1589 // We need to track in `inferGenericFunctionCall` whether we are going up |
| 1590 // or down. This would also allow for an improved heuristic: if we are | 1590 // or down. This would also allow for an improved heuristic: if we are |
| 1591 // doing our final inference, the downward context can take priority. | 1591 // doing our final inference, the downward context can take priority. |
| 1592 if (lowerBound is FutureUnionType) { | 1592 if (lowerBound is FutureUnionType) { |
| 1593 // lowerBound <: T, where lowerBound is Future<A> | A. | 1593 // lowerBound <: T, where lowerBound is Future<A> | A. |
| 1594 // So we choose lowerBound as LUB(A, Future<A>). | 1594 // So we choose lowerBound as LUB(A, Future<A>). |
| 1595 // | 1595 // |
| 1596 // This will typically lead to top with the current rules, but it will | 1596 // This will typically lead to top with the current rules, but it will |
| 1597 // work with `bottom` or if we remove Future flattening. | 1597 // work with `bottom` or if we remove Future flattening. |
| 1598 var f = upperBound as FutureUnionType; | 1598 var f = lowerBound as FutureUnionType; |
| 1599 lowerBound = _typeSystem.getLeastUpperBound( | 1599 lowerBound = _typeSystem.getLeastUpperBound( |
| 1600 _typeProvider, f.futureOfType, f.type); | 1600 _typeProvider, f.futureOfType, f.type); |
| 1601 } | 1601 } |
| 1602 if (upperBound is FutureUnionType) { | 1602 if (upperBound is FutureUnionType) { |
| 1603 // T <: upperBound, where upperBound is Future<A> | A. | 1603 // T <: upperBound, where upperBound is Future<A> | A. |
| 1604 // Therefore we need T <: Future<A> or T <: A. | 1604 // Therefore we need T <: Future<A> or T <: A. |
| 1605 // | 1605 // |
| 1606 // This is just an arbitrarily heuristic. | 1606 // This is just an arbitrarily heuristic. |
| 1607 var f = upperBound as FutureUnionType; | 1607 var f = upperBound as FutureUnionType; |
| 1608 if (_typeSystem.isSubtypeOf(lowerBound, f.type)) { | 1608 if (_typeSystem.isSubtypeOf(lowerBound, f.type)) { |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1792 } else { | 1792 } else { |
| 1793 passedOut = true; | 1793 passedOut = true; |
| 1794 } | 1794 } |
| 1795 } else if (type is FunctionType) { | 1795 } else if (type is FunctionType) { |
| 1796 _visitFunctionType(typeParam, type, paramIn); | 1796 _visitFunctionType(typeParam, type, paramIn); |
| 1797 } else if (type is InterfaceType) { | 1797 } else if (type is InterfaceType) { |
| 1798 _visitInterfaceType(typeParam, type, paramIn); | 1798 _visitInterfaceType(typeParam, type, paramIn); |
| 1799 } | 1799 } |
| 1800 } | 1800 } |
| 1801 } | 1801 } |
| OLD | NEW |