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

Unified Diff: pkg/kernel/lib/transformations/closure/info.dart

Issue 2989563002: Preserve type variables in closure conversion. (Closed)
Patch Set: Visit more children, review comments. Created 3 years, 5 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
« no previous file with comments | « pkg/kernel/lib/transformations/closure/converter.dart ('k') | pkg/kernel/test/closures/suite.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
« no previous file with comments | « pkg/kernel/lib/transformations/closure/converter.dart ('k') | pkg/kernel/test/closures/suite.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698