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

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

Issue 23531079: Revert "Reapply r27640: "Emit compile-time error on duplicate parameter names in typedefs."" (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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 1732 matching lines...) Expand 10 before | Expand all | Expand 10 after
1743 return mapping[node] = element; 1743 return mapping[node] = element;
1744 } 1744 }
1745 1745
1746 DartType useType(TypeAnnotation annotation, DartType type) { 1746 DartType useType(TypeAnnotation annotation, DartType type) {
1747 if (type != null) { 1747 if (type != null) {
1748 mapping.setType(annotation, type); 1748 mapping.setType(annotation, type);
1749 useElement(annotation, type.element); 1749 useElement(annotation, type.element);
1750 } 1750 }
1751 return type; 1751 return type;
1752 } 1752 }
1753
1754 Element defineElement(Node node, Element element,
1755 {bool doAddToScope: true}) {
1756 compiler.ensure(element != null);
1757 mapping[node] = element;
1758 if (doAddToScope) {
1759 Element existing = scope.add(element);
1760 if (existing != element) {
1761 reportDuplicateDefinition(node, element, existing);
1762 }
1763 }
1764 return element;
1765 }
1766
1767 void reportDuplicateDefinition(/*Node|SourceString*/ name,
1768 Spannable definition,
1769 Spannable existing) {
1770 compiler.reportError(
1771 definition,
1772 MessageKind.DUPLICATE_DEFINITION, {'name': name});
1773 compiler.reportMessage(
1774 compiler.spanFromSpannable(existing),
1775 MessageKind.EXISTING_DEFINITION.error({'name': name}),
1776 Diagnostic.INFO);
1777 }
1778 } 1753 }
1779 1754
1780 /** 1755 /**
1781 * Core implementation of resolution. 1756 * Core implementation of resolution.
1782 * 1757 *
1783 * Do not subclass or instantiate this class outside this library 1758 * Do not subclass or instantiate this class outside this library
1784 * except for testing. 1759 * except for testing.
1785 */ 1760 */
1786 class ResolverVisitor extends MappingVisitor<Element> { 1761 class ResolverVisitor extends MappingVisitor<Element> {
1787 /** 1762 /**
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
1960 DartType type = resolveTypeAnnotation(node); 1935 DartType type = resolveTypeAnnotation(node);
1961 if (type != null) { 1936 if (type != null) {
1962 if (inCheckContext) { 1937 if (inCheckContext) {
1963 compiler.enqueuer.resolution.registerIsCheck(type, mapping); 1938 compiler.enqueuer.resolution.registerIsCheck(type, mapping);
1964 } 1939 }
1965 return type.element; 1940 return type.element;
1966 } 1941 }
1967 return null; 1942 return null;
1968 } 1943 }
1969 1944
1945 Element defineElement(Node node, Element element,
1946 {bool doAddToScope: true}) {
1947 compiler.ensure(element != null);
1948 mapping[node] = element;
1949 if (doAddToScope) {
1950 Element existing = scope.add(element);
1951 if (existing != element) {
1952 compiler.reportError(
1953 node, MessageKind.DUPLICATE_DEFINITION, {'name': node});
1954 compiler.reportMessage(
1955 compiler.spanFromSpannable(existing),
1956 MessageKind.EXISTING_DEFINITION.error({'name': node}),
1957 Diagnostic.INFO);
1958 }
1959 }
1960 return element;
1961 }
1962
1970 bool isNamedConstructor(Send node) => node.receiver != null; 1963 bool isNamedConstructor(Send node) => node.receiver != null;
1971 1964
1972 Selector getRedirectingThisOrSuperConstructorSelector(Send node) { 1965 Selector getRedirectingThisOrSuperConstructorSelector(Send node) {
1973 if (isNamedConstructor(node)) { 1966 if (isNamedConstructor(node)) {
1974 SourceString constructorName = node.selector.asIdentifier().source; 1967 SourceString constructorName = node.selector.asIdentifier().source;
1975 return new Selector.callConstructor( 1968 return new Selector.callConstructor(
1976 constructorName, 1969 constructorName,
1977 enclosingElement.getLibrary()); 1970 enclosingElement.getLibrary());
1978 } else { 1971 } else {
1979 return new Selector.callDefaultConstructor( 1972 return new Selector.callDefaultConstructor(
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
2337 void resolveArguments(NodeList list) { 2330 void resolveArguments(NodeList list) {
2338 if (list == null) return; 2331 if (list == null) return;
2339 Map<SourceString, Node> seenNamedArguments = new Map<SourceString, Node>(); 2332 Map<SourceString, Node> seenNamedArguments = new Map<SourceString, Node>();
2340 for (Link<Node> link = list.nodes; !link.isEmpty; link = link.tail) { 2333 for (Link<Node> link = list.nodes; !link.isEmpty; link = link.tail) {
2341 Expression argument = link.head; 2334 Expression argument = link.head;
2342 visit(argument); 2335 visit(argument);
2343 NamedArgument namedArgument = argument.asNamedArgument(); 2336 NamedArgument namedArgument = argument.asNamedArgument();
2344 if (namedArgument != null) { 2337 if (namedArgument != null) {
2345 SourceString source = namedArgument.name.source; 2338 SourceString source = namedArgument.name.source;
2346 if (seenNamedArguments.containsKey(source)) { 2339 if (seenNamedArguments.containsKey(source)) {
2347 reportDuplicateDefinition( 2340 compiler.reportError(
2348 source,
2349 argument, 2341 argument,
2350 seenNamedArguments[source]); 2342 MessageKind.DUPLICATE_DEFINITION,
2343 {'name': source});
2344 compiler.reportMessage(
2345 compiler.spanFromSpannable(seenNamedArguments[source]),
2346 MessageKind.EXISTING_DEFINITION.error({'name': source}),
2347 Diagnostic.INFO);
2351 } else { 2348 } else {
2352 seenNamedArguments[source] = namedArgument; 2349 seenNamedArguments[source] = namedArgument;
2353 } 2350 }
2354 } else if (!seenNamedArguments.isEmpty) { 2351 } else if (!seenNamedArguments.isEmpty) {
2355 error(argument, MessageKind.INVALID_ARGUMENT_AFTER_NAMED); 2352 error(argument, MessageKind.INVALID_ARGUMENT_AFTER_NAMED);
2356 } 2353 }
2357 } 2354 }
2358 } 2355 }
2359 2356
2360 visitSend(Send node) { 2357 visitSend(Send node) {
(...skipping 991 matching lines...) Expand 10 before | Expand all | Expand 10 after
3352 TypedefResolverVisitor(Compiler compiler, 3349 TypedefResolverVisitor(Compiler compiler,
3353 TypedefElement typedefElement, 3350 TypedefElement typedefElement,
3354 TreeElementMapping mapping) 3351 TreeElementMapping mapping)
3355 : super(compiler, typedefElement, mapping); 3352 : super(compiler, typedefElement, mapping);
3356 3353
3357 visitTypedef(Typedef node) { 3354 visitTypedef(Typedef node) {
3358 TypedefType type = element.computeType(compiler); 3355 TypedefType type = element.computeType(compiler);
3359 scope = new TypeDeclarationScope(scope, element); 3356 scope = new TypeDeclarationScope(scope, element);
3360 resolveTypeVariableBounds(node.typeParameters); 3357 resolveTypeVariableBounds(node.typeParameters);
3361 3358
3362 FunctionSignature signature = SignatureResolver.analyze( 3359 element.functionSignature = SignatureResolver.analyze(
3363 compiler, node.formals, node.returnType, element, 3360 compiler, node.formals, node.returnType, element,
3364 defaultValuesAllowed: false); 3361 defaultValuesAllowed: false);
3365 element.functionSignature = signature;
3366 3362
3367 scope = new MethodScope(scope, element); 3363 element.alias = compiler.computeFunctionType(
3368 signature.forEachParameter((Element element) { 3364 element, element.functionSignature);
3369 defineElement(element.parseNode(compiler), element);
3370 });
3371
3372 element.alias = compiler.computeFunctionType(element, signature);
3373 3365
3374 void checkCyclicReference() { 3366 void checkCyclicReference() {
3375 var visitor = new TypedefCyclicVisitor(compiler, element); 3367 var visitor = new TypedefCyclicVisitor(compiler, element);
3376 type.accept(visitor, null); 3368 type.accept(visitor, null);
3377 } 3369 }
3378 compiler.enqueuer.resolution.addPostProcessAction(element, 3370 compiler.enqueuer.resolution.addPostProcessAction(element,
3379 checkCyclicReference); 3371 checkCyclicReference);
3380 } 3372 }
3381 } 3373 }
3382 3374
(...skipping 971 matching lines...) Expand 10 before | Expand all | Expand 10 after
4354 return e; 4346 return e;
4355 } 4347 }
4356 4348
4357 /// Assumed to be called by [resolveRedirectingFactory]. 4349 /// Assumed to be called by [resolveRedirectingFactory].
4358 Element visitReturn(Return node) { 4350 Element visitReturn(Return node) {
4359 Node expression = node.expression; 4351 Node expression = node.expression;
4360 return finishConstructorReference(visit(expression), 4352 return finishConstructorReference(visit(expression),
4361 expression, expression); 4353 expression, expression);
4362 } 4354 }
4363 } 4355 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/dart_backend/placeholder_collector.dart ('k') | tests/co19/co19-dart2dart.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698