From 4aa37691a1a87cda0476965207e6b00af0fe0ae3 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 18 Dec 2014 16:37:50 -0800 Subject: [PATCH] Fixed issue where the second type's signature having type parameters would not cause an error. --- src/compiler/checker.ts | 8 +++---- ...ndNonGenericInheritedSignature1.errors.txt | 17 +++++++++++++ ...ericAndNonGenericInheritedSignature1.types | 24 ------------------- 3 files changed, 21 insertions(+), 28 deletions(-) create mode 100644 tests/baselines/reference/genericAndNonGenericInheritedSignature1.errors.txt delete mode 100644 tests/baselines/reference/genericAndNonGenericInheritedSignature1.types diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index b1559f8dd13..d4ce2e6da9a 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -4016,7 +4016,7 @@ module ts { result &= related; } } - else if (source.typeParameters || source.typeParameters) { + else if (source.typeParameters || target.typeParameters) { return Ternary.False; } // Spec 1.0 Section 3.8.3 & 3.8.4: @@ -5244,8 +5244,8 @@ module ts { // Return the contextual signature for a given expression node. A contextual type provides a // contextual signature if it has a single call signature and if that call signature is non-generic. // If the contextual type is a union type, get the signature from each type possible and if they are - // all identical ignoring their return type, the result is same signature but with return type as - // union type of return types from these signatures + // all identical ignoring their return type, the result is same signature but with a union type of + // the return types of these signatures function getContextualSignature(node: FunctionExpression | MethodDeclaration): Signature { Debug.assert(node.kind !== SyntaxKind.MethodDeclaration || isObjectLiteralMethod(node)); var type = isObjectLiteralMethod(node) @@ -5274,7 +5274,7 @@ module ts { signatureList = [signature]; } else if (!compareSignatures(signatureList[0], signature, /*compareReturnTypes*/ false, compareTypes)) { - // Signatures arent identical, do not use + // Signatures aren't identical, do not use return undefined; } else { diff --git a/tests/baselines/reference/genericAndNonGenericInheritedSignature1.errors.txt b/tests/baselines/reference/genericAndNonGenericInheritedSignature1.errors.txt new file mode 100644 index 00000000000..63ff9d9313e --- /dev/null +++ b/tests/baselines/reference/genericAndNonGenericInheritedSignature1.errors.txt @@ -0,0 +1,17 @@ +tests/cases/compiler/genericAndNonGenericInheritedSignature1.ts(7,11): error TS2320: Interface 'Hello' cannot simultaneously extend types 'Foo' and 'Bar'. + Named properties 'f' of types 'Foo' and 'Bar' are not identical. + + +==== tests/cases/compiler/genericAndNonGenericInheritedSignature1.ts (1 errors) ==== + interface Foo { + f(x: any): any; + } + interface Bar { + f(x: T): T; + } + interface Hello extends Foo, Bar { + ~~~~~ +!!! error TS2320: Interface 'Hello' cannot simultaneously extend types 'Foo' and 'Bar'. +!!! error TS2320: Named properties 'f' of types 'Foo' and 'Bar' are not identical. + } + \ No newline at end of file diff --git a/tests/baselines/reference/genericAndNonGenericInheritedSignature1.types b/tests/baselines/reference/genericAndNonGenericInheritedSignature1.types deleted file mode 100644 index 939cbfa612f..00000000000 --- a/tests/baselines/reference/genericAndNonGenericInheritedSignature1.types +++ /dev/null @@ -1,24 +0,0 @@ -=== tests/cases/compiler/genericAndNonGenericInheritedSignature1.ts === -interface Foo { ->Foo : Foo - - f(x: any): any; ->f : (x: any) => any ->x : any -} -interface Bar { ->Bar : Bar - - f(x: T): T; ->f : (x: T) => T ->T : T ->x : T ->T : T ->T : T -} -interface Hello extends Foo, Bar { ->Hello : Hello ->Foo : Foo ->Bar : Bar -} -