Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE.md file. | 3 // BSD-style license that can be found in the LICENSE.md file. |
| 4 | 4 |
| 5 import 'dart:math' as math; | 5 import 'dart:math' as math; |
| 6 | 6 |
| 7 import 'package:front_end/src/fasta/type_inference/type_constraint_gatherer.dart '; | 7 import 'package:front_end/src/fasta/type_inference/type_constraint_gatherer.dart '; |
| 8 import 'package:front_end/src/fasta/type_inference/type_schema.dart'; | 8 import 'package:front_end/src/fasta/type_inference/type_schema.dart'; |
| 9 import 'package:front_end/src/fasta/type_inference/type_schema_elimination.dart' ; | 9 import 'package:front_end/src/fasta/type_inference/type_schema_elimination.dart' ; |
| 10 import 'package:kernel/ast.dart'; | 10 import 'package:kernel/ast.dart'; |
| 11 import 'package:kernel/class_hierarchy.dart'; | 11 import 'package:kernel/class_hierarchy.dart'; |
| 12 import 'package:kernel/core_types.dart'; | 12 import 'package:kernel/core_types.dart'; |
| 13 import 'package:kernel/type_algebra.dart'; | 13 import 'package:kernel/type_algebra.dart'; |
| 14 import 'package:kernel/type_environment.dart'; | 14 import 'package:kernel/type_environment.dart'; |
| 15 | 15 |
| 16 // TODO(paulberry): try to push this functionality into kernel. | |
| 17 FunctionType substituteTypeParams( | |
| 18 FunctionType type, | |
| 19 Map<TypeParameter, DartType> substitutionMap, | |
| 20 List<TypeParameter> newTypeParameters) { | |
| 21 var substitution = Substitution.fromMap(substitutionMap); | |
| 22 return new FunctionType( | |
| 23 type.positionalParameters.map(substitution.substituteType).toList(), | |
| 24 substitution.substituteType(type.returnType), | |
| 25 namedParameters: type.namedParameters | |
| 26 .map((named) => new NamedType( | |
| 27 named.name, substitution.substituteType(named.type))) | |
| 28 .toList(), | |
| 29 typeParameters: newTypeParameters, | |
|
Siggi Cherem (dart-lang)
2017/06/21 20:19:08
Just making sure I follow the change here. Before
Paul Berry
2017/06/21 20:54:47
That's right. It was a bug which happened to be b
| |
| 30 requiredParameterCount: type.requiredParameterCount); | |
| 31 } | |
| 32 | |
| 16 /// A constraint on a type parameter that we're inferring. | 33 /// A constraint on a type parameter that we're inferring. |
| 17 class TypeConstraint { | 34 class TypeConstraint { |
| 18 /// The lower bound of the type being constrained. This bound must be a | 35 /// The lower bound of the type being constrained. This bound must be a |
| 19 /// subtype of the type being constrained. | 36 /// subtype of the type being constrained. |
| 20 DartType lower; | 37 DartType lower; |
| 21 | 38 |
| 22 /// The upper bound of the type being constrained. The type being constrained | 39 /// The upper bound of the type being constrained. The type being constrained |
| 23 /// must be a subtype of this bound. | 40 /// must be a subtype of this bound. |
| 24 DartType upper; | 41 DartType upper; |
| 25 | 42 |
| (...skipping 741 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 767 Substitution.fromMap({type2.parameter: objectType}).substituteType( | 784 Substitution.fromMap({type2.parameter: objectType}).substituteType( |
| 768 type2.parameter.bound)); | 785 type2.parameter.bound)); |
| 769 } else { | 786 } else { |
| 770 // We should only be called when at least one of the types is a | 787 // We should only be called when at least one of the types is a |
| 771 // TypeParameterType | 788 // TypeParameterType |
| 772 assert(false); | 789 assert(false); |
| 773 return const DynamicType(); | 790 return const DynamicType(); |
| 774 } | 791 } |
| 775 } | 792 } |
| 776 } | 793 } |
| OLD | NEW |