| Index: pkg/kernel/lib/transformations/closure/info.dart
|
| diff --git a/pkg/kernel/lib/transformations/closure/info.dart b/pkg/kernel/lib/transformations/closure/info.dart
|
| index 68b82c1dc5e51e0c5fd4393e813aafc780f3a49d..e2eda7861664f2e0b7f353c97efc1647ea081bea 100644
|
| --- a/pkg/kernel/lib/transformations/closure/info.dart
|
| +++ b/pkg/kernel/lib/transformations/closure/info.dart
|
| @@ -30,6 +30,7 @@ class ClosureInfo extends RecursiveVisitor {
|
|
|
| final Set<VariableDeclaration> variables = new Set<VariableDeclaration>();
|
|
|
| + /// Map from functions to set of type variables captured within them.
|
| final Map<FunctionNode, Set<TypeParameter>> typeVariables =
|
| <FunctionNode, Set<TypeParameter>>{};
|
|
|
| @@ -166,7 +167,10 @@ class ClosureInfo extends RecursiveVisitor {
|
| // Propagate captured type variables to enclosing function.
|
| typeVariables
|
| .putIfAbsent(currentFunction, () => new Set<TypeParameter>())
|
| - .addAll(capturedTypeVariables);
|
| + .addAll(
|
| + // [t.parent == currentFunction] will be true if the type variable
|
| + // is defined by one of our type parameters.
|
| + capturedTypeVariables.where((t) => t.parent != currentFunction));
|
| }
|
| }
|
|
|
| @@ -190,7 +194,7 @@ class ClosureInfo extends RecursiveVisitor {
|
| }
|
|
|
| visitTypeParameterType(TypeParameterType node) {
|
| - if (!isOuterMostContext) {
|
| + if (!isOuterMostContext && node.parameter.parent != currentFunction) {
|
| typeVariables
|
| .putIfAbsent(currentFunction, () => new Set<TypeParameter>())
|
| .add(node.parameter);
|
|
|