File: recursiveTypesUsedAsFunctionParameters.types

package info (click to toggle)
node-typescript 2.1.5-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 203,952 kB
  • ctags: 52,987
  • sloc: sh: 11; makefile: 5
file content (157 lines) | stat: -rw-r--r-- 3,167 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
=== tests/cases/conformance/types/typeRelationships/recursiveTypes/recursiveTypesUsedAsFunctionParameters.ts ===
class List<T> {
>List : List<T>
>T : T

    data: T;
>data : T
>T : T

    next: List<List<T>>;
>next : List<List<T>>
>List : List<T>
>List : List<T>
>T : T
}

class MyList<T> {
>MyList : MyList<T>
>T : T

    data: T;
>data : T
>T : T

    next: MyList<MyList<T>>;
>next : MyList<MyList<T>>
>MyList : MyList<T>
>MyList : MyList<T>
>T : T
}

function foo<T>(x: List<T>);
>foo : { <T>(x: List<T>): any; <U>(x: List<U>): any; }
>T : T
>x : List<T>
>List : List<T>
>T : T

function foo<U>(x: List<U>); // error, duplicate
>foo : { <T>(x: List<T>): any; <U>(x: List<U>): any; }
>U : U
>x : List<U>
>List : List<T>
>U : U

function foo<T>(x: List<T>) {
>foo : { <T>(x: List<T>): any; <U>(x: List<U>): any; }
>T : T
>x : List<T>
>List : List<T>
>T : T
}

function foo2<T>(x: List<T>);
>foo2 : { <T>(x: List<T>): any; <U>(x: MyList<U>): any; }
>T : T
>x : List<T>
>List : List<T>
>T : T

function foo2<U>(x: MyList<U>); // ok, nominally compared with first overload
>foo2 : { <T>(x: List<T>): any; <U>(x: MyList<U>): any; }
>U : U
>x : MyList<U>
>MyList : MyList<T>
>U : U

function foo2<T>(x: any) {
>foo2 : { <T>(x: List<T>): any; <U>(x: MyList<U>): any; }
>T : T
>x : any
}

function other<T extends List<U>, U>() {
>other : <T extends List<U>, U>() => void
>T : T
>List : List<T>
>U : U
>U : U

    // error but wrong error
    // BUG 838247
    function foo3<V>(x: T);
>foo3 : <V>(x: T) => any
>V : V
>x : T
>T : T

    function foo3<V>(x: MyList<V>) { }
>foo3 : <V>(x: T) => any
>V : V
>x : MyList<V>
>MyList : MyList<T>
>V : V

    // should be error
    // BUG 838247
    function foo4<V>(x: T);
>foo4 : <V>(x: T) => any
>V : V
>x : T
>T : T

    function foo4<V>(x: List<V>) { }
>foo4 : <V>(x: T) => any
>V : V
>x : List<V>
>List : List<T>
>V : V

    // ok
    function foo5<V>(x: T): string;
>foo5 : { <V>(x: T): string; <V>(x: List<V>): number; <V>(x: MyList<V>): boolean; }
>V : V
>x : T
>T : T

    function foo5<V>(x: List<V>): number;
>foo5 : { <V>(x: T): string; <V>(x: List<V>): number; <V>(x: MyList<V>): boolean; }
>V : V
>x : List<V>
>List : List<T>
>V : V

    function foo5<V>(x: MyList<V>): boolean;
>foo5 : { <V>(x: T): string; <V>(x: List<V>): number; <V>(x: MyList<V>): boolean; }
>V : V
>x : MyList<V>
>MyList : MyList<T>
>V : V

    function foo5<V>(x: any): any { return null; }
>foo5 : { <V>(x: T): string; <V>(x: List<V>): number; <V>(x: MyList<V>): boolean; }
>V : V
>x : any
>null : null

    var list: List<string>;
>list : List<string>
>List : List<T>

    var myList: MyList<string>;
>myList : MyList<string>
>MyList : MyList<T>

    var r = foo5(list);
>r : number
>foo5(list) : number
>foo5 : { <V>(x: T): string; <V>(x: List<V>): number; <V>(x: MyList<V>): boolean; }
>list : List<string>

    var r2 = foo5(myList);
>r2 : number
>foo5(myList) : number
>foo5 : { <V>(x: T): string; <V>(x: List<V>): number; <V>(x: MyList<V>): boolean; }
>myList : MyList<string>
}