| Index: pkg/analyzer/lib/src/generated/type_system.dart
|
| diff --git a/pkg/analyzer/lib/src/generated/type_system.dart b/pkg/analyzer/lib/src/generated/type_system.dart
|
| index 911dfa9f81e072ddd26c99fbd157abb18979fa3a..5eb00ee385d3c67024d4c5f5bd9afdc82ecf54d9 100644
|
| --- a/pkg/analyzer/lib/src/generated/type_system.dart
|
| +++ b/pkg/analyzer/lib/src/generated/type_system.dart
|
| @@ -29,6 +29,9 @@ class StrongTypeSystemImpl implements TypeSystem {
|
| return ft.parameters.any((p) => predicate(p.type));
|
| }
|
|
|
| + @override
|
| + bool canPromoteToType(DartType to, DartType from) => isSubtypeOf(to, from);
|
| +
|
| /**
|
| * Given a type t, if t is an interface type with a call method
|
| * defined, return the function type for the call method, otherwise
|
| @@ -563,6 +566,16 @@ class StrongTypeSystemImpl implements TypeSystem {
|
| */
|
| abstract class TypeSystem {
|
| /**
|
| + * Returns `true` if we can promote to the first type from the second type.
|
| + *
|
| + * In the standard Dart type system, it is not possible to promote from or to
|
| + * `dynamic`, and we must be promoting to a more specific type.
|
| + *
|
| + * In strong mode, this is equivalent to [isSubtypeOf].
|
| + */
|
| + bool canPromoteToType(DartType to, DartType from);
|
| +
|
| + /**
|
| * Compute the least upper bound of two types.
|
| */
|
| DartType getLeastUpperBound(
|
| @@ -606,6 +619,14 @@ class TypeSystemImpl implements TypeSystem {
|
| TypeSystemImpl();
|
|
|
| @override
|
| + bool canPromoteToType(DartType to, DartType from) {
|
| + // Declared type should not be "dynamic".
|
| + // Promoted type should not be "dynamic".
|
| + // Promoted type should be more specific than declared.
|
| + return !from.isDynamic && !to.isDynamic && to.isMoreSpecificThan(from);
|
| + }
|
| +
|
| + @override
|
| DartType getLeastUpperBound(
|
| TypeProvider typeProvider, DartType type1, DartType type2) {
|
| // The least upper bound relation is reflexive.
|
|
|