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

Unified 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 side-by-side diff with in-line comments
Download patch
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 4135d0cc3585607fda7a57ae98f58db2ebdae025..fd3ab87101b0b30e7f1f1d1cc53359e0654c8927 100644
--- a/sdk/lib/_internal/compiler/implementation/resolution/members.dart
+++ b/sdk/lib/_internal/compiler/implementation/resolution/members.dart
@@ -1750,6 +1750,31 @@ 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(/*Node|SourceString*/ name,
+ Spannable definition,
+ Spannable existing) {
+ compiler.reportError(
+ definition,
+ MessageKind.DUPLICATE_DEFINITION, {'name': name});
+ compiler.reportMessage(
+ compiler.spanFromSpannable(existing),
+ MessageKind.EXISTING_DEFINITION.error({'name': name}),
+ Diagnostic.INFO);
+ }
}
/**
@@ -1942,24 +1967,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) {
@@ -2337,14 +2344,10 @@ class ResolverVisitor extends MappingVisitor<Element> {
if (namedArgument != null) {
SourceString source = namedArgument.name.source;
if (seenNamedArguments.containsKey(source)) {
- 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;
}
@@ -3356,12 +3359,17 @@ class TypedefResolverVisitor extends TypeDefinitionVisitor {
scope = new TypeDeclarationScope(scope, element);
resolveTypeVariableBounds(node.typeParameters);
- element.functionSignature = SignatureResolver.analyze(
+ FunctionSignature signature = SignatureResolver.analyze(
compiler, node.formals, node.returnType, element,
defaultValuesAllowed: false);
+ element.functionSignature = signature;
+
+ scope = new MethodScope(scope, element);
+ signature.forEachParameter((Element element) {
+ defineElement(element.parseNode(compiler), element);
+ });
- element.alias = compiler.computeFunctionType(
- element, element.functionSignature);
+ element.alias = compiler.computeFunctionType(element, signature);
void checkCyclicReference() {
var visitor = new TypedefCyclicVisitor(compiler, element);
« 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