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

Side by Side Diff: lib/compiler/implementation/resolver.dart

Issue 10915054: Mark the local for this as used if a constructor call needs type variables. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add test and address comments. Created 8 years, 3 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
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 interface TreeElements { 5 interface TreeElements {
6 Element operator[](Node node); 6 Element operator[](Node node);
7 Selector getSelector(Send send); 7 Selector getSelector(Send send);
8 DartType getType(TypeAnnotation annotation); 8 DartType getType(TypeAnnotation annotation);
9 } 9 }
10 10
(...skipping 1529 matching lines...) Expand 10 before | Expand all | Expand 10 after
1540 world.registerInstantiatedClass(cls); 1540 world.registerInstantiatedClass(cls);
1541 cls.forEachInstanceField( 1541 cls.forEachInstanceField(
1542 includeBackendMembers: false, 1542 includeBackendMembers: false,
1543 includeSuperMembers: true, 1543 includeSuperMembers: true,
1544 f: (ClassElement enclosingClass, Element member) { 1544 f: (ClassElement enclosingClass, Element member) {
1545 world.addToWorkList(member); 1545 world.addToWorkList(member);
1546 }); 1546 });
1547 return null; 1547 return null;
1548 } 1548 }
1549 1549
1550 TypeAnnotation getTypeAnnotationFromSend(Send send) {
1551 if (send.selector.asTypeAnnotation() !== null) {
1552 return send.selector;
1553 } else if (send.selector.asSend() !== null) {
1554 Send selector = send.selector;
1555 if (selector.receiver.asTypeAnnotation() !== null) {
1556 return selector.receiver;
1557 }
1558 } else {
1559 compiler.internalError("malformed send in new expression");
1560 }
1561 }
1562
1563 /** 1550 /**
1564 * Try to resolve the constructor that is referred to by [node]. 1551 * Try to resolve the constructor that is referred to by [node].
1565 * Note: this function may return an ErroneousFunctionElement instead of 1552 * Note: this function may return an ErroneousFunctionElement instead of
1566 * [null], if there is no corresponding constructor, class or library. 1553 * [null], if there is no corresponding constructor, class or library.
1567 */ 1554 */
1568 FunctionElement resolveConstructor(NewExpression node) { 1555 FunctionElement resolveConstructor(NewExpression node) {
1569 // Resolve the constructor that [node] refers to. 1556 // Resolve the constructor that [node] refers to.
1570 ConstructorResolver visitor = 1557 ConstructorResolver visitor =
1571 new ConstructorResolver(compiler, this, node.isConst()); 1558 new ConstructorResolver(compiler, this, node.isConst());
1572 FunctionElement constructor = node.accept(visitor); 1559 FunctionElement constructor = node.accept(visitor);
1573 // Try to resolve the type that the new-expression constructs. 1560 // Try to resolve the type that the new-expression constructs.
1574 TypeAnnotation annotation = getTypeAnnotationFromSend(node.send); 1561 TypeAnnotation annotation = node.send.getTypeAnnotation();
1575 if (Element.isInvalid(constructor)) { 1562 if (Element.isInvalid(constructor)) {
1576 // Resolve the type arguments. We cannot create a type and check the 1563 // Resolve the type arguments. We cannot create a type and check the
1577 // number of type arguments for this annotation, because we do not know 1564 // number of type arguments for this annotation, because we do not know
1578 // the element. 1565 // the element.
1579 Link arguments = const EmptyLink<Node>(); 1566 Link arguments = const EmptyLink<Node>();
1580 if (annotation.typeArguments != null) { 1567 if (annotation.typeArguments != null) {
1581 arguments = annotation.typeArguments.nodes; 1568 arguments = annotation.typeArguments.nodes;
1582 } 1569 }
1583 for (Node argument in arguments) { 1570 for (Node argument in arguments) {
1584 resolveTypeRequired(argument); 1571 resolveTypeRequired(argument);
(...skipping 1052 matching lines...) Expand 10 before | Expand all | Expand 10 after
2637 TopScope(LibraryElement library) : super(null, library); 2624 TopScope(LibraryElement library) : super(null, library);
2638 Element lookup(SourceString name) { 2625 Element lookup(SourceString name) {
2639 return library.find(name); 2626 return library.find(name);
2640 } 2627 }
2641 2628
2642 Element add(Element newElement) { 2629 Element add(Element newElement) {
2643 throw "Cannot add an element in the top scope"; 2630 throw "Cannot add an element in the top scope";
2644 } 2631 }
2645 String toString() => '$element'; 2632 String toString() => '$element';
2646 } 2633 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698