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

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

Issue 2989563002: Preserve type variables in closure conversion. (Closed)
Patch Set: Update binary.md. 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
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..082209aeca85e1da8a789d85dcff7d8c313e2460 100644
--- a/pkg/kernel/lib/transformations/closure/info.dart
+++ b/pkg/kernel/lib/transformations/closure/info.dart
@@ -30,6 +30,8 @@ class ClosureInfo extends RecursiveVisitor {
final Set<VariableDeclaration> variables = new Set<VariableDeclaration>();
+ /// Map from functions to set of type variables captured within them.
+ ///
karlklose 2017/07/25 09:38:23 Remove empty comment line.
sjindel 2017/07/25 13:11:48 Done.
final Map<FunctionNode, Set<TypeParameter>> typeVariables =
<FunctionNode, Set<TypeParameter>>{};
@@ -166,7 +168,8 @@ class ClosureInfo extends RecursiveVisitor {
// Propagate captured type variables to enclosing function.
typeVariables
.putIfAbsent(currentFunction, () => new Set<TypeParameter>())
- .addAll(capturedTypeVariables);
+ .addAll(
+ capturedTypeVariables.where((t) => t.parent != currentFunction));
karlklose 2017/07/25 09:38:23 Consider adding a comment here to explain when 't.
sjindel 2017/07/25 13:11:48 Done.
Dmitry Stefantsov 2017/07/26 09:12:09 Karl may correct me, but I think using square brac
karlklose 2017/07/26 10:36:30 Yes, you should use `` for code fragments. Note th
}
}
@@ -190,7 +193,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);

Powered by Google App Engine
This is Rietveld 408576698