// checking subtype relations for function types as it relates to contextual signature instantiation
// same as subtypingWithCallSignatures2 just with an extra level of indirection in the inheritance chain
class Base { foo: string; }
class Derived extends Base { bar: string; }
class Derived2 extends Derived { baz: string; }
class OtherDerived extends Base { bing: string; }
interface A { // T
// M's
a: (x: number) => number[];
a2: (x: number) => string[];
a3: (x: number) => void;
a4: (x: string, y: number) => string;
a5: (x: (arg: string) => number) => string;
a6: (x: (arg: Base) => Derived) => Base;
a7: (x: (arg: Base) => Derived) => (r: Base) => Derived;
a8: (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived;
a9: (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived;
a10: (...x: Derived[]) => Derived;
a11: (x: { foo: string }, y: { foo: string; bar: string }) => Base;
a12: (x: Array, y: Array) => Array;
a13: (x: Array, y: Array) => Array;
a14: (x: { a: string; b: number }) => Object;
}
interface B extends A {
a: (x: T) => T[];
}
// S's
interface I extends B {
// N's
a: (x: T) => T[]; // ok, instantiation of N is a subtype of M, T is number
a2: (x: T) => string[]; // ok
a3: (x: T) => T; // ok since Base returns void
a4: (x: T, y: U) => T; // ok, instantiation of N is a subtype of M, T is string, U is number
a5: (x: (arg: T) => U) => T; // ok, U is in a parameter position so inferences can be made
a6: (x: (arg: T) => U) => T; // ok, same as a5 but with object type hierarchy
a7: (x: (arg: T) => U) => (r: T) => U; // ok
a8: (x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U; // ok
a9: (x: (arg: T) => U, y: (arg2: { foo: string; bing: number }) => U) => (r: T) => U; // ok, same as a8 with compatible object literal
a10: (...x: T[]) => T; // ok
a11: (x: T, y: T) => T; // ok
a12: >(x: Array, y: T) => Array; // ok, less specific parameter type
a13: >(x: Array, y: T) => T; // ok, T = Array, satisfies constraint, contextual signature instantiation succeeds
a14: (x: { a: T; b: U }) => T; // ok
}