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

Unified Diff: sdk/lib/_internal/compiler/implementation/elements/modelx.dart

Issue 18072002: Fix Element.findMyName for named constructors. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 6 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/compiler/dart2js/find_my_name_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/compiler/implementation/elements/modelx.dart
diff --git a/sdk/lib/_internal/compiler/implementation/elements/modelx.dart b/sdk/lib/_internal/compiler/implementation/elements/modelx.dart
index 0d784568cd6b717a9b2c77eb9a97cb945327d2e3..fcd8691ac586a17276ae5af2052bf9f54e3e0e83 100644
--- a/sdk/lib/_internal/compiler/implementation/elements/modelx.dart
+++ b/sdk/lib/_internal/compiler/implementation/elements/modelx.dart
@@ -176,8 +176,13 @@ class ElementX implements Element {
Token position() => null;
Token findMyName(Token token) {
- for (Token t = token; !identical(t.kind, EOF_TOKEN); t = t.next) {
- if (t.value == name) return t;
+ // We search for the token that has the name of this element.
+ // For constructors, that doesn't work because they may have
+ // named formed out of multiple tokens (named constructors) so
+ // for those we search for the class name instead.
+ String needle = isConstructor() ? enclosingElement.name : name;
+ for (Token t = token; EOF_TOKEN != t.kind; t = t.next) {
+ if (needle == t.value) return t;
}
return token;
}
« no previous file with comments | « no previous file | tests/compiler/dart2js/find_my_name_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698