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

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

Issue 1509263002: Generic method subtyping. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years 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 | pkg/analyzer/lib/src/generated/type_system.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/generated/element.dart
diff --git a/pkg/analyzer/lib/src/generated/element.dart b/pkg/analyzer/lib/src/generated/element.dart
index 56c1f2563c76002a30a51ac90b429373e24944f6..4bdfea054d549f201673cc1f320230ea08798aa3 100644
--- a/pkg/analyzer/lib/src/generated/element.dart
+++ b/pkg/analyzer/lib/src/generated/element.dart
@@ -5076,9 +5076,22 @@ class FunctionTypeImpl extends TypeImpl implements FunctionType {
// variables, and see if the result is equal.
if (boundTypeParameters.isNotEmpty) {
List<DartType> instantiateTypeArgs = new List<DartType>();
- for (TypeParameterElement e in boundTypeParameters) {
- instantiateTypeArgs.add(new TypeParameterTypeImpl(
- new TypeParameterElementImpl(e.name, -1)));
+ List<DartType> variablesThis = new List<DartType>();
+ List<DartType> variablesOther = new List<DartType>();
+ for (int i = 0; i < boundTypeParameters.length; i++) {
+ TypeParameterElement pThis = boundTypeParameters[i];
+ TypeParameterElement pOther = otherType.boundTypeParameters[i];
+ TypeParameterTypeImpl pFresh = new TypeParameterTypeImpl(
+ new TypeParameterElementImpl(pThis.name, -1));
+ instantiateTypeArgs.add(pFresh);
+ variablesThis.add(pThis.type);
+ variablesOther.add(pOther.type);
+ // Check that the bounds are equal after equating the previous
+ // bound variables.
+ if (pThis.bound?.substitute2(instantiateTypeArgs, variablesThis) !=
+ pOther.bound?.substitute2(instantiateTypeArgs, variablesOther)) {
+ return false;
+ }
}
// After instantiation, they will no longer have boundTypeParameters,
// so we will continue below.
@@ -5110,6 +5123,7 @@ class FunctionTypeImpl extends TypeImpl implements FunctionType {
}
List<DartType> instantiateTypeArgs = new List<DartType>();
+ List<DartType> variables = new List<DartType>();
buffer.write("<");
for (TypeParameterElement e in boundTypeParameters) {
if (e != boundTypeParameters[0]) {
@@ -5130,6 +5144,13 @@ class FunctionTypeImpl extends TypeImpl implements FunctionType {
new TypeParameterTypeImpl(new TypeParameterElementImpl(name, -1));
t.appendTo(buffer);
instantiateTypeArgs.add(t);
+ variables.add(e.type);
+ if (e.bound != null) {
+ buffer.write(" extends ");
+ TypeImpl renamed =
+ e.bound.substitute2(instantiateTypeArgs, variables);
+ renamed.appendTo(buffer);
+ }
}
buffer.write(">");
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/generated/type_system.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698