| 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 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 428 typeDeclarationElement = currentElement.getEnclosingClass(); | 428 typeDeclarationElement = currentElement.getEnclosingClass(); |
| 429 } | 429 } |
| 430 if (typeDeclarationElement !== null && isPlainTypeName(node) | 430 if (typeDeclarationElement !== null && isPlainTypeName(node) |
| 431 && tryResolveAndCollectTypeVariable( | 431 && tryResolveAndCollectTypeVariable( |
| 432 typeDeclarationElement, node.typeName)) { | 432 typeDeclarationElement, node.typeName)) { |
| 433 return; | 433 return; |
| 434 } | 434 } |
| 435 // We call [resolveReturnType] to allow having 'void'. | 435 // We call [resolveReturnType] to allow having 'void'. |
| 436 final type = compiler.resolveReturnType(currentElement, node); | 436 final type = compiler.resolveReturnType(currentElement, node); |
| 437 if (type is InterfaceType || type is TypedefType) { | 437 if (type is InterfaceType || type is TypedefType) { |
| 438 var target = node.typeName; | 438 Node target = node.typeName; |
| 439 bool hasPrefix = false; |
| 439 if (node.typeName is Send) { | 440 if (node.typeName is Send) { |
| 440 final element = treeElements[node]; | 441 final element = treeElements[node]; |
| 441 if (element !== null) { | 442 if (element !== null) { |
| 442 final send = node.typeName.asSend(); | 443 final send = node.typeName.asSend(); |
| 443 Identifier receiver = send.receiver; | 444 Identifier receiver = send.receiver; |
| 444 Identifier selector = send.selector; | 445 Identifier selector = send.selector; |
| 445 hasPrefix() { | 446 getConstructor() => |
| 446 if (element is TypedefElement) return true; | 447 (element as ClassElement).lookupConstructor( |
| 447 ClassElement classElement = element; | 448 receiver.source, selector.source); |
| 448 final constructor = classElement.lookupConstructor( | 449 hasPrefix = (element is TypedefElement) || getConstructor() === null; |
| 449 receiver.source, selector.source); | 450 if (!hasPrefix) target = receiver; |
| 450 return constructor === null; | |
| 451 } | |
| 452 if (!hasPrefix()) target = send.receiver; | |
| 453 } | 451 } |
| 454 } | 452 } |
| 455 // TODO(antonm): is there a better way to detect unresolved types? | 453 // TODO(antonm): is there a better way to detect unresolved types? |
| 456 if (type.element !== compiler.types.dynamicType.element) { | 454 if (type.element !== compiler.types.dynamicType.element) { |
| 457 makeTypePlaceholder(target, type); | 455 // Corner case: dart:core type with a prefix. |
| 456 // Most probably there are some additional problems with |
| 457 // coreLibPrefix.Dynamic and coreLibPrefix.topLevels. |
| 458 if (type.element.getLibrary() === coreLibrary && hasPrefix) { |
| 459 makeNullPlaceholder(node.typeName.receiver); |
| 460 } else { |
| 461 makeTypePlaceholder(target, type); |
| 462 } |
| 458 } else { | 463 } else { |
| 459 if (!isDynamicType(node)) makeUnresolvedPlaceholder(target); | 464 if (!isDynamicType(node)) makeUnresolvedPlaceholder(target); |
| 460 } | 465 } |
| 461 } | 466 } |
| 462 node.visitChildren(this); | 467 node.visitChildren(this); |
| 463 } | 468 } |
| 464 | 469 |
| 465 visitVariableDefinitions(VariableDefinitions node) { | 470 visitVariableDefinitions(VariableDefinitions node) { |
| 466 // Collect only local placeholders. | 471 // Collect only local placeholders. |
| 467 for (Node definition in node.definitions.nodes) { | 472 for (Node definition in node.definitions.nodes) { |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 594 | 599 |
| 595 visitBlock(Block node) { | 600 visitBlock(Block node) { |
| 596 for (Node statement in node.statements.nodes) { | 601 for (Node statement in node.statements.nodes) { |
| 597 if (statement is VariableDefinitions) { | 602 if (statement is VariableDefinitions) { |
| 598 makeVarDeclarationTypePlaceholder(statement); | 603 makeVarDeclarationTypePlaceholder(statement); |
| 599 } | 604 } |
| 600 } | 605 } |
| 601 node.visitChildren(this); | 606 node.visitChildren(this); |
| 602 } | 607 } |
| 603 } | 608 } |
| OLD | NEW |