Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(172)

Unified Diff: pkg/analyzer/lib/src/generated/type_system.dart

Issue 2336503003: fix #25578, implement @covariant parameter overrides (Closed)
Patch Set: fix comments, format Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer/lib/src/generated/resolver.dart ('k') | pkg/analyzer/lib/src/summary/link.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
}
« no previous file with comments | « pkg/analyzer/lib/src/generated/resolver.dart ('k') | pkg/analyzer/lib/src/summary/link.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698