fix(ivy): ensure factory statements are emitted correctly (#25406)

PR Close #25406
This commit is contained in:
Alex Rickabaugh
2018-08-10 11:26:41 +01:00
committed by Matias Niemelä
parent 7500f0eafb
commit 61218f5f0b

View File

@ -181,8 +181,10 @@ export function compileFactoryFunction(meta: R3FactoryMetadata):
} else { } else {
const baseFactory = o.variable(`ɵ${meta.name}_BaseFactory`); const baseFactory = o.variable(`ɵ${meta.name}_BaseFactory`);
const getInheritedFactory = o.importExpr(R3.getInheritedFactory); const getInheritedFactory = o.importExpr(R3.getInheritedFactory);
const baseFactoryStmt = baseFactory.set(getInheritedFactory.callFn([meta.type])) const baseFactoryStmt =
.toDeclStmt(o.INFERRED_TYPE, [o.StmtModifier.Final]); baseFactory.set(getInheritedFactory.callFn([meta.type])).toDeclStmt(o.INFERRED_TYPE, [
o.StmtModifier.Exported, o.StmtModifier.Final
]);
statements.push(baseFactoryStmt); statements.push(baseFactoryStmt);
// There is no constructor, use the base class' factory to construct typeForCtor. // There is no constructor, use the base class' factory to construct typeForCtor.
@ -206,8 +208,10 @@ export function compileFactoryFunction(meta: R3FactoryMetadata):
if (meta.delegate.isEquivalent(meta.type)) { if (meta.delegate.isEquivalent(meta.type)) {
throw new Error(`Illegal state: compiling factory that delegates to itself`); throw new Error(`Illegal state: compiling factory that delegates to itself`);
} }
const delegateFactoryStmt = delegateFactory.set(getFactoryOf.callFn([meta.delegate])) const delegateFactoryStmt =
.toDeclStmt(o.INFERRED_TYPE, [o.StmtModifier.Final]); delegateFactory.set(getFactoryOf.callFn([meta.delegate])).toDeclStmt(o.INFERRED_TYPE, [
o.StmtModifier.Exported, o.StmtModifier.Final
]);
statements.push(delegateFactoryStmt); statements.push(delegateFactoryStmt);
const r = makeConditionalFactory(delegateFactory.callFn([])); const r = makeConditionalFactory(delegateFactory.callFn([]));