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 b19ae14f90edc13ed08740c472c8980f39d4def1..6e61466a223756ea6523840552453872838023f6 100644 |
--- a/pkg/analyzer/lib/src/generated/type_system.dart |
+++ b/pkg/analyzer/lib/src/generated/type_system.dart |
@@ -673,18 +673,30 @@ class StrongTypeSystemImpl extends TypeSystem { |
provider.dynamicType; |
} |
- /** |
- * Check that [f1] is a subtype of [f2]. |
- * |
- * This will always assume function types use fuzzy arrows, in other words |
- * that dynamic parameters of f1 and f2 are treated as bottom. |
- */ |
+ /// Check that [f1] is a subtype of [f2]. |
+ /// |
+ /// This will always assume function types use fuzzy arrows, in other words |
+ /// that dynamic parameters of f1 and f2 are treated as bottom. |
bool _isFunctionSubtypeOf(FunctionType f1, FunctionType f2) { |
return FunctionTypeImpl.relate( |
f1, |
f2, |
- (DartType t1, DartType t2) => |
- _isSubtypeOf(t2, t1, null, dynamicIsBottom: true), |
+ (t1, t2, _, __) => _isSubtypeOf(t2, t1, null, dynamicIsBottom: true), |
+ instantiateToBounds, |
+ returnRelation: isSubtypeOf); |
+ } |
+ |
+ /// Check that [f1] is a subtype of [f2] for an override. |
+ /// |
+ /// This is different from the normal function subtyping in two ways: |
+ /// - we know the function types are strict arrows, |
+ /// - it allows opt-in covariant parameters. |
+ bool isOverrideSubtypeOf(FunctionType f1, FunctionType f2) { |
+ return FunctionTypeImpl.relate( |
+ f1, |
+ f2, |
+ (t1, t2, t1Covariant, _) => |
+ isSubtypeOf(t2, t1) || t1Covariant && isSubtypeOf(t1, t2), |
instantiateToBounds, |
returnRelation: isSubtypeOf); |
} |