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

Unified Diff: pkg/compiler/lib/src/dart_types.dart

Issue 2307873002: Fix more-specific for interface types with call functions. (Closed)
Patch Set: 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 | « no previous file | tests/compiler/dart2js/subtype_test.dart » ('j') | tests/compiler/dart2js/subtype_test.dart » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/dart_types.dart
diff --git a/pkg/compiler/lib/src/dart_types.dart b/pkg/compiler/lib/src/dart_types.dart
index 271d09f6f98a94f61a63e03bd921188156701bbd..4482d34a4e2149ccd82bf39b9c8869d639aafaaa 100644
--- a/pkg/compiler/lib/src/dart_types.dart
+++ b/pkg/compiler/lib/src/dart_types.dart
@@ -1027,6 +1027,8 @@ abstract class AbstractTypeRelation
bool invalidTypeVariableBounds(DartType bound, DartType s);
+ bool invalidCallableType(DartType callType, DartType s);
+
/// Handle as dynamic for both subtype and more specific relation to avoid
/// spurious errors from malformed types.
bool visitMalformedType(MalformedType t, DartType s) => true;
@@ -1050,10 +1052,19 @@ abstract class AbstractTypeRelation
if (s is InterfaceType) {
InterfaceType instance = t.asInstanceOf(s.element);
- return instance != null && checkTypeArguments(instance, s);
- } else {
- return false;
+ if (instance != null && checkTypeArguments(instance, s)) {
+ return true;
+ }
}
+
+ if (s == coreTypes.functionType && t.element.callType != null) {
+ return true;
+ } else if (s is FunctionType) {
+ FunctionType callType = t.callType;
+ return callType != null && !invalidCallableType(callType, s);
+ }
+
+ return false;
}
bool visitFunctionType(FunctionType t, DartType s) {
@@ -1223,6 +1234,10 @@ class MoreSpecificVisitor extends AbstractTypeRelation {
bool invalidTypeVariableBounds(DartType bound, DartType s) {
return !isMoreSpecific(bound, s);
}
+
+ bool invalidCallableType(DartType callType, DartType s) {
+ return !isMoreSpecific(callType, s);
+ }
}
/**
@@ -1255,16 +1270,8 @@ class SubtypeVisitor extends MoreSpecificVisitor {
return !isSubtype(bound, s);
}
- bool visitInterfaceType(InterfaceType t, DartType s) {
- if (super.visitInterfaceType(t, s)) return true;
-
- if (s == coreTypes.functionType && t.element.callType != null) {
- return true;
- } else if (s is FunctionType) {
- FunctionType callType = t.callType;
- return callType != null && isSubtype(callType, s);
- }
- return false;
+ bool invalidCallableType(DartType callType, DartType s) {
+ return !isSubtype(callType, s);
}
}
« no previous file with comments | « no previous file | tests/compiler/dart2js/subtype_test.dart » ('j') | tests/compiler/dart2js/subtype_test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698