1
1
=== tests/cases/compiler/higherKindedTypes.ts ===
2
- interface Functor<Container<_T>, A > {
2
+ interface Functor<A, Container<_T>> {
3
3
>Functor : Symbol(Functor, Decl(higherKindedTypes.ts, 0, 0))
4
- >Container : Symbol(Container , Decl(higherKindedTypes.ts, 0, 18))
5
- >_T : Symbol(_T , Decl(higherKindedTypes.ts, 0, 28 ))
6
- >A : Symbol(A , Decl(higherKindedTypes.ts, 0, 32 ))
4
+ >A : Symbol(A , Decl(higherKindedTypes.ts, 0, 18))
5
+ >Container : Symbol(Container , Decl(higherKindedTypes.ts, 0, 20 ))
6
+ >_T : Symbol(_T , Decl(higherKindedTypes.ts, 0, 31 ))
7
7
8
8
map<B>(f: (a: A) => B): Container<B>;
9
9
>map : Symbol(Functor.map, Decl(higherKindedTypes.ts, 0, 37))
10
10
>B : Symbol(B, Decl(higherKindedTypes.ts, 1, 8))
11
11
>f : Symbol(f, Decl(higherKindedTypes.ts, 1, 11))
12
12
>a : Symbol(a, Decl(higherKindedTypes.ts, 1, 15))
13
- >A : Symbol(A, Decl(higherKindedTypes.ts, 0, 32 ))
13
+ >A : Symbol(A, Decl(higherKindedTypes.ts, 0, 18 ))
14
14
>B : Symbol(B, Decl(higherKindedTypes.ts, 1, 8))
15
- >Container : Symbol(Container, Decl(higherKindedTypes.ts, 0, 18 ))
15
+ >Container : Symbol(Container, Decl(higherKindedTypes.ts, 0, 20 ))
16
16
>B : Symbol(B, Decl(higherKindedTypes.ts, 1, 8))
17
17
}
18
18
19
- interface FunctorX<A> extends Functor<FunctorX, A > {
19
+ interface FunctorX<A> extends Functor<A, FunctorX > {
20
20
>FunctorX : Symbol(FunctorX, Decl(higherKindedTypes.ts, 2, 1))
21
21
>A : Symbol(A, Decl(higherKindedTypes.ts, 4, 19))
22
22
>Functor : Symbol(Functor, Decl(higherKindedTypes.ts, 0, 0))
23
- >FunctorX : Symbol(FunctorX, Decl(higherKindedTypes.ts, 2, 1))
24
23
>A : Symbol(A, Decl(higherKindedTypes.ts, 4, 19))
24
+ >FunctorX : Symbol(FunctorX, Decl(higherKindedTypes.ts, 2, 1))
25
25
26
26
map<B>(f: (a: A) => B): FunctorX<B>;
27
27
>map : Symbol(FunctorX.map, Decl(higherKindedTypes.ts, 4, 52))
@@ -37,12 +37,12 @@ interface FunctorX<A> extends Functor<FunctorX, A> {
37
37
>xVal : Symbol(FunctorX.xVal, Decl(higherKindedTypes.ts, 5, 40))
38
38
}
39
39
40
- interface FunctorY<A> extends Functor<FunctorY, A > {
40
+ interface FunctorY<A> extends Functor<A, FunctorY > {
41
41
>FunctorY : Symbol(FunctorY, Decl(higherKindedTypes.ts, 7, 1))
42
42
>A : Symbol(A, Decl(higherKindedTypes.ts, 9, 19))
43
43
>Functor : Symbol(Functor, Decl(higherKindedTypes.ts, 0, 0))
44
- >FunctorY : Symbol(FunctorY, Decl(higherKindedTypes.ts, 7, 1))
45
44
>A : Symbol(A, Decl(higherKindedTypes.ts, 9, 19))
45
+ >FunctorY : Symbol(FunctorY, Decl(higherKindedTypes.ts, 7, 1))
46
46
47
47
map<B>(f: (a: A) => B): FunctorY<B>;
48
48
>map : Symbol(FunctorY.map, Decl(higherKindedTypes.ts, 9, 52))
@@ -124,13 +124,13 @@ const expectY2: FunctorY<string[]> = resultY2;
124
124
>resultY2 : Symbol(resultY2, Decl(higherKindedTypes.ts, 26, 5))
125
125
126
126
127
- function staticMap<F<_T> extends Functor<F, _T >, A, B>(fa: F<A>, f: (a: A) => B): F<B> {
127
+ function staticMap<F<_T> extends Functor<_T, F >, A, B>(fa: F<A>, f: (a: A) => B): F<B> {
128
128
>staticMap : Symbol(staticMap, Decl(higherKindedTypes.ts, 27, 46))
129
129
>F : Symbol(F, Decl(higherKindedTypes.ts, 30, 19))
130
130
>_T : Symbol(_T, Decl(higherKindedTypes.ts, 30, 21))
131
131
>Functor : Symbol(Functor, Decl(higherKindedTypes.ts, 0, 0))
132
- >F : Symbol(F, Decl(higherKindedTypes.ts, 30, 19))
133
132
>_T : Symbol(_T, Decl(higherKindedTypes.ts, 30, 21))
133
+ >F : Symbol(F, Decl(higherKindedTypes.ts, 30, 19))
134
134
>A : Symbol(A, Decl(higherKindedTypes.ts, 30, 48))
135
135
>B : Symbol(B, Decl(higherKindedTypes.ts, 30, 51))
136
136
>fa : Symbol(fa, Decl(higherKindedTypes.ts, 30, 55))
@@ -154,13 +154,13 @@ function staticMap<F<_T> extends Functor<F, _T>, A, B>(fa: F<A>, f: (a: A) => B)
154
154
>result : Symbol(result, Decl(higherKindedTypes.ts, 31, 9))
155
155
}
156
156
157
- function staticMapBadImplementation<F<_T> extends Functor<F, _T >, A, B>(fa: F<A>, f: (a: A) => B): F<B> {
157
+ function staticMapBadImplementation<F<_T> extends Functor<_T, F >, A, B>(fa: F<A>, f: (a: A) => B): F<B> {
158
158
>staticMapBadImplementation : Symbol(staticMapBadImplementation, Decl(higherKindedTypes.ts, 33, 1))
159
159
>F : Symbol(F, Decl(higherKindedTypes.ts, 35, 36))
160
160
>_T : Symbol(_T, Decl(higherKindedTypes.ts, 35, 38))
161
161
>Functor : Symbol(Functor, Decl(higherKindedTypes.ts, 0, 0))
162
- >F : Symbol(F, Decl(higherKindedTypes.ts, 35, 36))
163
162
>_T : Symbol(_T, Decl(higherKindedTypes.ts, 35, 38))
163
+ >F : Symbol(F, Decl(higherKindedTypes.ts, 35, 36))
164
164
>A : Symbol(A, Decl(higherKindedTypes.ts, 35, 65))
165
165
>B : Symbol(B, Decl(higherKindedTypes.ts, 35, 68))
166
166
>fa : Symbol(fa, Decl(higherKindedTypes.ts, 35, 72))
@@ -177,55 +177,81 @@ function staticMapBadImplementation<F<_T> extends Functor<F, _T>, A, B>(fa: F<A>
177
177
>fa : Symbol(fa, Decl(higherKindedTypes.ts, 35, 72))
178
178
}
179
179
180
+ function staticMapNoConstraint<F<_T>, A, B>(fa: F<A>, f: (a: A) => B): F<B> {
181
+ >staticMapNoConstraint : Symbol(staticMapNoConstraint, Decl(higherKindedTypes.ts, 37, 1))
182
+ >F : Symbol(F, Decl(higherKindedTypes.ts, 39, 31))
183
+ >_T : Symbol(_T, Decl(higherKindedTypes.ts, 39, 33))
184
+ >A : Symbol(A, Decl(higherKindedTypes.ts, 39, 37))
185
+ >B : Symbol(B, Decl(higherKindedTypes.ts, 39, 40))
186
+ >fa : Symbol(fa, Decl(higherKindedTypes.ts, 39, 44))
187
+ >F : Symbol(F, Decl(higherKindedTypes.ts, 39, 31))
188
+ >A : Symbol(A, Decl(higherKindedTypes.ts, 39, 37))
189
+ >f : Symbol(f, Decl(higherKindedTypes.ts, 39, 53))
190
+ >a : Symbol(a, Decl(higherKindedTypes.ts, 39, 58))
191
+ >A : Symbol(A, Decl(higherKindedTypes.ts, 39, 37))
192
+ >B : Symbol(B, Decl(higherKindedTypes.ts, 39, 40))
193
+ >F : Symbol(F, Decl(higherKindedTypes.ts, 39, 31))
194
+ >B : Symbol(B, Decl(higherKindedTypes.ts, 39, 40))
195
+
196
+ // expect error here since F has no constraint so we have no idea what shape it will be
197
+ const result = fa.map(f);
198
+ >result : Symbol(result, Decl(higherKindedTypes.ts, 41, 9))
199
+ >fa : Symbol(fa, Decl(higherKindedTypes.ts, 39, 44))
200
+ >f : Symbol(f, Decl(higherKindedTypes.ts, 39, 53))
201
+
202
+ return result;
203
+ >result : Symbol(result, Decl(higherKindedTypes.ts, 41, 9))
204
+ }
205
+
180
206
const resultX3 = staticMap(initialX, val => val.length);
181
- >resultX3 : Symbol(resultX3, Decl(higherKindedTypes.ts, 39 , 5))
207
+ >resultX3 : Symbol(resultX3, Decl(higherKindedTypes.ts, 45 , 5))
182
208
>staticMap : Symbol(staticMap, Decl(higherKindedTypes.ts, 27, 46))
183
209
>initialX : Symbol(initialX, Decl(higherKindedTypes.ts, 14, 13))
184
- >val : Symbol(val, Decl(higherKindedTypes.ts, 39 , 36))
210
+ >val : Symbol(val, Decl(higherKindedTypes.ts, 45 , 36))
185
211
>val.length : Symbol(String.length, Decl(lib.d.ts, --, --))
186
- >val : Symbol(val, Decl(higherKindedTypes.ts, 39 , 36))
212
+ >val : Symbol(val, Decl(higherKindedTypes.ts, 45 , 36))
187
213
>length : Symbol(String.length, Decl(lib.d.ts, --, --))
188
214
189
215
const expectX3: FunctorX<number> = resultX3;
190
- >expectX3 : Symbol(expectX3, Decl(higherKindedTypes.ts, 40 , 5))
216
+ >expectX3 : Symbol(expectX3, Decl(higherKindedTypes.ts, 46 , 5))
191
217
>FunctorX : Symbol(FunctorX, Decl(higherKindedTypes.ts, 2, 1))
192
- >resultX3 : Symbol(resultX3, Decl(higherKindedTypes.ts, 39 , 5))
218
+ >resultX3 : Symbol(resultX3, Decl(higherKindedTypes.ts, 45 , 5))
193
219
194
220
const resultY3 = staticMap(initialY, val => val.length);
195
- >resultY3 : Symbol(resultY3, Decl(higherKindedTypes.ts, 42 , 5))
221
+ >resultY3 : Symbol(resultY3, Decl(higherKindedTypes.ts, 48 , 5))
196
222
>staticMap : Symbol(staticMap, Decl(higherKindedTypes.ts, 27, 46))
197
223
>initialY : Symbol(initialY, Decl(higherKindedTypes.ts, 15, 13))
198
- >val : Symbol(val, Decl(higherKindedTypes.ts, 42 , 36))
224
+ >val : Symbol(val, Decl(higherKindedTypes.ts, 48 , 36))
199
225
>val.length : Symbol(String.length, Decl(lib.d.ts, --, --))
200
- >val : Symbol(val, Decl(higherKindedTypes.ts, 42 , 36))
226
+ >val : Symbol(val, Decl(higherKindedTypes.ts, 48 , 36))
201
227
>length : Symbol(String.length, Decl(lib.d.ts, --, --))
202
228
203
229
const expectY3: FunctorY<number> = resultY3;
204
- >expectY3 : Symbol(expectY3, Decl(higherKindedTypes.ts, 43 , 5))
230
+ >expectY3 : Symbol(expectY3, Decl(higherKindedTypes.ts, 49 , 5))
205
231
>FunctorY : Symbol(FunctorY, Decl(higherKindedTypes.ts, 7, 1))
206
- >resultY3 : Symbol(resultY3, Decl(higherKindedTypes.ts, 42 , 5))
232
+ >resultY3 : Symbol(resultY3, Decl(higherKindedTypes.ts, 48 , 5))
207
233
208
234
const resultX4 = staticMap(initialX, val => [val]);
209
- >resultX4 : Symbol(resultX4, Decl(higherKindedTypes.ts, 45 , 5))
235
+ >resultX4 : Symbol(resultX4, Decl(higherKindedTypes.ts, 51 , 5))
210
236
>staticMap : Symbol(staticMap, Decl(higherKindedTypes.ts, 27, 46))
211
237
>initialX : Symbol(initialX, Decl(higherKindedTypes.ts, 14, 13))
212
- >val : Symbol(val, Decl(higherKindedTypes.ts, 45 , 36))
213
- >val : Symbol(val, Decl(higherKindedTypes.ts, 45 , 36))
238
+ >val : Symbol(val, Decl(higherKindedTypes.ts, 51 , 36))
239
+ >val : Symbol(val, Decl(higherKindedTypes.ts, 51 , 36))
214
240
215
241
const expectX4: FunctorX<string[]> = resultX4;
216
- >expectX4 : Symbol(expectX4, Decl(higherKindedTypes.ts, 46 , 5))
242
+ >expectX4 : Symbol(expectX4, Decl(higherKindedTypes.ts, 52 , 5))
217
243
>FunctorX : Symbol(FunctorX, Decl(higherKindedTypes.ts, 2, 1))
218
- >resultX4 : Symbol(resultX4, Decl(higherKindedTypes.ts, 45 , 5))
244
+ >resultX4 : Symbol(resultX4, Decl(higherKindedTypes.ts, 51 , 5))
219
245
220
246
const resultY4 = staticMap(initialY, val => [val]);
221
- >resultY4 : Symbol(resultY4, Decl(higherKindedTypes.ts, 48 , 5))
247
+ >resultY4 : Symbol(resultY4, Decl(higherKindedTypes.ts, 54 , 5))
222
248
>staticMap : Symbol(staticMap, Decl(higherKindedTypes.ts, 27, 46))
223
249
>initialY : Symbol(initialY, Decl(higherKindedTypes.ts, 15, 13))
224
- >val : Symbol(val, Decl(higherKindedTypes.ts, 48 , 36))
225
- >val : Symbol(val, Decl(higherKindedTypes.ts, 48 , 36))
250
+ >val : Symbol(val, Decl(higherKindedTypes.ts, 54 , 36))
251
+ >val : Symbol(val, Decl(higherKindedTypes.ts, 54 , 36))
226
252
227
253
const expectY4: FunctorY<string[]> = resultY4;
228
- >expectY4 : Symbol(expectY4, Decl(higherKindedTypes.ts, 49 , 5))
254
+ >expectY4 : Symbol(expectY4, Decl(higherKindedTypes.ts, 55 , 5))
229
255
>FunctorY : Symbol(FunctorY, Decl(higherKindedTypes.ts, 7, 1))
230
- >resultY4 : Symbol(resultY4, Decl(higherKindedTypes.ts, 48 , 5))
256
+ >resultY4 : Symbol(resultY4, Decl(higherKindedTypes.ts, 54 , 5))
231
257
0 commit comments