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

Side by Side Diff: pkg/analyzer/lib/src/generated/resolver.dart

Issue 688253004: Prevent conflict between parameter names and local function names. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 1 month 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 | pkg/analyzer/test/generated/compile_time_error_code_test.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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 library engine.resolver; 5 library engine.resolver;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 import "dart:math" as math; 8 import "dart:math" as math;
9 9
10 import 'java_core.dart'; 10 import 'java_core.dart';
(...skipping 5276 matching lines...) Expand 10 before | Expand all | Expand 10 after
5287 5287
5288 /** 5288 /**
5289 * Define the parameters for the given function in the scope that encloses thi s function. 5289 * Define the parameters for the given function in the scope that encloses thi s function.
5290 */ 5290 */
5291 void defineParameters() { 5291 void defineParameters() {
5292 if (_parametersDefined) { 5292 if (_parametersDefined) {
5293 return; 5293 return;
5294 } 5294 }
5295 _parametersDefined = true; 5295 _parametersDefined = true;
5296 Scope parameterScope = enclosingScope; 5296 Scope parameterScope = enclosingScope;
5297 if (_functionElement.enclosingElement is ExecutableElement) {
5298 String name = _functionElement.name;
5299 if (name != null && !name.isEmpty) {
5300 parameterScope.define(_functionElement);
5301 }
5302 }
5303 for (ParameterElement parameter in _functionElement.parameters) { 5297 for (ParameterElement parameter in _functionElement.parameters) {
5304 if (!parameter.isInitializingFormal) { 5298 if (!parameter.isInitializingFormal) {
5305 parameterScope.define(parameter); 5299 parameterScope.define(parameter);
5306 } 5300 }
5307 } 5301 }
5308 } 5302 }
5309 } 5303 }
5310 5304
5311 /** 5305 /**
5312 * Instances of the class `FunctionTypeScope` implement the scope defined by a f unction type 5306 * Instances of the class `FunctionTypeScope` implement the scope defined by a f unction type
(...skipping 7428 matching lines...) Expand 10 before | Expand all | Expand 10 after
12741 } finally { 12735 } finally {
12742 _labelScope = outerLabelScope; 12736 _labelScope = outerLabelScope;
12743 _nameScope = outerNameScope; 12737 _nameScope = outerNameScope;
12744 } 12738 }
12745 return null; 12739 return null;
12746 } 12740 }
12747 12741
12748 @override 12742 @override
12749 Object visitFunctionDeclaration(FunctionDeclaration node) { 12743 Object visitFunctionDeclaration(FunctionDeclaration node) {
12750 ExecutableElement functionElement = node.element; 12744 ExecutableElement functionElement = node.element;
12745 if (functionElement != null &&
12746 functionElement.enclosingElement is! CompilationUnitElement) {
12747 _nameScope.define(functionElement);
12748 }
12751 Scope outerScope = _nameScope; 12749 Scope outerScope = _nameScope;
12752 try { 12750 try {
12753 if (functionElement == null) { 12751 if (functionElement == null) {
12754 AnalysisEngine.instance.logger.logInformation( 12752 AnalysisEngine.instance.logger.logInformation(
12755 "Missing element for top-level function ${node.name.name} in ${defin ingLibrary.source.fullName}", 12753 "Missing element for top-level function ${node.name.name} in ${defin ingLibrary.source.fullName}",
12756 new CaughtException(new AnalysisException(), null)); 12754 new CaughtException(new AnalysisException(), null));
12757 } else { 12755 } else {
12758 _nameScope = new FunctionScope(_nameScope, functionElement); 12756 _nameScope = new FunctionScope(_nameScope, functionElement);
12759 } 12757 }
12760 super.visitFunctionDeclaration(node); 12758 super.visitFunctionDeclaration(node);
12761 } finally { 12759 } finally {
12762 _nameScope = outerScope; 12760 _nameScope = outerScope;
12763 } 12761 }
12764 if (functionElement != null && functionElement.enclosingElement is! Compilat ionUnitElement) {
12765 _nameScope.define(functionElement);
12766 }
12767 return null; 12762 return null;
12768 } 12763 }
12769 12764
12770 @override 12765 @override
12771 Object visitFunctionExpression(FunctionExpression node) { 12766 Object visitFunctionExpression(FunctionExpression node) {
12772 if (node.parent is FunctionDeclaration) { 12767 if (node.parent is FunctionDeclaration) {
12773 // We have already created a function scope and don't need to do so again. 12768 // We have already created a function scope and don't need to do so again.
12774 super.visitFunctionExpression(node); 12769 super.visitFunctionExpression(node);
12775 } else { 12770 } else {
12776 Scope outerScope = _nameScope; 12771 Scope outerScope = _nameScope;
(...skipping 2760 matching lines...) Expand 10 before | Expand all | Expand 10 after
15537 /** 15532 /**
15538 * Return the tag that has the given identifier, or {@code null} if there is n o such tag (the 15533 * Return the tag that has the given identifier, or {@code null} if there is n o such tag (the
15539 * identifier is not defined). 15534 * identifier is not defined).
15540 * 15535 *
15541 * @return the tag that has the given identifier 15536 * @return the tag that has the given identifier
15542 */ 15537 */
15543 String getTagWithId(String identifier) { 15538 String getTagWithId(String identifier) {
15544 return idToTagMap[identifier]; 15539 return idToTagMap[identifier];
15545 } 15540 }
15546 } 15541 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/test/generated/compile_time_error_code_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698