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

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

Issue 24166003: 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 }
1753 } 1778 }
1754 1779
1755 /** 1780 /**
1756 * Core implementation of resolution. 1781 * Core implementation of resolution.
1757 * 1782 *
1758 * Do not subclass or instantiate this class outside this library 1783 * Do not subclass or instantiate this class outside this library
1759 * except for testing. 1784 * except for testing.
1760 */ 1785 */
1761 class ResolverVisitor extends MappingVisitor<Element> { 1786 class ResolverVisitor extends MappingVisitor<Element> {
1762 /** 1787 /**
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
1935 DartType type = resolveTypeAnnotation(node); 1960 DartType type = resolveTypeAnnotation(node);
1936 if (type != null) { 1961 if (type != null) {
1937 if (inCheckContext) { 1962 if (inCheckContext) {
1938 compiler.enqueuer.resolution.registerIsCheck(type, mapping); 1963 compiler.enqueuer.resolution.registerIsCheck(type, mapping);
1939 } 1964 }
1940 return type.element; 1965 return type.element;
1941 } 1966 }
1942 return null; 1967 return null;
1943 } 1968 }
1944 1969
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
1963 bool isNamedConstructor(Send node) => node.receiver != null; 1970 bool isNamedConstructor(Send node) => node.receiver != null;
1964 1971
1965 Selector getRedirectingThisOrSuperConstructorSelector(Send node) { 1972 Selector getRedirectingThisOrSuperConstructorSelector(Send node) {
1966 if (isNamedConstructor(node)) { 1973 if (isNamedConstructor(node)) {
1967 SourceString constructorName = node.selector.asIdentifier().source; 1974 SourceString constructorName = node.selector.asIdentifier().source;
1968 return new Selector.callConstructor( 1975 return new Selector.callConstructor(
1969 constructorName, 1976 constructorName,
1970 enclosingElement.getLibrary()); 1977 enclosingElement.getLibrary());
1971 } else { 1978 } else {
1972 return new Selector.callDefaultConstructor( 1979 return new Selector.callDefaultConstructor(
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
2330 void resolveArguments(NodeList list) { 2337 void resolveArguments(NodeList list) {
2331 if (list == null) return; 2338 if (list == null) return;
2332 Map<SourceString, Node> seenNamedArguments = new Map<SourceString, Node>(); 2339 Map<SourceString, Node> seenNamedArguments = new Map<SourceString, Node>();
2333 for (Link<Node> link = list.nodes; !link.isEmpty; link = link.tail) { 2340 for (Link<Node> link = list.nodes; !link.isEmpty; link = link.tail) {
2334 Expression argument = link.head; 2341 Expression argument = link.head;
2335 visit(argument); 2342 visit(argument);
2336 NamedArgument namedArgument = argument.asNamedArgument(); 2343 NamedArgument namedArgument = argument.asNamedArgument();
2337 if (namedArgument != null) { 2344 if (namedArgument != null) {
2338 SourceString source = namedArgument.name.source; 2345 SourceString source = namedArgument.name.source;
2339 if (seenNamedArguments.containsKey(source)) { 2346 if (seenNamedArguments.containsKey(source)) {
2340 compiler.reportError( 2347 reportDuplicateDefinition(
2348 source,
2341 argument, 2349 argument,
2342 MessageKind.DUPLICATE_DEFINITION, 2350 seenNamedArguments[source]);
2343 {'name': source});
2344 compiler.reportMessage(
2345 compiler.spanFromSpannable(seenNamedArguments[source]),
2346 MessageKind.EXISTING_DEFINITION.error({'name': source}),
2347 Diagnostic.INFO);
2348 } else { 2351 } else {
2349 seenNamedArguments[source] = namedArgument; 2352 seenNamedArguments[source] = namedArgument;
2350 } 2353 }
2351 } else if (!seenNamedArguments.isEmpty) { 2354 } else if (!seenNamedArguments.isEmpty) {
2352 error(argument, MessageKind.INVALID_ARGUMENT_AFTER_NAMED); 2355 error(argument, MessageKind.INVALID_ARGUMENT_AFTER_NAMED);
2353 } 2356 }
2354 } 2357 }
2355 } 2358 }
2356 2359
2357 visitSend(Send node) { 2360 visitSend(Send node) {
(...skipping 991 matching lines...) Expand 10 before | Expand all | Expand 10 after
3349 TypedefResolverVisitor(Compiler compiler, 3352 TypedefResolverVisitor(Compiler compiler,
3350 TypedefElement typedefElement, 3353 TypedefElement typedefElement,
3351 TreeElementMapping mapping) 3354 TreeElementMapping mapping)
3352 : super(compiler, typedefElement, mapping); 3355 : super(compiler, typedefElement, mapping);
3353 3356
3354 visitTypedef(Typedef node) { 3357 visitTypedef(Typedef node) {
3355 TypedefType type = element.computeType(compiler); 3358 TypedefType type = element.computeType(compiler);
3356 scope = new TypeDeclarationScope(scope, element); 3359 scope = new TypeDeclarationScope(scope, element);
3357 resolveTypeVariableBounds(node.typeParameters); 3360 resolveTypeVariableBounds(node.typeParameters);
3358 3361
3359 element.functionSignature = SignatureResolver.analyze( 3362 FunctionSignature signature = SignatureResolver.analyze(
3360 compiler, node.formals, node.returnType, element, 3363 compiler, node.formals, node.returnType, element,
3361 defaultValuesAllowed: false); 3364 defaultValuesAllowed: false);
3365 element.functionSignature = signature;
3362 3366
3363 element.alias = compiler.computeFunctionType( 3367 scope = new MethodScope(scope, element);
3364 element, element.functionSignature); 3368 signature.forEachParameter((Element element) {
3369 defineElement(element.parseNode(compiler), element);
3370 });
3371
3372 element.alias = compiler.computeFunctionType(element, signature);
3365 3373
3366 void checkCyclicReference() { 3374 void checkCyclicReference() {
3367 var visitor = new TypedefCyclicVisitor(compiler, element); 3375 var visitor = new TypedefCyclicVisitor(compiler, element);
3368 type.accept(visitor, null); 3376 type.accept(visitor, null);
3369 } 3377 }
3370 compiler.enqueuer.resolution.addPostProcessAction(element, 3378 compiler.enqueuer.resolution.addPostProcessAction(element,
3371 checkCyclicReference); 3379 checkCyclicReference);
3372 } 3380 }
3373 } 3381 }
3374 3382
(...skipping 971 matching lines...) Expand 10 before | Expand all | Expand 10 after
4346 return e; 4354 return e;
4347 } 4355 }
4348 4356
4349 /// Assumed to be called by [resolveRedirectingFactory]. 4357 /// Assumed to be called by [resolveRedirectingFactory].
4350 Element visitReturn(Return node) { 4358 Element visitReturn(Return node) {
4351 Node expression = node.expression; 4359 Node expression = node.expression;
4352 return finishConstructorReference(visit(expression), 4360 return finishConstructorReference(visit(expression),
4353 expression, expression); 4361 expression, expression);
4354 } 4362 }
4355 } 4363 }
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