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

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

Issue 11034021: [dart2dart] Don't go inside TypeAnnotation.typeName, otherwise in "new lib.A()" expression (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 2 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 | no next file » | 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 { 5 class LocalPlaceholder {
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 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 } else { 427 } else {
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 bool hasPrefix = false;
437 if (type is InterfaceType || type is TypedefType) { 438 if (type is InterfaceType || type is TypedefType) {
438 Node target = node.typeName; 439 Node target = node.typeName;
439 bool hasPrefix = false;
440 if (node.typeName is Send) { 440 if (node.typeName is Send) {
441 final send = node.typeName.asSend(); 441 final send = node.typeName.asSend();
442 Identifier receiver = send.receiver; 442 Identifier receiver = send.receiver;
443 Identifier selector = send.selector; 443 Identifier selector = send.selector;
444 Element potentialPrefix = 444 Element potentialPrefix =
445 currentElement.getLibrary().findLocal(receiver.source); 445 currentElement.getLibrary().findLocal(receiver.source);
446 if (potentialPrefix !== null && potentialPrefix.isPrefix()) { 446 if (potentialPrefix !== null && potentialPrefix.isPrefix()) {
447 // prefix.Class case. 447 // prefix.Class case.
448 hasPrefix = true; 448 hasPrefix = true;
449 } else { 449 } else {
(...skipping 16 matching lines...) Expand all
466 typeElement === dynamicTypeElement)) { 466 typeElement === dynamicTypeElement)) {
467 makeNullPlaceholder(node.typeName.receiver); 467 makeNullPlaceholder(node.typeName.receiver);
468 } else { 468 } else {
469 if (typeElement !== dynamicTypeElement) { 469 if (typeElement !== dynamicTypeElement) {
470 makeTypePlaceholder(target, type); 470 makeTypePlaceholder(target, type);
471 } else { 471 } else {
472 if (!isDynamicType(node)) makeUnresolvedPlaceholder(target); 472 if (!isDynamicType(node)) makeUnresolvedPlaceholder(target);
473 } 473 }
474 } 474 }
475 } 475 }
476 node.visitChildren(this); 476 // Trying to differentiate new A.foo() and lib.A cases. In the latter case
477 // we don't want to go deeper into typeName.
478 if (hasPrefix) {
479 // Visit only type arguments, otherwise in case of lib.Class type
480 // annotation typeName is Send and we go to visitGetterSend, as a result
481 // "Class" is added to member placeholders.
482 visit(node.typeArguments);
483 } else {
484 node.visitChildren(this);
485 }
477 } 486 }
478 487
479 visitVariableDefinitions(VariableDefinitions node) { 488 visitVariableDefinitions(VariableDefinitions node) {
480 // Collect only local placeholders. 489 // Collect only local placeholders.
481 for (Node definition in node.definitions.nodes) { 490 for (Node definition in node.definitions.nodes) {
482 Element definitionElement = treeElements[definition]; 491 Element definitionElement = treeElements[definition];
483 // definitionElement may be null if we're inside variable definitions 492 // definitionElement may be null if we're inside variable definitions
484 // of a function that is a parameter of another function. 493 // of a function that is a parameter of another function.
485 // TODO(smok): Fix this when resolver correctly deals with 494 // TODO(smok): Fix this when resolver correctly deals with
486 // such cases. 495 // such cases.
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
608 617
609 visitBlock(Block node) { 618 visitBlock(Block node) {
610 for (Node statement in node.statements.nodes) { 619 for (Node statement in node.statements.nodes) {
611 if (statement is VariableDefinitions) { 620 if (statement is VariableDefinitions) {
612 makeVarDeclarationTypePlaceholder(statement); 621 makeVarDeclarationTypePlaceholder(statement);
613 } 622 }
614 } 623 }
615 node.visitChildren(this); 624 node.visitChildren(this);
616 } 625 }
617 } 626 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698