Index: sdk/lib/_internal/compiler/implementation/resolution/members.dart |
=================================================================== |
--- sdk/lib/_internal/compiler/implementation/resolution/members.dart (revision 25107) |
+++ sdk/lib/_internal/compiler/implementation/resolution/members.dart (working copy) |
@@ -339,6 +339,11 @@ |
assert(isConstructor); |
return elements; |
} |
+ if (element.isSynthesized) { |
+ compiler.enqueuer.resolution.registerStaticUse( |
+ element.targetConstructor); |
+ return new TreeElementMapping(element); |
+ } |
if (element.isPatched) { |
checkMatchingPatchSignatures(element, element.patch); |
element = element.patch; |
@@ -2535,7 +2540,9 @@ |
{ // This entire block is temporary code per the above TODO. |
FunctionElement targetImplementation = redirectionTarget.implementation; |
FunctionExpression function = targetImplementation.parseNode(compiler); |
- if (function.body != null && function.body.asReturn() != null |
+ if (function != null |
ahe
2013/07/18 09:59:32
I think if function is null, there is a big chance
|
+ && function.body != null |
+ && function.body.asReturn() != null |
&& function.body.asReturn().isRedirectingFactoryBody) { |
unimplemented(node.expression, 'redirecting to redirecting factory'); |
} |
@@ -3272,7 +3279,23 @@ |
element.interfaces = resolveInterfaces(node.interfaces, node.superclass); |
calculateAllSupertypes(element); |
- element.addDefaultConstructorIfNeeded(compiler); |
+ if (!element.hasConstructor) { |
+ Element superMember = |
+ element.superclass.localLookup(const SourceString('')); |
+ if (superMember == null || !superMember.isGenerativeConstructor()) { |
+ ResolutionWarning warning = new ResolutionWarning( |
+ MessageKind.CANNOT_FIND_CONSTRUCTOR, |
+ {'constructorName': const SourceString('')}); |
+ compiler.reportError(node, warning); |
ahe
2013/07/18 14:32:56
Please use:
compiler.reportErrorCode(node, Messag
ngeoffray
2013/07/18 15:25:14
Done.
|
+ superMember = new ErroneousElementX( |
ahe
2013/07/18 14:32:56
I'm not sure why you include the error message in
ngeoffray
2013/07/18 15:25:14
As discussed, if the erroneous element is later us
|
+ warning.message.kind, warning.message.arguments, |
+ const SourceString(''), element); |
+ compiler.backend.registerThrowNoSuchMethod(mapping); |
+ } |
+ FunctionElement constructor = |
+ new SynthesizedConstructorElementX.forDefault(superMember, element); |
+ element.setDefaultConstructor(constructor, compiler); |
+ } |
return element.computeType(compiler); |
} |
@@ -3316,11 +3339,11 @@ |
constructor.computeSignature(compiler).parameterCount == 0; |
} |
- FunctionElement createForwardingConstructor(FunctionElement constructor, |
- ClassElement target) { |
- return new SynthesizedConstructorElementX.forwarding(constructor.name, |
- constructor, |
- target); |
+ FunctionElement createForwardingConstructor(FunctionElement target, |
+ ClassElement enclosing) { |
+ return new SynthesizedConstructorElementX(target.name, |
+ target, |
+ enclosing); |
} |
void doApplyMixinTo(MixinApplicationElement mixinApplication, |
@@ -3359,20 +3382,11 @@ |
// because they are now hidden by the mixin application. |
ClassElement superclass = supertype.element; |
superclass.forEachLocalMember((Element member) { |
- if (!member.isConstructor()) return; |
- if (member.isSynthesized && !member.isForwardingConstructor) return; |
- if (isDefaultConstructor(member)) return; |
- assert(invariant(node, !member.isFactoryConstructor(), |
- message: 'mixins cannot have factory constructors')); |
- // Skip forwarding constructors and use their target. |
- FunctionElement constructor = |
- member.isForwardingConstructor ? member.targetConstructor : member; |
- assert(invariant(node, !constructor.isForwardingConstructor)); |
+ if (!member.isGenerativeConstructor()) return; |
FunctionElement forwarder = |
- createForwardingConstructor(constructor, mixinApplication); |
+ createForwardingConstructor(member, mixinApplication); |
mixinApplication.addConstructor(forwarder); |
}); |
- mixinApplication.addDefaultConstructorIfNeeded(compiler); |
calculateAllSupertypes(mixinApplication); |
} |