| 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 787 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 798 | 798 |
| 799 /** | 799 /** |
| 800 * This currently does not implement a very complete least upper bound | 800 * This currently does not implement a very complete least upper bound |
| 801 * algorithm, but handles a couple of the very common cases that are | 801 * algorithm, but handles a couple of the very common cases that are |
| 802 * causing pain in real code. The current algorithm is: | 802 * causing pain in real code. The current algorithm is: |
| 803 * 1. If either of the types is a supertype of the other, return it. | 803 * 1. If either of the types is a supertype of the other, return it. |
| 804 * This is in fact the best result in this case. | 804 * This is in fact the best result in this case. |
| 805 * 2. If the two types have the same class element, then take the | 805 * 2. If the two types have the same class element, then take the |
| 806 * pointwise least upper bound of the type arguments. This is again | 806 * pointwise least upper bound of the type arguments. This is again |
| 807 * the best result, except that the recursive calls may not return | 807 * the best result, except that the recursive calls may not return |
| 808 * the true least uppper bounds. The result is guaranteed to be a | 808 * the true least upper bounds. The result is guaranteed to be a |
| 809 * well-formed type under the assumption that the input types were | 809 * well-formed type under the assumption that the input types were |
| 810 * well-formed (and assuming that the recursive calls return | 810 * well-formed (and assuming that the recursive calls return |
| 811 * well-formed types). | 811 * well-formed types). |
| 812 * 3. Otherwise return the spec-defined least upper bound. This will | 812 * 3. Otherwise return the spec-defined least upper bound. This will |
| 813 * be an upper bound, might (or might not) be least, and might | 813 * be an upper bound, might (or might not) be least, and might |
| 814 * (or might not) be a well-formed type. | 814 * (or might not) be a well-formed type. |
| 815 * | 815 * |
| 816 * TODO(leafp): Use matchTypes or something similar here to handle the | 816 * TODO(leafp): Use matchTypes or something similar here to handle the |
| 817 * case where one of the types is a superclass (but not supertype) of | 817 * case where one of the types is a superclass (but not supertype) of |
| 818 * the other, e.g. LUB(Iterable<double>, List<int>) = Iterable<num> | 818 * the other, e.g. LUB(Iterable<double>, List<int>) = Iterable<num> |
| (...skipping 1549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2368 if (type is InterfaceTypeImpl) { | 2368 if (type is InterfaceTypeImpl) { |
| 2369 return type.typeArguments.any(isUnknown); | 2369 return type.typeArguments.any(isUnknown); |
| 2370 } | 2370 } |
| 2371 if (type is FunctionType) { | 2371 if (type is FunctionType) { |
| 2372 return isUnknown(type.returnType) || | 2372 return isUnknown(type.returnType) || |
| 2373 type.parameters.any((p) => isUnknown(p.type)); | 2373 type.parameters.any((p) => isUnknown(p.type)); |
| 2374 } | 2374 } |
| 2375 return false; | 2375 return false; |
| 2376 } | 2376 } |
| 2377 } | 2377 } |
| OLD | NEW |