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

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

Issue 19754002: Rewrite how we handle synthesized constructors in the compiler. This was motivated by issue https:/… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 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: sdk/lib/_internal/compiler/implementation/elements/modelx.dart
===================================================================
--- sdk/lib/_internal/compiler/implementation/elements/modelx.dart (revision 25147)
+++ sdk/lib/_internal/compiler/implementation/elements/modelx.dart (working copy)
@@ -1398,63 +1398,31 @@
* constructors for mixin applications.
*/
class SynthesizedConstructorElementX extends FunctionElementX {
- /// The target constructor if this synthetic constructor is a forwarding
- /// constructor in a mixin application.
- final FunctionElement target;
+ final FunctionElement superMember;
- SynthesizedConstructorElementX(Element enclosing)
- : super(enclosing.name, ElementKind.GENERATIVE_CONSTRUCTOR,
- Modifiers.EMPTY, enclosing),
- target = null;
+ SynthesizedConstructorElementX(SourceString name,
+ this.superMember,
+ Element enclosing)
+ : super(name,
+ ElementKind.GENERATIVE_CONSTRUCTOR,
+ Modifiers.EMPTY,
+ enclosing);
- SynthesizedConstructorElementX.forDefault(Element enclosing,
- Compiler compiler)
- : super(const SourceString(''), ElementKind.GENERATIVE_CONSTRUCTOR,
- Modifiers.EMPTY, enclosing),
- target = null {
- // TODO(karlklose): get rid of the fake AST.
- type = new FunctionType(this,
- compiler.types.voidType,
- const Link<DartType>(),
- const Link<DartType>(),
- const Link<SourceString>(),
- const Link<DartType>());
- cachedNode = new FunctionExpression(
- new Identifier(enclosing.position()),
- new NodeList.empty(),
- new Block(new NodeList.empty()),
- null, Modifiers.EMPTY, null, null);
- }
+ SynthesizedConstructorElementX.forDefault(superMember, Element enclosing)
+ : this(const SourceString(''), superMember, enclosing);
- /**
- * Create synthetic constructor that directly forwards to a constructor in the
- * super class of a mixin application.
- *
- * In a mixin application `Base with M`, any constructor defined in `Base` is
- * available as if they were a constructor defined in the mixin application
- * with the same formal parameters that calls the constructor in the super
- * class via a `super` initializer (see Ch. 9.1 in the specification).
- */
- SynthesizedConstructorElementX.forwarding(SourceString name, this.target,
- Element enclosing)
- : super(name, ElementKind.GENERATIVE_CONSTRUCTOR, Modifiers.EMPTY,
- enclosing);
-
Token position() => enclosingElement.position();
bool get isSynthesized => true;
- bool get isForwardingConstructor => target != null;
+ FunctionElement get targetConstructor => superMember;
- FunctionElement get targetConstructor => target;
-
FunctionSignature computeSignature(compiler) {
- if (target != null) {
- return target.computeSignature(compiler);
- } else {
- assert(cachedNode != null);
- return super.computeSignature(compiler);
+ if (superMember.isErroneous()) {
+ return compiler.objectClass.localLookup(
+ const SourceString('')).computeSignature(compiler);
}
+ return superMember.computeSignature(compiler);
}
get declaration => this;
@@ -1604,13 +1572,6 @@
return this;
}
- void addDefaultConstructorIfNeeded(Compiler compiler) {
- if (hasConstructor) return;
- FunctionElement constructor =
- new SynthesizedConstructorElementX.forDefault(this, compiler);
- setDefaultConstructor(constructor, compiler);
- }
-
void setDefaultConstructor(FunctionElement constructor, Compiler compiler);
void addBackendMember(Element member) {

Powered by Google App Engine
This is Rietveld 408576698