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

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

Issue 23825007: Reapply r27285: "Support dynamic as type literal." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comment. Created 7 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 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 Set<Node> get superUses; 9 Set<Node> get superUses;
10 10
(...skipping 1733 matching lines...) Expand 10 before | Expand all | Expand 10 after
1744 // TODO(karlklose): clean this up (dartbug.com/8870). 1744 // TODO(karlklose): clean this up (dartbug.com/8870).
1745 inCheckContext = compiler.enableTypeAssertions && 1745 inCheckContext = compiler.enableTypeAssertions &&
1746 !element.isLibrary() && 1746 !element.isLibrary() &&
1747 !element.isTypedef() && 1747 !element.isTypedef() &&
1748 !element.enclosingElement.isTypedef(), 1748 !element.enclosingElement.isTypedef(),
1749 inCatchBlock = false, 1749 inCatchBlock = false,
1750 super(compiler, mapping); 1750 super(compiler, mapping);
1751 1751
1752 ResolutionEnqueuer get world => compiler.enqueuer.resolution; 1752 ResolutionEnqueuer get world => compiler.enqueuer.resolution;
1753 1753
1754 Element lookup(Node node, SourceString name) { 1754 Element reportLookupErrorIfAny(Element result, Node node, SourceString name) {
1755 Element result = scope.lookup(name);
1756 if (!Elements.isUnresolved(result)) { 1755 if (!Elements.isUnresolved(result)) {
1757 if (!inInstanceContext && result.isInstanceMember()) { 1756 if (!inInstanceContext && result.isInstanceMember()) {
1758 compiler.reportError( 1757 compiler.reportError(
1759 node, MessageKind.NO_INSTANCE_AVAILABLE, {'name': name}); 1758 node, MessageKind.NO_INSTANCE_AVAILABLE, {'name': name});
1760 return new ErroneousElementX(MessageKind.NO_INSTANCE_AVAILABLE, 1759 return new ErroneousElementX(MessageKind.NO_INSTANCE_AVAILABLE,
1761 {'name': name}, 1760 {'name': name},
1762 name, enclosingElement); 1761 name, enclosingElement);
1763 } else if (result.isAmbiguous()) { 1762 } else if (result.isAmbiguous()) {
1764 AmbiguousElement ambiguous = result; 1763 AmbiguousElement ambiguous = result;
1765 compiler.reportError( 1764 compiler.reportError(
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
1821 error(node, MessageKind.NO_INSTANCE_AVAILABLE, {'name': node}); 1820 error(node, MessageKind.NO_INSTANCE_AVAILABLE, {'name': node});
1822 } 1821 }
1823 return null; 1822 return null;
1824 } else if (node.isSuper()) { 1823 } else if (node.isSuper()) {
1825 if (!inInstanceContext) error(node, MessageKind.NO_SUPER_IN_STATIC); 1824 if (!inInstanceContext) error(node, MessageKind.NO_SUPER_IN_STATIC);
1826 if ((ElementCategory.SUPER & allowedCategory) == 0) { 1825 if ((ElementCategory.SUPER & allowedCategory) == 0) {
1827 error(node, MessageKind.INVALID_USE_OF_SUPER); 1826 error(node, MessageKind.INVALID_USE_OF_SUPER);
1828 } 1827 }
1829 return null; 1828 return null;
1830 } else { 1829 } else {
1831 Element element = lookup(node, node.source); 1830 SourceString name = node.source;
1831 Element element = scope.lookup(name);
1832 if (Elements.isUnresolved(element) && name.slowToString() == 'dynamic') {
1833 element = compiler.dynamicClass;
1834 }
1835 element = reportLookupErrorIfAny(element, node, node.source);
1832 if (element == null) { 1836 if (element == null) {
1833 if (!inInstanceContext) { 1837 if (!inInstanceContext) {
1834 element = warnAndCreateErroneousElement( 1838 element = warnAndCreateErroneousElement(
1835 node, node.source, MessageKind.CANNOT_RESOLVE, 1839 node, node.source, MessageKind.CANNOT_RESOLVE,
1836 {'name': node}); 1840 {'name': node});
1837 compiler.backend.registerThrowNoSuchMethod(mapping); 1841 compiler.backend.registerThrowNoSuchMethod(mapping);
1838 } 1842 }
1839 } else if (element.isErroneous()) { 1843 } else if (element.isErroneous()) {
1840 // Use the erroneous element. 1844 // Use the erroneous element.
1841 } else { 1845 } else {
(...skipping 2279 matching lines...) Expand 10 before | Expand all | Expand 10 after
4121 error(node, MessageKind.NOT_A_TYPE.error, {'node': name}); 4125 error(node, MessageKind.NOT_A_TYPE.error, {'node': name});
4122 } 4126 }
4123 } else { 4127 } else {
4124 internalError(node.receiver, 'unexpected element $e'); 4128 internalError(node.receiver, 'unexpected element $e');
4125 } 4129 }
4126 return e; 4130 return e;
4127 } 4131 }
4128 4132
4129 Element visitIdentifier(Identifier node) { 4133 Element visitIdentifier(Identifier node) {
4130 SourceString name = node.source; 4134 SourceString name = node.source;
4131 Element e = resolver.lookup(node, name); 4135 Element e = resolver.reportLookupErrorIfAny(
4136 resolver.scope.lookup(name), node, name);
4132 // TODO(johnniwinther): Change errors to warnings, cf. 11.11.1. 4137 // TODO(johnniwinther): Change errors to warnings, cf. 11.11.1.
4133 if (e == null) { 4138 if (e == null) {
4134 return failOrReturnErroneousElement(resolver.enclosingElement, node, name, 4139 return failOrReturnErroneousElement(resolver.enclosingElement, node, name,
4135 MessageKind.CANNOT_RESOLVE, 4140 MessageKind.CANNOT_RESOLVE,
4136 {'name': name}); 4141 {'name': name});
4137 } else if (e.isErroneous()) { 4142 } else if (e.isErroneous()) {
4138 return e; 4143 return e;
4139 } else if (identical(e.kind, ElementKind.TYPEDEF)) { 4144 } else if (identical(e.kind, ElementKind.TYPEDEF)) {
4140 error(node, MessageKind.CANNOT_INSTANTIATE_TYPEDEF, 4145 error(node, MessageKind.CANNOT_INSTANTIATE_TYPEDEF,
4141 {'typedefName': name}); 4146 {'typedefName': name});
4142 } else if (identical(e.kind, ElementKind.TYPE_VARIABLE)) { 4147 } else if (identical(e.kind, ElementKind.TYPE_VARIABLE)) {
4143 error(node, MessageKind.CANNOT_INSTANTIATE_TYPE_VARIABLE, 4148 error(node, MessageKind.CANNOT_INSTANTIATE_TYPE_VARIABLE,
4144 {'typeVariableName': name}); 4149 {'typeVariableName': name});
4145 } else if (!identical(e.kind, ElementKind.CLASS) 4150 } else if (!identical(e.kind, ElementKind.CLASS)
4146 && !identical(e.kind, ElementKind.PREFIX)) { 4151 && !identical(e.kind, ElementKind.PREFIX)) {
4147 error(node, MessageKind.NOT_A_TYPE.error, {'node': name}); 4152 error(node, MessageKind.NOT_A_TYPE.error, {'node': name});
4148 } 4153 }
4149 return e; 4154 return e;
4150 } 4155 }
4151 4156
4152 /// Assumed to be called by [resolveRedirectingFactory]. 4157 /// Assumed to be called by [resolveRedirectingFactory].
4153 Element visitReturn(Return node) { 4158 Element visitReturn(Return node) {
4154 Node expression = node.expression; 4159 Node expression = node.expression;
4155 return finishConstructorReference(visit(expression), 4160 return finishConstructorReference(visit(expression),
4156 expression, expression); 4161 expression, expression);
4157 } 4162 }
4158 } 4163 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/js_backend/namer.dart ('k') | tests/language/first_class_types_literals_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698