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

Unified Diff: sdk/lib/_internal/compiler/implementation/dart_backend/placeholder_collector.dart

Issue 15959017: Fix issue with dart2dart translation of parameters (collision risk). (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 7 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/dart_backend/placeholder_collector.dart
diff --git a/sdk/lib/_internal/compiler/implementation/dart_backend/placeholder_collector.dart b/sdk/lib/_internal/compiler/implementation/dart_backend/placeholder_collector.dart
index 2d67ace7e157e138206c479d950dce8e0e8db818..83a067fe10a9ff36285e7a82b83077a91660a57b 100644
--- a/sdk/lib/_internal/compiler/implementation/dart_backend/placeholder_collector.dart
+++ b/sdk/lib/_internal/compiler/implementation/dart_backend/placeholder_collector.dart
@@ -48,7 +48,15 @@ class SendVisitor extends ResolvedVisitor {
SendVisitor(this.collector, TreeElements elements) : super(elements);
- visitOperatorSend(Send node) {}
+ visitOperatorSend(Send node) {
+ if (node.isParameterCheck) {
+ final element = elements[node.receiver];
+ if (element != null) {
+ collector.tryMakeLocalPlaceholder(element, node.receiver);
+ }
+ }
+ }
+
visitForeignSend(Send node) {}
visitSuperSend(Send node) {
@@ -236,9 +244,11 @@ class PlaceholderCollector extends Visitor {
}
void tryMakeLocalPlaceholder(Element element, Identifier node) {
- bool isOptionalParameter() {
+ bool isNamedOptionalParameter() {
FunctionElement function = element.enclosingElement;
- for (Element parameter in function.functionSignature.optionalParameters) {
+ FunctionSignature signature = function.functionSignature;
+ if (!signature.optionalParametersAreNamed) return false;
+ for (Element parameter in signature.optionalParameters) {
if (identical(parameter, element)) return true;
}
return false;
@@ -247,7 +257,7 @@ class PlaceholderCollector extends Visitor {
// TODO(smok): Maybe we should rename privates as well, their privacy
// should not matter if they are local vars.
if (node.source.isPrivate()) return;
- if (element.isParameter() && isOptionalParameter()) {
+ if (element.isParameter() && isNamedOptionalParameter()) {
currentFunctionScope.registerParameter(node);
} else if (Elements.isLocal(element)) {
makeLocalPlaceholder(node);

Powered by Google App Engine
This is Rietveld 408576698