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/token.dart' show TokenType; | 10 import 'package:analyzer/dart/ast/token.dart' show TokenType; |
(...skipping 889 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
900 * we don't know what function value will be passed there. | 900 * we don't know what function value will be passed there. |
901 */ | 901 */ |
902 FunctionType functionTypeToConcreteType( | 902 FunctionType functionTypeToConcreteType( |
903 TypeProvider typeProvider, FunctionType t); | 903 TypeProvider typeProvider, FunctionType t); |
904 | 904 |
905 /** | 905 /** |
906 * Compute the least upper bound of two types. | 906 * Compute the least upper bound of two types. |
907 */ | 907 */ |
908 DartType getLeastUpperBound( | 908 DartType getLeastUpperBound( |
909 TypeProvider typeProvider, DartType type1, DartType type2, | 909 TypeProvider typeProvider, DartType type1, DartType type2, |
910 {dynamicIsBottom: false}) { | 910 {bool dynamicIsBottom: false}) { |
911 // The least upper bound relation is reflexive. | 911 // The least upper bound relation is reflexive. |
912 if (identical(type1, type2)) { | 912 if (identical(type1, type2)) { |
913 return type1; | 913 return type1; |
914 } | 914 } |
915 // The least upper bound of top and any type T is top. | 915 // The least upper bound of top and any type T is top. |
916 // The least upper bound of bottom and any type T is T. | 916 // The least upper bound of bottom and any type T is T. |
917 if (_isTop(type1, dynamicIsBottom: dynamicIsBottom) || | 917 if (_isTop(type1, dynamicIsBottom: dynamicIsBottom) || |
918 _isBottom(type2, dynamicIsBottom: dynamicIsBottom)) { | 918 _isBottom(type2, dynamicIsBottom: dynamicIsBottom)) { |
919 return type1; | 919 return type1; |
920 } | 920 } |
(...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1548 } | 1548 } |
1549 | 1549 |
1550 bool _isBottom(DartType t, {bool dynamicIsBottom: false}) { | 1550 bool _isBottom(DartType t, {bool dynamicIsBottom: false}) { |
1551 return (t.isDynamic && dynamicIsBottom) || t.isBottom; | 1551 return (t.isDynamic && dynamicIsBottom) || t.isBottom; |
1552 } | 1552 } |
1553 | 1553 |
1554 bool _isTop(DartType t, {bool dynamicIsBottom: false}) { | 1554 bool _isTop(DartType t, {bool dynamicIsBottom: false}) { |
1555 // TODO(leafp): Document the rules in play here | 1555 // TODO(leafp): Document the rules in play here |
1556 return (t.isDynamic && !dynamicIsBottom) || t.isObject; | 1556 return (t.isDynamic && !dynamicIsBottom) || t.isObject; |
1557 } | 1557 } |
OLD | NEW |