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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/dart_backend/placeholder_collector.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
« no previous file with comments | « no previous file | sdk/lib/_internal/compiler/implementation/resolution/members.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 dart_backend; 5 part of dart_backend;
6 6
7 class LocalPlaceholder { 7 class LocalPlaceholder {
8 final String identifier; 8 final String identifier;
9 final Set<Node> nodes; 9 final Set<Node> nodes;
10 LocalPlaceholder(this.identifier) : nodes = new Set<Node>(); 10 LocalPlaceholder(this.identifier) : nodes = new Set<Node>();
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 makeVarDeclarationTypePlaceholder(definitions); 237 makeVarDeclarationTypePlaceholder(definitions);
238 } else { 238 } else {
239 assert(element is ClassElement || element is TypedefElement); 239 assert(element is ClassElement || element is TypedefElement);
240 } 240 }
241 currentLocalPlaceholders = new Map<String, LocalPlaceholder>(); 241 currentLocalPlaceholders = new Map<String, LocalPlaceholder>();
242 compiler.withCurrentElement(element, () { 242 compiler.withCurrentElement(element, () {
243 elementNode.accept(this); 243 elementNode.accept(this);
244 }); 244 });
245 } 245 }
246 246
247 // TODO(karlklose): should we create placeholders for these?
248 bool isTypedefParameter(Element element) {
249 return element != null &&
250 element.enclosingElement != null &&
251 element.enclosingElement.isTypedef();
252 }
253
254 void tryMakeLocalPlaceholder(Element element, Identifier node) { 247 void tryMakeLocalPlaceholder(Element element, Identifier node) {
255 bool isNamedOptionalParameter() { 248 bool isNamedOptionalParameter() {
256 FunctionElement function = element.enclosingElement; 249 FunctionElement function = element.enclosingElement;
257 FunctionSignature signature = function.functionSignature; 250 FunctionSignature signature = function.functionSignature;
258 if (!signature.optionalParametersAreNamed) return false; 251 if (!signature.optionalParametersAreNamed) return false;
259 for (Element parameter in signature.optionalParameters) { 252 for (Element parameter in signature.optionalParameters) {
260 if (identical(parameter, element)) return true; 253 if (identical(parameter, element)) return true;
261 } 254 }
262 return false; 255 return false;
263 } 256 }
264 257
265 // TODO(smok): Maybe we should rename privates as well, their privacy 258 // TODO(smok): Maybe we should rename privates as well, their privacy
266 // should not matter if they are local vars. 259 // should not matter if they are local vars.
267 if (node.source.isPrivate()) return; 260 if (node.source.isPrivate()) return;
268 if (element.isParameter() && isNamedOptionalParameter() && 261 if (element.isParameter() && isNamedOptionalParameter()) {
269 !isTypedefParameter(element)) {
270 currentFunctionScope.registerParameter(node); 262 currentFunctionScope.registerParameter(node);
271 } else if (Elements.isLocal(element) && !isTypedefParameter(element)) { 263 } else if (Elements.isLocal(element)) {
272 makeLocalPlaceholder(node); 264 makeLocalPlaceholder(node);
273 } 265 }
274 } 266 }
275 267
276 void tryMakeMemberPlaceholder(Identifier node) { 268 void tryMakeMemberPlaceholder(Identifier node) {
277 assert(node != null); 269 assert(node != null);
278 if (node.source.isPrivate()) return; 270 if (node.source.isPrivate()) return;
279 if (node is Operator) return; 271 if (node is Operator) return;
280 final identifier = node.source.slowToString(); 272 final identifier = node.source.slowToString();
281 if (fixedMemberNames.contains(identifier)) return; 273 if (fixedMemberNames.contains(identifier)) return;
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
634 626
635 visitBlock(Block node) { 627 visitBlock(Block node) {
636 for (Node statement in node.statements.nodes) { 628 for (Node statement in node.statements.nodes) {
637 if (statement is VariableDefinitions) { 629 if (statement is VariableDefinitions) {
638 makeVarDeclarationTypePlaceholder(statement); 630 makeVarDeclarationTypePlaceholder(statement);
639 } 631 }
640 } 632 }
641 node.visitChildren(this); 633 node.visitChildren(this);
642 } 634 }
643 } 635 }
OLDNEW
« no previous file with comments | « no previous file | sdk/lib/_internal/compiler/implementation/resolution/members.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698