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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/resolution/members.dart

Issue 32363003: Handle resolution of Class.named<TypeArg> correctly. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comments. Created 7 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 | sdk/lib/_internal/lib/isolate_helper.dart » ('j') | 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 part of resolution; 5 part of resolution;
6 6
7 abstract class TreeElements { 7 abstract class TreeElements {
8 Element get currentElement; 8 Element get currentElement;
9 Setlet<Node> get superUses; 9 Setlet<Node> get superUses;
10 10
(...skipping 1609 matching lines...) Expand 10 before | Expand all | Expand 10 after
1620 1620
1621 class TypeResolver { 1621 class TypeResolver {
1622 final Compiler compiler; 1622 final Compiler compiler;
1623 1623
1624 TypeResolver(this.compiler); 1624 TypeResolver(this.compiler);
1625 1625
1626 Element resolveTypeName(Scope scope, 1626 Element resolveTypeName(Scope scope,
1627 Identifier prefixName, 1627 Identifier prefixName,
1628 Identifier typeName) { 1628 Identifier typeName) {
1629 if (prefixName != null) { 1629 if (prefixName != null) {
1630 Element e = lookupInScope(compiler, prefixName, scope, prefixName.source); 1630 Element element =
1631 if (e != null) { 1631 lookupInScope(compiler, prefixName, scope, prefixName.source);
1632 if (identical(e.kind, ElementKind.PREFIX)) { 1632 if (element != null && element.isPrefix()) {
1633 // The receiver is a prefix. Lookup in the imported members. 1633 // The receiver is a prefix. Lookup in the imported members.
1634 PrefixElement prefix = e; 1634 PrefixElement prefix = element;
1635 return prefix.lookupLocalMember(typeName.source); 1635 return prefix.lookupLocalMember(typeName.source);
1636 } else if (identical(e.kind, ElementKind.CLASS)) {
1637 // TODO(johnniwinther): Remove this case.
1638 // The receiver is the class part of a named constructor.
1639 return e;
1640 }
1641 } else {
1642 // The caller creates the ErroneousElement for the MalformedType.
1643 return null;
1644 } 1636 }
1637 // The caller of this method will create the ErroneousElement for
1638 // the MalformedType.
1639 return null;
1645 } else { 1640 } else {
1646 String stringValue = typeName.source; 1641 String stringValue = typeName.source;
1647 if (identical(stringValue, 'void')) { 1642 if (identical(stringValue, 'void')) {
1648 return compiler.types.voidType.element; 1643 return compiler.types.voidType.element;
1649 } else if (identical(stringValue, 'dynamic')) { 1644 } else if (identical(stringValue, 'dynamic')) {
1650 return compiler.dynamicClass; 1645 return compiler.dynamicClass;
1651 } else { 1646 } else {
1652 return lookupInScope(compiler, typeName, scope, typeName.source); 1647 return lookupInScope(compiler, typeName, scope, typeName.source);
1653 } 1648 }
1654 } 1649 }
1655 } 1650 }
1656 1651
1657 DartType resolveTypeAnnotation(MappingVisitor visitor, TypeAnnotation node, 1652 DartType resolveTypeAnnotation(MappingVisitor visitor, TypeAnnotation node,
1658 {bool malformedIsError: false}) { 1653 {bool malformedIsError: false}) {
1659 Identifier typeName; 1654 Identifier typeName;
1660 Identifier prefixName; 1655 Identifier prefixName;
1661 Send send = node.typeName.asSend(); 1656 Send send = node.typeName.asSend();
1662 if (send != null) { 1657 if (send != null) {
1663 // The type name is of the form [: prefix . identifier :]. 1658 // The type name is of the form [: prefix . identifier :].
1664 prefixName = send.receiver.asIdentifier(); 1659 prefixName = send.receiver.asIdentifier();
1665 typeName = send.selector.asIdentifier(); 1660 typeName = send.selector.asIdentifier();
1666 } else { 1661 } else {
1667 typeName = node.typeName.asIdentifier(); 1662 typeName = node.typeName.asIdentifier();
1668 } 1663 }
1669 1664
1670 Element element = resolveTypeName(visitor.scope, prefixName, typeName); 1665 Element element = resolveTypeName(visitor.scope, prefixName, typeName);
1671 DartType type;
1672 1666
1673 DartType reportFailureAndCreateType(DualKind messageKind, 1667 DartType reportFailureAndCreateType(DualKind messageKind,
1674 Map messageArguments, 1668 Map messageArguments,
1675 {DartType userProvidedBadType}) { 1669 {DartType userProvidedBadType}) {
1676 if (malformedIsError) { 1670 if (malformedIsError) {
1677 visitor.error(node, messageKind.error, messageArguments); 1671 visitor.error(node, messageKind.error, messageArguments);
1678 } else { 1672 } else {
1679 compiler.backend.registerThrowRuntimeError(visitor.mapping); 1673 compiler.backend.registerThrowRuntimeError(visitor.mapping);
1680 visitor.warning(node, messageKind.warning, messageArguments); 1674 visitor.warning(node, messageKind.warning, messageArguments);
1681 } 1675 }
(...skipping 12 matching lines...) Expand all
1694 visitor, node, const Link<DartType>(), arguments); 1688 visitor, node, const Link<DartType>(), arguments);
1695 if (hasTypeArgumentMismatch) { 1689 if (hasTypeArgumentMismatch) {
1696 return new MalformedType( 1690 return new MalformedType(
1697 new ErroneousElementX(MessageKind.TYPE_ARGUMENT_COUNT_MISMATCH, 1691 new ErroneousElementX(MessageKind.TYPE_ARGUMENT_COUNT_MISMATCH,
1698 {'type': node}, typeName.source, visitor.enclosingElement), 1692 {'type': node}, typeName.source, visitor.enclosingElement),
1699 type, arguments.toLink()); 1693 type, arguments.toLink());
1700 } 1694 }
1701 return type; 1695 return type;
1702 } 1696 }
1703 1697
1698 DartType type;
1704 if (element == null) { 1699 if (element == null) {
1705 type = reportFailureAndCreateType( 1700 type = reportFailureAndCreateType(
1706 MessageKind.CANNOT_RESOLVE_TYPE, {'typeName': node.typeName}); 1701 MessageKind.CANNOT_RESOLVE_TYPE, {'typeName': node.typeName});
1707 } else if (element.isAmbiguous()) { 1702 } else if (element.isAmbiguous()) {
1708 AmbiguousElement ambiguous = element; 1703 AmbiguousElement ambiguous = element;
1709 type = reportFailureAndCreateType( 1704 type = reportFailureAndCreateType(
1710 ambiguous.messageKind, ambiguous.messageArguments); 1705 ambiguous.messageKind, ambiguous.messageArguments);
1711 ambiguous.diagnose(visitor.mapping.currentElement, compiler); 1706 ambiguous.diagnose(visitor.mapping.currentElement, compiler);
1712 } else if (!element.impliesType()) { 1707 } else if (!element.impliesType()) {
1713 type = reportFailureAndCreateType( 1708 type = reportFailureAndCreateType(
(...skipping 2961 matching lines...) Expand 10 before | Expand all | Expand 10 after
4675 return finishConstructorReference(visit(expression), 4670 return finishConstructorReference(visit(expression),
4676 expression, expression); 4671 expression, expression);
4677 } 4672 }
4678 } 4673 }
4679 4674
4680 /// Looks up [name] in [scope] and unwraps the result. 4675 /// Looks up [name] in [scope] and unwraps the result.
4681 Element lookupInScope(Compiler compiler, Node node, 4676 Element lookupInScope(Compiler compiler, Node node,
4682 Scope scope, String name) { 4677 Scope scope, String name) {
4683 return Elements.unwrap(scope.lookup(name), compiler, node); 4678 return Elements.unwrap(scope.lookup(name), compiler, node);
4684 } 4679 }
OLDNEW
« no previous file with comments | « no previous file | sdk/lib/_internal/lib/isolate_helper.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698