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

Unified Diff: pkg/front_end/lib/src/fasta/type_inference/type_constraint_gatherer.dart

Issue 2946273002: Implement override-based type inference for instance methods. (Closed)
Patch Set: Created 3 years, 6 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
Index: pkg/front_end/lib/src/fasta/type_inference/type_constraint_gatherer.dart
diff --git a/pkg/front_end/lib/src/fasta/type_inference/type_constraint_gatherer.dart b/pkg/front_end/lib/src/fasta/type_inference/type_constraint_gatherer.dart
index 3a53f12e4065488451f5374100fcea946fabdd7c..d278b100908f52a5ecf67cfb074effcea955443a 100644
--- a/pkg/front_end/lib/src/fasta/type_inference/type_constraint_gatherer.dart
+++ b/pkg/front_end/lib/src/fasta/type_inference/type_constraint_gatherer.dart
@@ -92,28 +92,16 @@ class TypeConstraintGatherer {
supertype.typeParameters.isNotEmpty) {
var subtypeSubstitution = <TypeParameter, DartType>{};
var supertypeSubstitution = <TypeParameter, DartType>{};
+ var freshTypeVariables = <TypeParameter>[];
if (!_matchTypeFormals(subtype.typeParameters, supertype.typeParameters,
- subtypeSubstitution, supertypeSubstitution)) {
+ subtypeSubstitution, supertypeSubstitution, freshTypeVariables)) {
return false;
}
- // TODO(paulberry): try to push this functionality into kernel.
- FunctionType substituteTypeParams(
- FunctionType type, Map<TypeParameter, DartType> substitutionMap) {
- var substitution = Substitution.fromMap(substitutionMap);
- return new FunctionType(
- type.positionalParameters.map(substitution.substituteType).toList(),
- substitution.substituteType(type.returnType),
- namedParameters: type.namedParameters
- .map((named) => new NamedType(
- named.name, substitution.substituteType(named.type)))
- .toList(),
- typeParameters: substitutionMap.keys.toList(),
- requiredParameterCount: type.requiredParameterCount);
- }
-
- subtype = substituteTypeParams(subtype, subtypeSubstitution);
- supertype = substituteTypeParams(supertype, supertypeSubstitution);
+ subtype = substituteTypeParams(
+ subtype, subtypeSubstitution, freshTypeVariables);
+ supertype = substituteTypeParams(
+ supertype, supertypeSubstitution, freshTypeVariables);
}
// Test the return types.
@@ -343,7 +331,8 @@ class TypeConstraintGatherer {
List<TypeParameter> params1,
List<TypeParameter> params2,
Map<TypeParameter, DartType> substitution1,
- Map<TypeParameter, DartType> substitution2) {
+ Map<TypeParameter, DartType> substitution2,
+ List<TypeParameter> freshTypeVariables) {
int count = params1.length;
if (count != params2.length) return false;
// TODO(paulberry): in imitation of analyzer, we're checking the bounds as
@@ -352,6 +341,7 @@ class TypeConstraintGatherer {
// bounds. See dartbug.com/29629.
for (int i = 0; i < count; i++) {
TypeParameter pFresh = new TypeParameter(params2[i].name);
+ freshTypeVariables.add(pFresh);
DartType variableFresh = new TypeParameterType(pFresh);
substitution1[params1[i]] = variableFresh;
substitution2[params2[i]] = variableFresh;

Powered by Google App Engine
This is Rietveld 408576698