| Index: pkg/kernel/lib/transformations/erasure.dart
|
| diff --git a/pkg/kernel/lib/transformations/erasure.dart b/pkg/kernel/lib/transformations/erasure.dart
|
| index c2f572d2c7855188f5a5b059b87eb064ba933a1e..ee3695857cc54ed5a0ed0e3bf19b562b7fe4dbdd 100644
|
| --- a/pkg/kernel/lib/transformations/erasure.dart
|
| +++ b/pkg/kernel/lib/transformations/erasure.dart
|
| @@ -51,6 +51,31 @@ class Erasure extends Transformer {
|
|
|
| @override
|
| visitDartType(DartType type) {
|
| + if (type is FunctionType && type.typeParameters.isNotEmpty) {
|
| + FunctionType function = type;
|
| + for (var parameter in function.typeParameters) {
|
| + // Note, normally, we would have to remove these substitutions again to
|
| + // avoid memory leaks. Unfortunately, that that's not compatible with
|
| + // how function types share their TypeParameter object with a
|
| + // FunctionNode.
|
| + substitution[parameter] = const DynamicType();
|
| + }
|
| + for (var parameter in function.typeParameters) {
|
| + if (!isObject(parameter.bound)) {
|
| + substitution[parameter] = substitute(parameter.bound, substitution);
|
| + }
|
| + }
|
| + // We need to delete the type parameters of the function type before
|
| + // calling [substitute], otherwise it creates a new environment with
|
| + // fresh type variables that shadow the ones we want to remove. Since a
|
| + // FunctionType is often assumed to be immutable, we return a copy.
|
| + type = new FunctionType(
|
| + function.positionalParameters, function.returnType,
|
| + namedParameters: function.namedParameters,
|
| + requiredParameterCount: function.requiredParameterCount,
|
| + positionalParameterNames: function.positionalParameterNames,
|
| + typedefReference: function.typedefReference);
|
| + }
|
| type = substitute(type, substitution);
|
| if (isInConstantContext) {
|
| type = substitute(type, constantSubstitution);
|
|
|