diff --git a/packages/compiler/src/render3/r3_factory.ts b/packages/compiler/src/render3/r3_factory.ts index c1cb7c923b..ef075ebf78 100644 --- a/packages/compiler/src/render3/r3_factory.ts +++ b/packages/compiler/src/render3/r3_factory.ts @@ -71,12 +71,6 @@ export interface R3ConstructorFactoryMetadata { export enum R3FactoryDelegateType { Class, Function, - Factory, -} - -export interface R3DelegatedFactoryMetadata extends R3ConstructorFactoryMetadata { - delegate: o.Expression; - delegateType: R3FactoryDelegateType.Factory; } export interface R3DelegatedFnOrClassMetadata extends R3ConstructorFactoryMetadata { @@ -89,8 +83,8 @@ export interface R3ExpressionFactoryMetadata extends R3ConstructorFactoryMetadat expression: o.Expression; } -export type R3FactoryMetadata = R3ConstructorFactoryMetadata|R3DelegatedFactoryMetadata| - R3DelegatedFnOrClassMetadata|R3ExpressionFactoryMetadata; +export type R3FactoryMetadata = + R3ConstructorFactoryMetadata|R3DelegatedFnOrClassMetadata|R3ExpressionFactoryMetadata; export enum R3FactoryTarget { Directive = 0, @@ -239,20 +233,7 @@ export function compileFactoryFunction(meta: R3FactoryMetadata): R3FactoryFn { return r; } - if (isDelegatedMetadata(meta) && meta.delegateType === R3FactoryDelegateType.Factory) { - const delegateFactory = o.variable(`ɵ${meta.name}_BaseFactory`); - const getFactoryOf = o.importExpr(R3.getFactoryOf); - if (meta.delegate.isEquivalent(meta.internalType)) { - throw new Error(`Illegal state: compiling factory that delegates to itself`); - } - const delegateFactoryStmt = - delegateFactory.set(getFactoryOf.callFn([meta.delegate])).toDeclStmt(o.INFERRED_TYPE, [ - o.StmtModifier.Exported, o.StmtModifier.Final - ]); - - statements.push(delegateFactoryStmt); - retExpr = makeConditionalFactory(delegateFactory.callFn([])); - } else if (isDelegatedMetadata(meta)) { + if (isDelegatedMetadata(meta)) { // This type is created with a delegated factory. If a type parameter is not specified, call // the factory instead. const delegateArgs = @@ -418,8 +399,7 @@ export function dependenciesFromGlobalMetadata( return deps; } -function isDelegatedMetadata(meta: R3FactoryMetadata): meta is R3DelegatedFactoryMetadata| - R3DelegatedFnOrClassMetadata { +function isDelegatedMetadata(meta: R3FactoryMetadata): meta is R3DelegatedFnOrClassMetadata { return (meta as any).delegateType !== undefined; } diff --git a/packages/compiler/src/render3/r3_identifiers.ts b/packages/compiler/src/render3/r3_identifiers.ts index 30b5005bad..5362f17979 100644 --- a/packages/compiler/src/render3/r3_identifiers.ts +++ b/packages/compiler/src/render3/r3_identifiers.ts @@ -313,11 +313,6 @@ export class Identifiers { static listener: o.ExternalReference = {name: 'ɵɵlistener', moduleName: CORE}; - static getFactoryOf: o.ExternalReference = { - name: 'ɵɵgetFactoryOf', - moduleName: CORE, - }; - static getInheritedFactory: o.ExternalReference = { name: 'ɵɵgetInheritedFactory', moduleName: CORE, diff --git a/packages/core/src/di/jit/environment.ts b/packages/core/src/di/jit/environment.ts index a11e03998d..c77c0e1f1a 100644 --- a/packages/core/src/di/jit/environment.ts +++ b/packages/core/src/di/jit/environment.ts @@ -5,13 +5,8 @@ * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ - -import {Type} from '../../interface/type'; -import {isForwardRef, resolveForwardRef} from '../forward_ref'; import {ɵɵinject, ɵɵinvalidFactoryDep} from '../injector_compatibility'; -import {getInjectableDef, getInjectorDef, ɵɵdefineInjectable, ɵɵdefineInjector} from '../interface/defs'; - - +import {ɵɵdefineInjectable, ɵɵdefineInjector} from '../interface/defs'; /** * A mapping of the @angular/core API surface used in generated expressions to the actual symbols. @@ -22,23 +17,5 @@ export const angularCoreDiEnv: {[name: string]: Function} = { 'ɵɵdefineInjectable': ɵɵdefineInjectable, 'ɵɵdefineInjector': ɵɵdefineInjector, 'ɵɵinject': ɵɵinject, - 'ɵɵgetFactoryOf': getFactoryOf, 'ɵɵinvalidFactoryDep': ɵɵinvalidFactoryDep, }; - -function getFactoryOf(type: Type): ((type?: Type) => T)|null { - const typeAny = type as any; - - if (isForwardRef(type)) { - return (() => { - const factory = getFactoryOf(resolveForwardRef(typeAny)); - return factory ? factory() : null; - }) as any; - } - - const def = getInjectableDef(typeAny) || getInjectorDef(typeAny); - if (!def || def.factory === undefined) { - return null; - } - return def.factory; -} diff --git a/packages/core/src/render3/jit/environment.ts b/packages/core/src/render3/jit/environment.ts index 289f1f6e1e..8486e40655 100644 --- a/packages/core/src/render3/jit/environment.ts +++ b/packages/core/src/render3/jit/environment.ts @@ -37,7 +37,6 @@ export const angularCoreEnv: {[name: string]: Function} = 'ɵɵdefineNgModule': r3.ɵɵdefineNgModule, 'ɵɵdefinePipe': r3.ɵɵdefinePipe, 'ɵɵdirectiveInject': r3.ɵɵdirectiveInject, - 'ɵɵgetFactoryOf': r3.ɵɵgetFactoryOf, 'ɵɵgetInheritedFactory': r3.ɵɵgetInheritedFactory, 'ɵɵinject': ɵɵinject, 'ɵɵinjectAttribute': r3.ɵɵinjectAttribute,