From dc854158ab50efe69609b2f24c119219872ca71b Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Fri, 10 Jul 2015 11:48:09 -0700 Subject: [PATCH] Made check more readable --- src/compiler/checker.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index feb76446e1a..58f858e4d6d 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -4875,17 +4875,19 @@ namespace ts { let targetReturnType = getReturnTypeOfSignature(target); if (targetReturnType === voidType) return result; let sourceReturnType = getReturnTypeOfSignature(source); - - let targetReturnDecl = targetReturnType.symbol && getDeclarationOfKind(targetReturnType.symbol, SyntaxKind.ClassDeclaration); + let sourceReturnDecl = sourceReturnType.symbol && getDeclarationOfKind(sourceReturnType.symbol, SyntaxKind.ClassDeclaration); - - if(sourceReturnDecl && sourceReturnDecl.flags & NodeFlags.Abstract && (!targetReturnDecl || !(targetReturnDecl.flags & NodeFlags.Abstract))) { - if(reportErrors) { + let targetReturnDecl = targetReturnType.symbol && getDeclarationOfKind(targetReturnType.symbol, SyntaxKind.ClassDeclaration); + let sourceIsAbstract = sourceReturnDecl && sourceReturnDecl.flags & NodeFlags.Abstract; + let targetIsAbstract = targetReturnDecl && targetReturnDecl.flags & NodeFlags.Abstract; + + if (sourceIsAbstract && !targetIsAbstract) { + if (reportErrors) { reportError(Diagnostics.Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type); } return Ternary.False; } - + return result & isRelatedTo(sourceReturnType, targetReturnType, reportErrors); }