diff --git a/packages/core/src/render3/di.ts b/packages/core/src/render3/di.ts index a539e0972b..28eced1bda 100644 --- a/packages/core/src/render3/di.ts +++ b/packages/core/src/render3/di.ts @@ -777,13 +777,17 @@ export function getFactoryOf(type: Type): ((type?: Type) => T)|null { } export function getInheritedFactory(type: Type): (type: Type) => T { - debugger; const proto = Object.getPrototypeOf(type.prototype).constructor as Type; const factory = getFactoryOf(proto); - if (factory === null) { - throw new Error(`Type ${proto.name} does not support inheritance`); + if (factory !== null) { + return factory; + } else { + // There is no factory defined. Either this was improper usage of inheritance + // (no Angular decorator on the superclass) or there is no constructor at all + // in the inheritance chain. Since the two cases cannot be distinguished, the + // latter has to be assumed. + return (t) => new t(); } - return factory; } class TemplateRef implements viewEngine.TemplateRef {