2014-07-13 01:04:16 +02:00
|
|
|
//// [recursiveTypesUsedAsFunctionParameters.ts]
|
|
|
|
class List<T> {
|
|
|
|
data: T;
|
|
|
|
next: List<List<T>>;
|
|
|
|
}
|
|
|
|
|
|
|
|
class MyList<T> {
|
|
|
|
data: T;
|
|
|
|
next: MyList<MyList<T>>;
|
|
|
|
}
|
|
|
|
|
|
|
|
function foo<T>(x: List<T>);
|
|
|
|
function foo<U>(x: List<U>); // error, duplicate
|
|
|
|
function foo<T>(x: List<T>) {
|
|
|
|
}
|
|
|
|
|
|
|
|
function foo2<T>(x: List<T>);
|
|
|
|
function foo2<U>(x: MyList<U>); // ok, nominally compared with first overload
|
|
|
|
function foo2<T>(x: any) {
|
|
|
|
}
|
|
|
|
|
|
|
|
function other<T extends List<U>, U>() {
|
|
|
|
// error but wrong error
|
|
|
|
// BUG 838247
|
|
|
|
function foo3<V>(x: T);
|
|
|
|
function foo3<V>(x: MyList<V>) { }
|
|
|
|
|
|
|
|
// should be error
|
|
|
|
// BUG 838247
|
|
|
|
function foo4<V>(x: T);
|
|
|
|
function foo4<V>(x: List<V>) { }
|
|
|
|
|
|
|
|
// ok
|
|
|
|
function foo5<V>(x: T): string;
|
|
|
|
function foo5<V>(x: List<V>): number;
|
|
|
|
function foo5<V>(x: MyList<V>): boolean;
|
|
|
|
function foo5<V>(x: any): any { return null; }
|
|
|
|
|
|
|
|
var list: List<string>;
|
|
|
|
var myList: MyList<string>;
|
|
|
|
|
|
|
|
var r = foo5(list);
|
|
|
|
var r2 = foo5(myList);
|
|
|
|
}
|
|
|
|
|
|
|
|
//// [recursiveTypesUsedAsFunctionParameters.js]
|
|
|
|
var List = (function () {
|
|
|
|
function List() {
|
|
|
|
}
|
|
|
|
return List;
|
|
|
|
})();
|
|
|
|
var MyList = (function () {
|
|
|
|
function MyList() {
|
|
|
|
}
|
|
|
|
return MyList;
|
|
|
|
})();
|
|
|
|
function foo(x) {
|
|
|
|
}
|
|
|
|
function foo2(x) {
|
|
|
|
}
|
|
|
|
function other() {
|
2015-02-07 03:45:09 +01:00
|
|
|
function foo3(x) { }
|
|
|
|
function foo4(x) { }
|
2015-02-07 05:03:24 +01:00
|
|
|
function foo5(x) { return null; }
|
2014-07-13 01:04:16 +02:00
|
|
|
var list;
|
|
|
|
var myList;
|
|
|
|
var r = foo5(list);
|
|
|
|
var r2 = foo5(myList);
|
|
|
|
}
|