281 lines
5 KiB
Text
281 lines
5 KiB
Text
=== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSignatureAssignabilityInInheritance4.ts ===
|
|
// checking subtype relations for function types as it relates to contextual signature instantiation
|
|
|
|
class Base { foo: string; }
|
|
>Base : Base
|
|
>foo : string
|
|
|
|
class Derived extends Base { bar: string; }
|
|
>Derived : Derived
|
|
>Base : Base
|
|
>bar : string
|
|
|
|
class Derived2 extends Derived { baz: string; }
|
|
>Derived2 : Derived2
|
|
>Derived : Derived
|
|
>baz : string
|
|
|
|
class OtherDerived extends Base { bing: string; }
|
|
>OtherDerived : OtherDerived
|
|
>Base : Base
|
|
>bing : string
|
|
|
|
interface A { // T
|
|
>A : A
|
|
|
|
// M's
|
|
a: <T>(x: T) => T[];
|
|
>a : <T>(x: T) => T[]
|
|
>T : T
|
|
>x : T
|
|
>T : T
|
|
>T : T
|
|
|
|
a2: <T>(x: T) => string[];
|
|
>a2 : <T>(x: T) => string[]
|
|
>T : T
|
|
>x : T
|
|
>T : T
|
|
|
|
a3: <T>(x: T) => void;
|
|
>a3 : <T>(x: T) => void
|
|
>T : T
|
|
>x : T
|
|
>T : T
|
|
|
|
a4: <T,U>(x: T, y: U) => string;
|
|
>a4 : <T, U>(x: T, y: U) => string
|
|
>T : T
|
|
>U : U
|
|
>x : T
|
|
>T : T
|
|
>y : U
|
|
>U : U
|
|
|
|
a5: <T,U>(x: (arg: T) => U) => T;
|
|
>a5 : <T, U>(x: (arg: T) => U) => T
|
|
>T : T
|
|
>U : U
|
|
>x : (arg: T) => U
|
|
>arg : T
|
|
>T : T
|
|
>U : U
|
|
>T : T
|
|
|
|
a6: <T extends Base>(x: (arg: T) => Derived) => T;
|
|
>a6 : <T extends Base>(x: (arg: T) => Derived) => T
|
|
>T : T
|
|
>Base : Base
|
|
>x : (arg: T) => Derived
|
|
>arg : T
|
|
>T : T
|
|
>Derived : Derived
|
|
>T : T
|
|
|
|
a11: <T>(x: { foo: T }, y: { foo: T; bar: T }) => Base;
|
|
>a11 : <T>(x: { foo: T; }, y: { foo: T; bar: T; }) => Base
|
|
>T : T
|
|
>x : { foo: T; }
|
|
>foo : T
|
|
>T : T
|
|
>y : { foo: T; bar: T; }
|
|
>foo : T
|
|
>T : T
|
|
>bar : T
|
|
>T : T
|
|
>Base : Base
|
|
|
|
a15: <T>(x: { a: T; b: T }) => T[];
|
|
>a15 : <T>(x: { a: T; b: T; }) => T[]
|
|
>T : T
|
|
>x : { a: T; b: T; }
|
|
>a : T
|
|
>T : T
|
|
>b : T
|
|
>T : T
|
|
>T : T
|
|
|
|
a16: <T extends Base>(x: { a: T; b: T }) => T[];
|
|
>a16 : <T extends Base>(x: { a: T; b: T; }) => T[]
|
|
>T : T
|
|
>Base : Base
|
|
>x : { a: T; b: T; }
|
|
>a : T
|
|
>T : T
|
|
>b : T
|
|
>T : T
|
|
>T : T
|
|
|
|
a17: {
|
|
>a17 : { <T extends Derived>(x: (a: T) => T): T[]; <T extends Base>(x: (a: T) => T): T[]; }
|
|
|
|
<T extends Derived>(x: (a: T) => T): T[];
|
|
>T : T
|
|
>Derived : Derived
|
|
>x : (a: T) => T
|
|
>a : T
|
|
>T : T
|
|
>T : T
|
|
>T : T
|
|
|
|
<T extends Base>(x: (a: T) => T): T[];
|
|
>T : T
|
|
>Base : Base
|
|
>x : (a: T) => T
|
|
>a : T
|
|
>T : T
|
|
>T : T
|
|
>T : T
|
|
|
|
};
|
|
a18: {
|
|
>a18 : { (x: { <T extends Derived>(a: T): T; <T extends Base>(a: T): T; }): any[]; (x: { <T extends Derived2>(a: T): T; <T extends Base>(a: T): T; }): any[]; }
|
|
|
|
(x: {
|
|
>x : { <T extends Derived>(a: T): T; <T extends Base>(a: T): T; }
|
|
|
|
<T extends Derived>(a: T): T;
|
|
>T : T
|
|
>Derived : Derived
|
|
>a : T
|
|
>T : T
|
|
>T : T
|
|
|
|
<T extends Base>(a: T): T;
|
|
>T : T
|
|
>Base : Base
|
|
>a : T
|
|
>T : T
|
|
>T : T
|
|
|
|
}): any[];
|
|
(x: {
|
|
>x : { <T extends Derived2>(a: T): T; <T extends Base>(a: T): T; }
|
|
|
|
<T extends Derived2>(a: T): T;
|
|
>T : T
|
|
>Derived2 : Derived2
|
|
>a : T
|
|
>T : T
|
|
>T : T
|
|
|
|
<T extends Base>(a: T): T;
|
|
>T : T
|
|
>Base : Base
|
|
>a : T
|
|
>T : T
|
|
>T : T
|
|
|
|
}): any[];
|
|
};
|
|
}
|
|
|
|
// S's
|
|
interface I extends A {
|
|
>I : I
|
|
>A : A
|
|
|
|
// N's
|
|
a: <T>(x: T) => T[]; // ok, instantiation of N is a subtype of M, T is number
|
|
>a : <T>(x: T) => T[]
|
|
>T : T
|
|
>x : T
|
|
>T : T
|
|
>T : T
|
|
|
|
a2: <T>(x: T) => string[]; // ok
|
|
>a2 : <T>(x: T) => string[]
|
|
>T : T
|
|
>x : T
|
|
>T : T
|
|
|
|
a3: <T>(x: T) => T; // ok since Base returns void
|
|
>a3 : <T>(x: T) => T
|
|
>T : T
|
|
>x : T
|
|
>T : T
|
|
>T : T
|
|
|
|
a4: <T, U>(x: T, y: U) => string; // ok, instantiation of N is a subtype of M, T is string, U is number
|
|
>a4 : <T, U>(x: T, y: U) => string
|
|
>T : T
|
|
>U : U
|
|
>x : T
|
|
>T : T
|
|
>y : U
|
|
>U : U
|
|
|
|
a5: <T, U>(x: (arg: T) => U) => T; // ok, U is in a parameter position so inferences can be made
|
|
>a5 : <T, U>(x: (arg: T) => U) => T
|
|
>T : T
|
|
>U : U
|
|
>x : (arg: T) => U
|
|
>arg : T
|
|
>T : T
|
|
>U : U
|
|
>T : T
|
|
|
|
a6: <T extends Base, U extends Derived>(x: (arg: T) => U) => T; // ok, same as a5 but with object type hierarchy
|
|
>a6 : <T extends Base, U extends Derived>(x: (arg: T) => U) => T
|
|
>T : T
|
|
>Base : Base
|
|
>U : U
|
|
>Derived : Derived
|
|
>x : (arg: T) => U
|
|
>arg : T
|
|
>T : T
|
|
>U : U
|
|
>T : T
|
|
|
|
a11: <T, U>(x: { foo: T }, y: { foo: U; bar: U }) => Base; // ok
|
|
>a11 : <T, U>(x: { foo: T; }, y: { foo: U; bar: U; }) => Base
|
|
>T : T
|
|
>U : U
|
|
>x : { foo: T; }
|
|
>foo : T
|
|
>T : T
|
|
>y : { foo: U; bar: U; }
|
|
>foo : U
|
|
>U : U
|
|
>bar : U
|
|
>U : U
|
|
>Base : Base
|
|
|
|
a15: <U, V>(x: { a: U; b: V; }) => U[]; // ok, T = U, T = V
|
|
>a15 : <U, V>(x: { a: U; b: V; }) => U[]
|
|
>U : U
|
|
>V : V
|
|
>x : { a: U; b: V; }
|
|
>a : U
|
|
>U : U
|
|
>b : V
|
|
>V : V
|
|
>U : U
|
|
|
|
a16: <T>(x: { a: T; b: T }) => T[]; // ok, more general parameter type
|
|
>a16 : <T>(x: { a: T; b: T; }) => T[]
|
|
>T : T
|
|
>x : { a: T; b: T; }
|
|
>a : T
|
|
>T : T
|
|
>b : T
|
|
>T : T
|
|
>T : T
|
|
|
|
a17: <T>(x: (a: T) => T) => T[]; // ok
|
|
>a17 : <T>(x: (a: T) => T) => T[]
|
|
>T : T
|
|
>x : (a: T) => T
|
|
>a : T
|
|
>T : T
|
|
>T : T
|
|
>T : T
|
|
|
|
a18: (x: <T>(a: T) => T) => any[]; // ok
|
|
>a18 : (x: <T>(a: T) => T) => any[]
|
|
>x : <T>(a: T) => T
|
|
>T : T
|
|
>a : T
|
|
>T : T
|
|
>T : T
|
|
}
|