Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 435 } | 435 } |
| 436 } | 436 } |
| 437 } | 437 } |
| 438 node.visitChildren(this); | 438 node.visitChildren(this); |
| 439 } | 439 } |
| 440 | 440 |
| 441 visitClassNode(ClassNode node) { | 441 visitClassNode(ClassNode node) { |
| 442 assert(currentElement is ClassElement); | 442 assert(currentElement is ClassElement); |
| 443 makeElementPlaceholder(node.name, currentElement); | 443 makeElementPlaceholder(node.name, currentElement); |
| 444 node.visitChildren(this); | 444 node.visitChildren(this); |
| 445 if (node.typeParameters !== null) { | |
| 446 // Another poor man resolution. | |
| 447 final typeVariableTypes = | |
| 448 new List<Type>.from(currentElement.typeVariables); | |
| 449 int i = 0; | |
| 450 for (TypeVariable typeVariable in node.typeParameters) { | |
| 451 makeTypePlaceholder(typeVariable.name, typeVariableTypes[i]); | |
| 452 i++; | |
| 453 } | |
| 454 } | |
| 455 if (node.defaultClause !== null) { | 445 if (node.defaultClause !== null) { |
| 456 // Can't just visit class node's default clause because of the bug in the | 446 // Can't just visit class node's default clause because of the bug in the |
| 457 // resolver, it just crashes when it meets type variable. | 447 // resolver, it just crashes when it meets type variable. |
| 458 Type defaultType = (currentElement as ClassElement).defaultClass; | 448 Type defaultType = (currentElement as ClassElement).defaultClass; |
| 459 assert(defaultType !== null); | 449 assert(defaultType !== null); |
| 460 makeTypePlaceholder(node.defaultClause.typeName, defaultType); | 450 makeTypePlaceholder(node.defaultClause.typeName, defaultType); |
| 461 visit(node.defaultClause.typeArguments); | 451 visit(node.defaultClause.typeArguments); |
| 462 } | 452 } |
| 463 } | 453 } |
| 464 | 454 |
| 455 visitTypeVariable(TypeVariable node) { | |
|
Anton Muhin
2012/08/22 12:34:53
it fixes a case with typedefs too?
Roman
2012/08/22 12:38:22
Yes, there's a test for it in unparser_test. At fi
| |
| 456 assert(currentElement is TypedefElement || currentElement is ClassElement); | |
| 457 // Another poor man type resolution. | |
| 458 // Find this variable in current element type parameters. | |
| 459 for (Type type in currentElement.typeVariables) { | |
| 460 if (type.name.slowToString() == node.name.source.slowToString()) { | |
| 461 makeTypePlaceholder(node.name, type); | |
| 462 break; | |
| 463 } | |
| 464 } | |
| 465 node.visitChildren(this); | |
| 466 } | |
| 467 | |
| 465 visitTypedef(Typedef node) { | 468 visitTypedef(Typedef node) { |
| 466 assert(currentElement is TypedefElement); | 469 assert(currentElement is TypedefElement); |
| 467 makeElementPlaceholder(node.name, currentElement); | 470 makeElementPlaceholder(node.name, currentElement); |
| 468 node.visitChildren(this); | 471 node.visitChildren(this); |
| 469 } | 472 } |
| 470 } | 473 } |
| OLD | NEW |