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

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

Issue 23463032: Emit compile-time error on duplicate parameter names in typedefs. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Use defineElement for parameters. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/co19/co19-dart2js.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/compiler/implementation/resolution/members.dart
diff --git a/sdk/lib/_internal/compiler/implementation/resolution/members.dart b/sdk/lib/_internal/compiler/implementation/resolution/members.dart
index 130943c3f752e220ae367a76ff733065f9c28743..09a9c463e06110a65e5bd00ca2c2ad7f9ed01bcf 100644
--- a/sdk/lib/_internal/compiler/implementation/resolution/members.dart
+++ b/sdk/lib/_internal/compiler/implementation/resolution/members.dart
@@ -1723,6 +1723,30 @@ abstract class MappingVisitor<T> extends CommonResolverVisitor<T> {
}
return type;
}
+
+ Element defineElement(Node node, Element element,
+ {bool doAddToScope: true}) {
+ compiler.ensure(element != null);
+ mapping[node] = element;
+ if (doAddToScope) {
+ Element existing = scope.add(element);
+ if (existing != element) {
+ reportDuplicateDefinition(node, element, existing);
+ }
+ }
+ return element;
+ }
+
+ void reportDuplicateDefinition(name, Spannable definition,
ngeoffray 2013/09/16 16:12:49 Could you add (/* SourceString|Node */ name, ...)
+ Spannable existing) {
+ compiler.reportError(
+ definition,
+ MessageKind.DUPLICATE_DEFINITION, {'name': name});
+ compiler.reportMessage(
+ compiler.spanFromSpannable(existing),
+ MessageKind.EXISTING_DEFINITION.error({'name': name}),
+ Diagnostic.INFO);
+ }
}
/**
@@ -1915,24 +1939,6 @@ class ResolverVisitor extends MappingVisitor<Element> {
return null;
}
- Element defineElement(Node node, Element element,
- {bool doAddToScope: true}) {
- compiler.ensure(element != null);
- mapping[node] = element;
- if (doAddToScope) {
- Element existing = scope.add(element);
- if (existing != element) {
- compiler.reportError(
- node, MessageKind.DUPLICATE_DEFINITION, {'name': node});
- compiler.reportMessage(
- compiler.spanFromSpannable(existing),
- MessageKind.EXISTING_DEFINITION.error({'name': node}),
- Diagnostic.INFO);
- }
- }
- return element;
- }
-
bool isNamedConstructor(Send node) => node.receiver != null;
Selector getRedirectingThisOrSuperConstructorSelector(Send node) {
@@ -2310,14 +2316,10 @@ class ResolverVisitor extends MappingVisitor<Element> {
if (namedArgument != null) {
SourceString source = namedArgument.name.source;
if (seenNamedArguments.containsKey(source)) {
ngeoffray 2013/09/16 16:12:49 Do you still need this check? It seems that the de
- compiler.reportError(
+ reportDuplicateDefinition(
+ source,
argument,
- MessageKind.DUPLICATE_DEFINITION,
- {'name': source});
- compiler.reportMessage(
- compiler.spanFromSpannable(seenNamedArguments[source]),
- MessageKind.EXISTING_DEFINITION.error({'name': source}),
- Diagnostic.INFO);
+ seenNamedArguments[source]);
} else {
seenNamedArguments[source] = namedArgument;
}
@@ -3333,12 +3335,16 @@ class TypedefResolverVisitor extends TypeDefinitionVisitor {
scope = new TypeDeclarationScope(scope, element);
resolveTypeVariableBounds(node.typeParameters);
- element.functionSignature = SignatureResolver.analyze(
+ FunctionSignature signature = SignatureResolver.analyze(
ngeoffray 2013/09/16 16:25:27 I would have thought that SignatureResolver would
compiler, node.formals, node.returnType, element,
defaultValuesAllowed: false);
- element.alias = compiler.computeFunctionType(
- element, element.functionSignature);
+ scope = new MethodScope(scope, element);
+ signature.forEachParameter((Element element) {
+ defineElement(element.parseNode(compiler), element);
+ });
+
+ element.alias = compiler.computeFunctionType(element, signature);
// TODO(johnniwinther): Check for cyclic references in the typedef alias.
}
« no previous file with comments | « no previous file | tests/co19/co19-dart2js.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698