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

Side by Side Diff: lib/compiler/implementation/dart_backend/placeholder_collector.dart

Issue 10875009: [dart2dart] Fix type variables for interfaces and default classes if they are in different libs. (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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | tests/compiler/dart2js/unparser_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 class LocalPlaceholder implements Hashable { 5 class LocalPlaceholder implements Hashable {
6 final String identifier; 6 final String identifier;
7 final Set<Node> nodes; 7 final Set<Node> nodes;
8 LocalPlaceholder(this.identifier) : nodes = new Set<Node>(); 8 LocalPlaceholder(this.identifier) : nodes = new Set<Node>();
9 int hashCode() => identifier.hashCode(); 9 int hashCode() => identifier.hashCode();
10 String toString() => 10 String toString() =>
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 // resolver, it just crashes when it meets type variable. 381 // resolver, it just crashes when it meets type variable.
382 Type defaultType = classElement.defaultClass; 382 Type defaultType = classElement.defaultClass;
383 assert(defaultType !== null); 383 assert(defaultType !== null);
384 makeTypePlaceholder(node.defaultClause.typeName, defaultType); 384 makeTypePlaceholder(node.defaultClause.typeName, defaultType);
385 visit(node.defaultClause.typeArguments); 385 visit(node.defaultClause.typeArguments);
386 } 386 }
387 } 387 }
388 388
389 visitTypeVariable(TypeVariable node) { 389 visitTypeVariable(TypeVariable node) {
390 assert(currentElement is TypedefElement || currentElement is ClassElement); 390 assert(currentElement is TypedefElement || currentElement is ClassElement);
391 // Hack for case when interface and default class are in different
392 // libraries, try to resolve type variable to default class type arg.
393 // Example:
394 // lib1: interface I<K> default C<K> {...}
395 // lib2: class C<K> {...}
396 if (currentElement is ClassElement
397 && (currentElement as ClassElement).defaultClass !== null) {
398 currentElement = (currentElement as ClassElement).defaultClass.element;
399 }
391 // Another poor man type resolution. 400 // Another poor man type resolution.
392 // Find this variable in current element type parameters. 401 // Find this variable in current element type parameters.
393 for (Type type in currentElement.typeVariables) { 402 for (Type type in currentElement.typeVariables) {
394 if (type.name.slowToString() == node.name.source.slowToString()) { 403 if (type.name.slowToString() == node.name.source.slowToString()) {
395 makeTypePlaceholder(node.name, type); 404 makeTypePlaceholder(node.name, type);
396 break; 405 break;
397 } 406 }
398 } 407 }
399 node.visitChildren(this); 408 node.visitChildren(this);
400 } 409 }
401 410
402 visitTypedef(Typedef node) { 411 visitTypedef(Typedef node) {
403 assert(currentElement is TypedefElement); 412 assert(currentElement is TypedefElement);
404 makeElementPlaceholder(node.name, currentElement); 413 makeElementPlaceholder(node.name, currentElement);
405 node.visitChildren(this); 414 node.visitChildren(this);
406 } 415 }
407 } 416 }
OLDNEW
« no previous file with comments | « no previous file | tests/compiler/dart2js/unparser_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698