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 part of dart_backend; | 5 part of dart_backend; |
6 | 6 |
7 class LocalPlaceholder { | 7 class LocalPlaceholder { |
8 final String identifier; | 8 final String identifier; |
9 final Set<Node> nodes; | 9 final Set<Node> nodes; |
10 LocalPlaceholder(this.identifier) : nodes = new Set<Node>(); | 10 LocalPlaceholder(this.identifier) : nodes = new Set<Node>(); |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 | 358 |
359 visitNode(Node node) { node.visitChildren(this); } // We must go deeper. | 359 visitNode(Node node) { node.visitChildren(this); } // We must go deeper. |
360 | 360 |
361 visitNewExpression(NewExpression node) { | 361 visitNewExpression(NewExpression node) { |
362 Send send = node.send; | 362 Send send = node.send; |
363 InterfaceType type = treeElements.getType(node); | 363 InterfaceType type = treeElements.getType(node); |
364 assert(type != null); | 364 assert(type != null); |
365 Element constructor = treeElements[send]; | 365 Element constructor = treeElements[send]; |
366 assert(constructor != null); | 366 assert(constructor != null); |
367 assert(send.receiver == null); | 367 assert(send.receiver == null); |
368 if (!Elements.isErroneousElement(constructor) && | 368 |
369 !Elements.isMalformedElement(constructor)) { | 369 // For constructors that refer to malformed class types retrieve |
| 370 // class type like it is done in [ SsaBuilder.visitNewSend ]. |
| 371 if (type.kind == TypeKind.MALFORMED_TYPE) { |
| 372 type = constructor.getEnclosingClass().thisType; |
| 373 } |
| 374 |
| 375 if (!Elements.isUnresolved(constructor)) { |
370 makeConstructorPlaceholder(node.send.selector, constructor, type); | 376 makeConstructorPlaceholder(node.send.selector, constructor, type); |
371 // TODO(smok): Should this be in visitNamedArgument? | 377 // TODO(smok): Should this be in visitNamedArgument? |
372 // Field names can be exposed as names of optional arguments, e.g. | 378 // Field names can be exposed as names of optional arguments, e.g. |
373 // class C { | 379 // class C { |
374 // final field; | 380 // final field; |
375 // C([this.field]); | 381 // C([this.field]); |
376 // } | 382 // } |
377 // Do not forget to rename them as well. | 383 // Do not forget to rename them as well. |
378 FunctionElement constructorFunction = constructor; | 384 FunctionElement constructorFunction = constructor; |
379 Link<Element> optionalParameters = | 385 Link<Element> optionalParameters = |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
616 | 622 |
617 visitBlock(Block node) { | 623 visitBlock(Block node) { |
618 for (Node statement in node.statements.nodes) { | 624 for (Node statement in node.statements.nodes) { |
619 if (statement is VariableDefinitions) { | 625 if (statement is VariableDefinitions) { |
620 makeVarDeclarationTypePlaceholder(statement); | 626 makeVarDeclarationTypePlaceholder(statement); |
621 } | 627 } |
622 } | 628 } |
623 node.visitChildren(this); | 629 node.visitChildren(this); |
624 } | 630 } |
625 } | 631 } |
OLD | NEW |