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

Unified Diff: lib/compiler/implementation/dart_backend/renamer.dart

Issue 10828121: Improve renaming of constructors and factories. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 5 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: lib/compiler/implementation/dart_backend/renamer.dart
diff --git a/lib/compiler/implementation/dart_backend/renamer.dart b/lib/compiler/implementation/dart_backend/renamer.dart
index 831330ed9aae0756f3f031894a5baca2a13964c7..041871253db97b427724b2821dad606a0976c209 100644
--- a/lib/compiler/implementation/dart_backend/renamer.dart
+++ b/lib/compiler/implementation/dart_backend/renamer.dart
@@ -78,13 +78,23 @@ class ConflictingRenamer extends Renamer {
String renameType(Type type) => renameElement(type.element);
String renameIdentifier(Identifier node) {
- if (context.isGenerativeConstructor()) {
- // This is either a named constructor or simple one.
- // TODO(smok): Check if resolver can help us identifying named
- // constructors.
- var enclosingClass = context.getEnclosingClass();
- if (node.token.slowToString() == context.name.slowToString()
- || enclosingClass.name.slowToString() == node.token.slowToString()) {
+ if (context.isGenerativeConstructor() || context.isFactoryConstructor()) {
+ // Two complicated cases for class/interface renaming:
+ // 1) class which implements constructors of other interfaces, but not
+ // implements interfaces themselves:
+ // 0.dart: class C { I(); }
+ // 1.dart and 2.dart: interface I default C { I(); }
+ // now we have to duplicate our I() constructor in C class with
+ // proper names.
+ // 2) (even worse for us):
+ // 0.dart: class C { C(); }
+ // 1.dart: interface C default p0.C { C(); }
+ // the second case is just a bug now.
+ final enclosingClass = context.getEnclosingClass();
+ if (node.token.slowToString() == enclosingClass.name.slowToString()) {
+ // TODO: distinguish the case of constructor vs. nested named closure
+ // (see function_syntax_test).
+ // TODO: fix the bugs above and turn if into the assert.
return renameElement(enclosingClass);
}
}
« no previous file with comments | « no previous file | lib/compiler/implementation/tree/unparser.dart » ('j') | lib/compiler/implementation/tree/unparser.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698