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 1586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1597 // error spans. But ultimately it's just a heuristic, as the code is | 1597 // error spans. But ultimately it's just a heuristic, as the code is |
1598 // already erroneous. | 1598 // already erroneous. |
1599 // | 1599 // |
1600 // (we may adjust the normal heuristic too, once upwards+downwards | 1600 // (we may adjust the normal heuristic too, once upwards+downwards |
1601 // inference are fully integrated, to prefer downwards info). | 1601 // inference are fully integrated, to prefer downwards info). |
1602 lowerBound = bound.upper; | 1602 lowerBound = bound.upper; |
1603 upperBound = bound.lower; | 1603 upperBound = bound.lower; |
1604 } | 1604 } |
1605 | 1605 |
1606 inferredTypes[i] = | 1606 inferredTypes[i] = |
1607 variance.passedIn || lowerBound.isBottom ? upperBound : lowerBound; | 1607 variance.passedIn && !upperBound.isDynamic || lowerBound.isBottom |
| 1608 ? upperBound |
| 1609 : lowerBound; |
1608 } | 1610 } |
1609 | 1611 |
1610 // Return the instantiated type. | 1612 // Return the instantiated type. |
1611 return genericType.instantiate(inferredTypes) as dynamic/*=T*/; | 1613 return genericType.instantiate(inferredTypes) as dynamic/*=T*/; |
1612 } | 1614 } |
1613 | 1615 |
1614 @override | 1616 @override |
1615 bool _inferTypeParameterSubtypeOf( | 1617 bool _inferTypeParameterSubtypeOf( |
1616 DartType t1, DartType t2, Set<Element> visited) { | 1618 DartType t1, DartType t2, Set<Element> visited) { |
1617 if (t1 is TypeParameterType) { | 1619 if (t1 is TypeParameterType) { |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1751 } else { | 1753 } else { |
1752 passedOut = true; | 1754 passedOut = true; |
1753 } | 1755 } |
1754 } else if (type is FunctionType) { | 1756 } else if (type is FunctionType) { |
1755 _visitFunctionType(typeParam, type, paramIn); | 1757 _visitFunctionType(typeParam, type, paramIn); |
1756 } else if (type is InterfaceType) { | 1758 } else if (type is InterfaceType) { |
1757 _visitInterfaceType(typeParam, type, paramIn); | 1759 _visitInterfaceType(typeParam, type, paramIn); |
1758 } | 1760 } |
1759 } | 1761 } |
1760 } | 1762 } |
OLD | NEW |