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

Unified Diff: lib/compiler/implementation/dart_backend/placeholder_collector.dart

Issue 10861029: Properly rename type variables. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 4 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 | « no previous file | lib/compiler/implementation/dart_backend/renamer.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/compiler/implementation/dart_backend/placeholder_collector.dart
diff --git a/lib/compiler/implementation/dart_backend/placeholder_collector.dart b/lib/compiler/implementation/dart_backend/placeholder_collector.dart
index c23ebed30acaf49ae70079d0953d7a8287c10afa..1f697c8f190f493d071f1a5eb378e4ca304d6272 100644
--- a/lib/compiler/implementation/dart_backend/placeholder_collector.dart
+++ b/lib/compiler/implementation/dart_backend/placeholder_collector.dart
@@ -358,12 +358,17 @@ class PlaceholderCollector extends AbstractVisitor {
visitTypeAnnotation(TypeAnnotation node) {
// Poor man generic variables resolution.
// TODO(antonm): get rid of it once resolver can deal with it.
- if (isPlainTypeName(node) && currentElement is TypeDeclarationElement) {
+ TypeDeclarationElement typeDeclarationElement;
+ if (currentElement is TypeDeclarationElement) {
+ typeDeclarationElement = currentElement;
+ } else {
+ typeDeclarationElement = currentElement.getEnclosingClass();
+ }
+ if (typeDeclarationElement !== null && isPlainTypeName(node)) {
SourceString name = node.typeName.asIdentifier().source;
- TypeDeclarationElement typeElement = currentElement;
- for (TypeVariableType parameter in typeElement.typeVariables) {
+ for (TypeVariableType parameter in typeDeclarationElement.typeVariables) {
if (parameter.name == name) {
- // type annotation matches one of parameters, shouldn't be renamed.
+ makeTypePlaceholder(node, parameter);
return;
}
}
@@ -442,6 +447,16 @@ class PlaceholderCollector extends AbstractVisitor {
assert(currentElement is ClassElement);
makeElementPlaceholder(node.name, currentElement);
node.visitChildren(this);
Roman 2012/08/22 08:32:07 probably my last change in ClassNode affects this.
+ if (node.typeParameters !== null) {
+ // Another poor man resolution.
+ final typeVariableTypes =
+ new List<Type>.from(currentElement.typeVariables);
+ int i = 0;
+ for (TypeVariable typeVariable in node.typeParameters) {
+ makeTypePlaceholder(typeVariable.name, typeVariableTypes[i]);
+ i++;
+ }
+ }
if (node.defaultClause !== null) {
// Can't just visit class node's default clause because of the bug in the
// resolver, it just crashes when it meets type variable.
« no previous file with comments | « no previous file | lib/compiler/implementation/dart_backend/renamer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698