2014-07-13 01:04:16 +02:00
|
|
|
//// [genericCallWithOverloadedFunctionTypedArguments2.ts]
|
|
|
|
// Function typed arguments with multiple signatures must be passed an implementation that matches all of them
|
|
|
|
// Inferences are made quadratic-pairwise to and from these overload sets
|
|
|
|
|
|
|
|
module NonGenericParameter {
|
|
|
|
var a: {
|
|
|
|
(x: boolean): boolean;
|
|
|
|
(x: string): string;
|
|
|
|
}
|
|
|
|
|
|
|
|
function foo4(cb: typeof a) {
|
|
|
|
return cb;
|
|
|
|
}
|
|
|
|
|
|
|
|
var r3 = foo4(<T, U>(x: T) => { var r: U; return r }); // ok
|
|
|
|
}
|
|
|
|
|
|
|
|
module GenericParameter {
|
|
|
|
function foo5<T>(cb: { (x: T): string; (x: number): T }) {
|
|
|
|
return cb;
|
|
|
|
}
|
|
|
|
|
|
|
|
var r6 = foo5(<T>(x: T) => x); // ok
|
|
|
|
|
|
|
|
function foo6<T>(cb: { (x: T): string; (x: T, y?: T): string }) {
|
|
|
|
return cb;
|
|
|
|
}
|
|
|
|
|
|
|
|
var r10 = foo6(<T>(x: T, y: T) => ''); // error
|
|
|
|
|
|
|
|
function foo7<T>(x:T, cb: { (x: T): string; (x: T, y?: T): string }) {
|
|
|
|
return cb;
|
|
|
|
}
|
|
|
|
|
|
|
|
var r13 = foo7(1, <T>(x: T) => x); // ok
|
|
|
|
var a: { <T>(x: T): number; <T>(x: number): T; }
|
|
|
|
var r14 = foo7(1, a); // ok
|
|
|
|
}
|
|
|
|
|
|
|
|
//// [genericCallWithOverloadedFunctionTypedArguments2.js]
|
2014-08-14 15:53:37 +02:00
|
|
|
// Function typed arguments with multiple signatures must be passed an implementation that matches all of them
|
|
|
|
// Inferences are made quadratic-pairwise to and from these overload sets
|
2014-07-13 01:04:16 +02:00
|
|
|
var NonGenericParameter;
|
|
|
|
(function (NonGenericParameter) {
|
|
|
|
var a;
|
|
|
|
function foo4(cb) {
|
|
|
|
return cb;
|
|
|
|
}
|
|
|
|
var r3 = foo4(function (x) {
|
|
|
|
var r;
|
|
|
|
return r;
|
2014-08-15 22:18:54 +02:00
|
|
|
}); // ok
|
2014-07-13 01:04:16 +02:00
|
|
|
})(NonGenericParameter || (NonGenericParameter = {}));
|
|
|
|
var GenericParameter;
|
|
|
|
(function (GenericParameter) {
|
|
|
|
function foo5(cb) {
|
|
|
|
return cb;
|
|
|
|
}
|
2014-08-15 22:18:54 +02:00
|
|
|
var r6 = foo5(function (x) { return x; }); // ok
|
2014-07-13 01:04:16 +02:00
|
|
|
function foo6(cb) {
|
|
|
|
return cb;
|
|
|
|
}
|
2014-08-15 22:18:54 +02:00
|
|
|
var r10 = foo6(function (x, y) { return ''; }); // error
|
2014-07-13 01:04:16 +02:00
|
|
|
function foo7(x, cb) {
|
|
|
|
return cb;
|
|
|
|
}
|
2014-08-15 22:18:54 +02:00
|
|
|
var r13 = foo7(1, function (x) { return x; }); // ok
|
2014-07-13 01:04:16 +02:00
|
|
|
var a;
|
2014-08-15 22:18:54 +02:00
|
|
|
var r14 = foo7(1, a); // ok
|
2014-07-13 01:04:16 +02:00
|
|
|
})(GenericParameter || (GenericParameter = {}));
|