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

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: Remove debug code. Created 7 years, 1 month 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 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 creates the ErroneousElement for the MalformedType.
ngeoffray 2013/10/21 13:28:56 caller creates -> the caller of this method will c
Johnni Winther 2013/10/22 06:25:54 Done.
1638 return null;
1645 } else { 1639 } else {
1646 String stringValue = typeName.source; 1640 String stringValue = typeName.source;
1647 if (identical(stringValue, 'void')) { 1641 if (identical(stringValue, 'void')) {
1648 return compiler.types.voidType.element; 1642 return compiler.types.voidType.element;
1649 } else if (identical(stringValue, 'dynamic')) { 1643 } else if (identical(stringValue, 'dynamic')) {
1650 return compiler.dynamicClass; 1644 return compiler.dynamicClass;
1651 } else { 1645 } else {
1652 return lookupInScope(compiler, typeName, scope, typeName.source); 1646 return lookupInScope(compiler, typeName, scope, typeName.source);
1653 } 1647 }
1654 } 1648 }
1655 } 1649 }
1656 1650
1657 DartType resolveTypeAnnotation(MappingVisitor visitor, TypeAnnotation node, 1651 DartType resolveTypeAnnotation(MappingVisitor visitor, TypeAnnotation node,
1658 {bool malformedIsError: false}) { 1652 {bool malformedIsError: false}) {
1659 Identifier typeName; 1653 Identifier typeName;
1660 Identifier prefixName; 1654 Identifier prefixName;
1661 Send send = node.typeName.asSend(); 1655 Send send = node.typeName.asSend();
1662 if (send != null) { 1656 if (send != null) {
1663 // The type name is of the form [: prefix . identifier :]. 1657 // The type name is of the form [: prefix . identifier :].
1664 prefixName = send.receiver.asIdentifier(); 1658 prefixName = send.receiver.asIdentifier();
1665 typeName = send.selector.asIdentifier(); 1659 typeName = send.selector.asIdentifier();
1666 } else { 1660 } else {
1667 typeName = node.typeName.asIdentifier(); 1661 typeName = node.typeName.asIdentifier();
1668 } 1662 }
1669 1663
1670 Element element = resolveTypeName(visitor.scope, prefixName, typeName); 1664 Element element = resolveTypeName(visitor.scope, prefixName, typeName);
1671 DartType type;
1672 1665
1673 DartType reportFailureAndCreateType(DualKind messageKind, 1666 DartType reportFailureAndCreateType(DualKind messageKind,
1674 Map messageArguments, 1667 Map messageArguments,
1675 {DartType userProvidedBadType}) { 1668 {DartType userProvidedBadType}) {
1676 if (malformedIsError) { 1669 if (malformedIsError) {
1677 visitor.error(node, messageKind.error, messageArguments); 1670 visitor.error(node, messageKind.error, messageArguments);
1678 } else { 1671 } else {
1679 compiler.backend.registerThrowRuntimeError(visitor.mapping); 1672 compiler.backend.registerThrowRuntimeError(visitor.mapping);
1680 visitor.warning(node, messageKind.warning, messageArguments); 1673 visitor.warning(node, messageKind.warning, messageArguments);
1681 } 1674 }
(...skipping 12 matching lines...) Expand all
1694 visitor, node, const Link<DartType>(), arguments); 1687 visitor, node, const Link<DartType>(), arguments);
1695 if (hasTypeArgumentMismatch) { 1688 if (hasTypeArgumentMismatch) {
1696 return new MalformedType( 1689 return new MalformedType(
1697 new ErroneousElementX(MessageKind.TYPE_ARGUMENT_COUNT_MISMATCH, 1690 new ErroneousElementX(MessageKind.TYPE_ARGUMENT_COUNT_MISMATCH,
1698 {'type': node}, typeName.source, visitor.enclosingElement), 1691 {'type': node}, typeName.source, visitor.enclosingElement),
1699 type, arguments.toLink()); 1692 type, arguments.toLink());
1700 } 1693 }
1701 return type; 1694 return type;
1702 } 1695 }
1703 1696
1697 DartType type;
1704 if (element == null) { 1698 if (element == null) {
1705 type = reportFailureAndCreateType( 1699 type = reportFailureAndCreateType(
1706 MessageKind.CANNOT_RESOLVE_TYPE, {'typeName': node.typeName}); 1700 MessageKind.CANNOT_RESOLVE_TYPE, {'typeName': node.typeName});
1707 } else if (element.isAmbiguous()) { 1701 } else if (element.isAmbiguous()) {
1708 AmbiguousElement ambiguous = element; 1702 AmbiguousElement ambiguous = element;
1709 type = reportFailureAndCreateType( 1703 type = reportFailureAndCreateType(
1710 ambiguous.messageKind, ambiguous.messageArguments); 1704 ambiguous.messageKind, ambiguous.messageArguments);
1711 ambiguous.diagnose(visitor.mapping.currentElement, compiler); 1705 ambiguous.diagnose(visitor.mapping.currentElement, compiler);
1712 } else if (!element.impliesType()) { 1706 } else if (!element.impliesType()) {
1713 type = reportFailureAndCreateType( 1707 type = reportFailureAndCreateType(
(...skipping 2961 matching lines...) Expand 10 before | Expand all | Expand 10 after
4675 return finishConstructorReference(visit(expression), 4669 return finishConstructorReference(visit(expression),
4676 expression, expression); 4670 expression, expression);
4677 } 4671 }
4678 } 4672 }
4679 4673
4680 /// Looks up [name] in [scope] and unwraps the result. 4674 /// Looks up [name] in [scope] and unwraps the result.
4681 Element lookupInScope(Compiler compiler, Node node, 4675 Element lookupInScope(Compiler compiler, Node node,
4682 Scope scope, String name) { 4676 Scope scope, String name) {
4683 return Elements.unwrap(scope.lookup(name), compiler, node); 4677 return Elements.unwrap(scope.lookup(name), compiler, node);
4684 } 4678 }
OLDNEW
« no previous file with comments | « no previous file | sdk/lib/_internal/lib/isolate_helper.dart » ('j') | tests/language/named_constructor_test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698