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

Unified Diff: lib/compiler/implementation/closure.dart

Issue 10915054: Mark the local for this as used if a constructor call needs type variables. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add test and address comments. Created 8 years, 3 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: lib/compiler/implementation/closure.dart
diff --git a/lib/compiler/implementation/closure.dart b/lib/compiler/implementation/closure.dart
index f278e6ba8ba7b5118f37e1dcb0d93a0f15ef6f9b..bfa29101e403d21265a14fdc2039f775497cf871 100644
--- a/lib/compiler/implementation/closure.dart
+++ b/lib/compiler/implementation/closure.dart
@@ -317,6 +317,30 @@ class ClosureTranslator extends AbstractVisitor {
super.visitSendSet(node);
}
+ visitNewExpression(NewExpression node) {
+ bool hasTypeVariable(DartType type) {
+ if (type is TypeVariableType) {
+ return true;
+ } else if (type is InterfaceType) {
+ InterfaceType ifcType = type;
+ for (DartType argument in ifcType.arguments) {
+ if (hasTypeVariable(argument)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+ TypeAnnotation annotation = node.send.getTypeAnnotation();
+ DartType type = elements.getType(annotation);
+ if (hasTypeVariable(type)) {
+ if (closureData.thisElement !== null) {
floitsch 2012/09/03 14:04:15 Add comment why this is necessary. Maybe find a mo
+ useLocal(closureData.thisElement);
+ }
+ }
+ node.visitChildren(this);
+ }
+
// If variables that are declared in the [node] scope are captured and need
// to be boxed create a box-element and update the [capturingScopes] in the
// current [closureData].
« no previous file with comments | « no previous file | lib/compiler/implementation/resolver.dart » ('j') | tests/language/closure_type_variables_test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698