@@ -13,11 +13,6 @@ namespace Microsoft.FSharp.Collections
13
13
open Microsoft.FSharp .Control
14
14
open Microsoft.FSharp .Collections
15
15
16
- module Upcast =
17
- // The f# compiler outputs unnecessary unbox.any calls in upcasts. If this functionality
18
- // is fixed with the compiler then these functions can be removed.
19
- let inline enumerable ( t : #IEnumerable<'T> ) : IEnumerable < 'T > = ( # " " t : IEnumerable< 'T> #)
20
-
21
16
module Internal =
22
17
module IEnumerator =
23
18
open Microsoft.FSharp .Collections .IEnumerator
@@ -66,18 +61,18 @@ namespace Microsoft.FSharp.Collections
66
61
67
62
[<CompiledName( " Unfold" ) >]
68
63
let unfold f x =
69
- ISeq.unfold f x |> Upcast.enumerable
64
+ ISeq.unfold f x :> seq <_>
70
65
71
66
[<CompiledName( " Empty" ) >]
72
67
let empty < 'T > = ( EmptyEnumerable :> seq< 'T>)
73
68
74
69
[<CompiledName( " InitializeInfinite" ) >]
75
70
let initInfinite f =
76
- ISeq.initInfinite f |> Upcast.enumerable
71
+ ISeq.initInfinite f :> seq <_>
77
72
78
73
[<CompiledName( " Initialize" ) >]
79
74
let init count f =
80
- ISeq.init count f |> Upcast.enumerable
75
+ ISeq.init count f :> seq <_>
81
76
82
77
[<CompiledName( " Iterate" ) >]
83
78
let iter f ( source : seq < 'T >) =
@@ -126,52 +121,52 @@ namespace Microsoft.FSharp.Collections
126
121
127
122
[<CompiledName( " Filter" ) >]
128
123
let filter f source =
129
- ISeq.filter f ( toISeq source) |> Upcast.enumerable
124
+ ISeq.filter f ( toISeq source) :> seq <_>
130
125
131
126
[<CompiledName( " Where" ) >]
132
127
let where f source = filter f source
133
128
134
129
[<CompiledName( " Map" ) >]
135
130
let map f source =
136
- ISeq.map f ( toISeq source) |> Upcast.enumerable
131
+ ISeq.map f ( toISeq source) :> seq <_>
137
132
138
133
[<CompiledName( " MapIndexed" ) >]
139
134
let mapi f source =
140
135
let f = OptimizedClosures.FSharpFunc<_,_,_>. Adapt f
141
- ISeq.mapi ( fun idx a -> f.Invoke( idx, a)) ( toISeq source) |> Upcast.enumerable
136
+ ISeq.mapi ( fun idx a -> f.Invoke( idx, a)) ( toISeq source) :> seq <_>
142
137
143
138
[<CompiledName( " MapIndexed2" ) >]
144
139
let mapi2 f source1 source2 =
145
140
let f = OptimizedClosures.FSharpFunc< int, 'T, 'U, 'V>. Adapt f
146
- ISeq.mapi2 ( fun idx a b -> f.Invoke ( idx, a, b)) ( source1 |> toISeq1) ( source2 |> toISeq2) |> Upcast.enumerable
141
+ ISeq.mapi2 ( fun idx a b -> f.Invoke ( idx, a, b)) ( source1 |> toISeq1) ( source2 |> toISeq2) :> seq <_>
147
142
148
143
[<CompiledName( " Map2" ) >]
149
144
let map2 f source1 source2 =
150
- ISeq.map2 f ( source1 |> toISeq1) ( source2 |> toISeq2) |> Upcast.enumerable
145
+ ISeq.map2 f ( source1 |> toISeq1) ( source2 |> toISeq2) :> seq <_>
151
146
152
147
[<CompiledName( " Map3" ) >]
153
148
let map3 f source1 source2 source3 =
154
- ISeq.map3 f ( source1 |> toISeq1) ( source2 |> toISeq2) ( source3 |> toISeq3) |> Upcast.enumerable
149
+ ISeq.map3 f ( source1 |> toISeq1) ( source2 |> toISeq2) ( source3 |> toISeq3) :> seq <_>
155
150
156
151
[<CompiledName( " Choose" ) >]
157
152
let choose f source =
158
- ISeq.choose f ( toISeq source) |> Upcast.enumerable
153
+ ISeq.choose f ( toISeq source) :> seq <_>
159
154
160
155
[<CompiledName( " Indexed" ) >]
161
156
let indexed source =
162
- ISeq.indexed ( toISeq source) |> Upcast.enumerable
157
+ ISeq.indexed ( toISeq source) :> seq <_>
163
158
164
159
[<CompiledName( " Zip" ) >]
165
160
let zip source1 source2 =
166
- ISeq.zip ( source1 |> toISeq1) ( source2 |> toISeq2) |> Upcast.enumerable
161
+ ISeq.zip ( source1 |> toISeq1) ( source2 |> toISeq2) :> seq <_>
167
162
168
163
[<CompiledName( " Zip3" ) >]
169
164
let zip3 source1 source2 source3 =
170
- ISeq.zip3 ( source1 |> toISeq1) ( source2 |> toISeq2) ( source3 |> toISeq3) |> Upcast.enumerable
165
+ ISeq.zip3 ( source1 |> toISeq1) ( source2 |> toISeq2) ( source3 |> toISeq3) :> seq <_>
171
166
172
167
[<CompiledName( " Cast" ) >]
173
168
let cast ( source : IEnumerable ) =
174
- source |> ISeq.cast |> Upcast.enumerable
169
+ source |> ISeq.cast :> seq <_>
175
170
176
171
[<CompiledName( " TryPick" ) >]
177
172
let tryPick f ( source : seq < 'T >) =
@@ -191,7 +186,7 @@ namespace Microsoft.FSharp.Collections
191
186
192
187
[<CompiledName( " Take" ) >]
193
188
let take count ( source : seq < 'T >) =
194
- ISeq.take count ( toISeq source) |> Upcast.enumerable
189
+ ISeq.take count ( toISeq source) :> seq <_>
195
190
196
191
[<CompiledName( " IsEmpty" ) >]
197
192
let isEmpty ( source : seq < 'T >) =
@@ -206,7 +201,7 @@ namespace Microsoft.FSharp.Collections
206
201
207
202
[<CompiledName( " Concat" ) >]
208
203
let concat sources =
209
- sources |> toISeqs |> ISeq.map toISeq |> ISeq.concat |> Upcast.enumerable
204
+ sources |> toISeqs |> ISeq.map toISeq |> ISeq.concat :> seq <_>
210
205
211
206
[<CompiledName( " Length" ) >]
212
207
let length ( source : seq < 'T >) =
@@ -229,11 +224,11 @@ namespace Microsoft.FSharp.Collections
229
224
230
225
[<CompiledName( " Replicate" ) >]
231
226
let replicate count x =
232
- ISeq.replicate count x |> Upcast.enumerable
227
+ ISeq.replicate count x :> seq <_>
233
228
234
229
[<CompiledName( " Append" ) >]
235
230
let append ( source1 : seq < 'T >) ( source2 : seq < 'T >) =
236
- ISeq.append ( source1 |> toISeq1) ( source2 |> toISeq2) |> Upcast.enumerable
231
+ ISeq.append ( source1 |> toISeq1) ( source2 |> toISeq2) :> seq <_>
237
232
238
233
[<CompiledName( " Collect" ) >]
239
234
let collect f sources = map f sources |> concat
@@ -245,15 +240,15 @@ namespace Microsoft.FSharp.Collections
245
240
246
241
[<CompiledName( " OfList" ) >]
247
242
let ofList ( source : 'T list ) =
248
- ISeq.ofList source |> Upcast.enumerable
243
+ ISeq.ofList source :> seq <_>
249
244
250
245
[<CompiledName( " ToList" ) >]
251
246
let toList ( source : seq < 'T >) =
252
247
ISeq.toList ( toISeq source)
253
248
254
249
[<CompiledName( " OfArray" ) >]
255
250
let ofArray ( source : 'T array ) =
256
- ISeq.ofArray source |> Upcast.enumerable
251
+ ISeq.ofArray source :> seq <_>
257
252
258
253
[<CompiledName( " ToArray" ) >]
259
254
let toArray ( source : seq < 'T >) =
@@ -273,19 +268,19 @@ namespace Microsoft.FSharp.Collections
273
268
274
269
[<CompiledName( " Singleton" ) >]
275
270
let singleton x =
276
- ISeq.singleton x |> Upcast.enumerable
271
+ ISeq.singleton x :> seq <_>
277
272
278
273
[<CompiledName( " Truncate" ) >]
279
274
let truncate n ( source : seq < 'T >) =
280
- ISeq.truncate n ( toISeq source) |> Upcast.enumerable
275
+ ISeq.truncate n ( toISeq source) :> seq <_>
281
276
282
277
[<CompiledName( " Pairwise" ) >]
283
278
let pairwise ( source : seq < 'T >) =
284
- ISeq.pairwise ( toISeq source) |> Upcast.enumerable
279
+ ISeq.pairwise ( toISeq source) :> seq <_>
285
280
286
281
[<CompiledName( " Scan" ) >]
287
282
let scan < 'T , 'State > f ( z : 'State ) ( source : seq < 'T >) =
288
- ISeq.scan f z ( toISeq source) |> Upcast.enumerable
283
+ ISeq.scan f z ( toISeq source) :> seq <_>
289
284
290
285
[<CompiledName( " TryFindBack" ) >]
291
286
let tryFindBack f ( source : seq < 'T >) =
@@ -297,7 +292,7 @@ namespace Microsoft.FSharp.Collections
297
292
298
293
[<CompiledName( " ScanBack" ) >]
299
294
let scanBack < 'T , 'State > f ( source : seq < 'T >) ( acc : 'State ) =
300
- ISeq.scanBack f ( toISeq source) acc |> Upcast.enumerable
295
+ ISeq.scanBack f ( toISeq source) acc :> seq <_>
301
296
302
297
[<CompiledName( " FindIndex" ) >]
303
298
let findIndex p ( source : seq < _ >) =
@@ -318,15 +313,15 @@ namespace Microsoft.FSharp.Collections
318
313
// windowed : int -> seq<'T> -> seq<'T[]>
319
314
[<CompiledName( " Windowed" ) >]
320
315
let windowed windowSize ( source : seq < _ >) =
321
- ISeq.windowed windowSize ( toISeq source) |> Upcast.enumerable
316
+ ISeq.windowed windowSize ( toISeq source) :> seq <_>
322
317
323
318
[<CompiledName( " Cache" ) >]
324
319
let cache ( source : seq < 'T >) =
325
- ISeq.cache ( toISeq source) |> Upcast.enumerable
320
+ ISeq.cache ( toISeq source) :> seq <_>
326
321
327
322
[<CompiledName( " AllPairs" ) >]
328
323
let allPairs source1 source2 =
329
- ISeq.allPairs ( source1 |> toISeq1) ( source2 |> toISeq2) |> Upcast.enumerable
324
+ ISeq.allPairs ( source1 |> toISeq1) ( source2 |> toISeq2) :> seq <_>
330
325
331
326
[<CodeAnalysis.SuppressMessage( " Microsoft.Naming" , " CA1709:IdentifiersShouldBeCasedCorrectly" ); CodeAnalysis.SuppressMessage( " Microsoft.Naming" , " CA1707:IdentifiersShouldNotContainUnderscores" ); CodeAnalysis.SuppressMessage( " Microsoft.Naming" , " CA1704:IdentifiersShouldBeSpelledCorrectly" ) >]
332
327
[<CompiledName( " ReadOnly" ) >]
@@ -347,36 +342,36 @@ namespace Microsoft.FSharp.Collections
347
342
else seq |> toISeq |> ISeq.GroupBy.byRef keyf
348
343
349
344
grouped
350
- |> ISeq.map ( fun ( key , value ) -> key, Upcast.enumerable value)
351
- |> Upcast.enumerable )
345
+ |> ISeq.map ( fun ( key , value ) -> key, value :> seq <_> )
346
+ :> seq <_> )
352
347
353
348
[<CompiledName( " Distinct" ) >]
354
349
let distinct source =
355
- ISeq.distinct ( toISeq source) |> Upcast.enumerable
350
+ ISeq.distinct ( toISeq source) :> seq <_>
356
351
357
352
[<CompiledName( " DistinctBy" ) >]
358
353
let distinctBy keyf source =
359
- ISeq.distinctBy keyf ( toISeq source) |> Upcast.enumerable
354
+ ISeq.distinctBy keyf ( toISeq source) :> seq <_>
360
355
361
356
[<CompiledName( " SortBy" ) >]
362
357
let sortBy keyf source =
363
- ISeq.sortBy keyf ( toISeq source) |> Upcast.enumerable
358
+ ISeq.sortBy keyf ( toISeq source) :> seq <_>
364
359
365
360
[<CompiledName( " Sort" ) >]
366
361
let sort source =
367
- ISeq.sort ( toISeq source) |> Upcast.enumerable
362
+ ISeq.sort ( toISeq source) :> seq <_>
368
363
369
364
[<CompiledName( " SortWith" ) >]
370
365
let sortWith f source =
371
- ISeq.sortWith f ( toISeq source) |> Upcast.enumerable
366
+ ISeq.sortWith f ( toISeq source) :> seq <_>
372
367
373
368
[<CompiledName( " SortByDescending" ) >]
374
369
let inline sortByDescending keyf source =
375
- ISeq.sortByDescending keyf ( toISeq source) |> Upcast.enumerable
370
+ ISeq.sortByDescending keyf ( toISeq source) :> seq <_>
376
371
377
372
[<CompiledName( " SortDescending" ) >]
378
373
let inline sortDescending source =
379
- ISeq.sortDescending ( toISeq source) |> Upcast.enumerable
374
+ ISeq.sortDescending ( toISeq source) :> seq <_>
380
375
381
376
[<CompiledName( " CountBy" ) >]
382
377
let countBy ( keyf : 'T -> 'Key ) ( source : seq < 'T >) =
@@ -385,8 +380,8 @@ namespace Microsoft.FSharp.Collections
385
380
#else
386
381
if typeof< 'Key>. IsValueType
387
382
#endif
388
- then ISeq.CountBy.byVal keyf ( toISeq source) |> Upcast.enumerable
389
- else ISeq.CountBy.byRef keyf ( toISeq source) |> Upcast.enumerable
383
+ then ISeq.CountBy.byVal keyf ( toISeq source) :> seq <_>
384
+ else ISeq.CountBy.byRef keyf ( toISeq source) :> seq <_>
390
385
391
386
[<CompiledName( " Sum" ) >]
392
387
let inline sum ( source : seq < ^a >) : ^a =
@@ -422,15 +417,15 @@ namespace Microsoft.FSharp.Collections
422
417
423
418
[<CompiledName( " TakeWhile" ) >]
424
419
let takeWhile p ( source : seq < _ >) =
425
- ISeq.takeWhile p ( toISeq source) |> Upcast.enumerable
420
+ ISeq.takeWhile p ( toISeq source) :> seq <_>
426
421
427
422
[<CompiledName( " Skip" ) >]
428
423
let skip count ( source : seq < _ >) =
429
- ISeq.skip count ( toISeq source) |> Upcast.enumerable
424
+ ISeq.skip count ( toISeq source) :> seq <_>
430
425
431
426
[<CompiledName( " SkipWhile" ) >]
432
427
let skipWhile p ( source : seq < _ >) =
433
- ISeq.skipWhile p ( toISeq source) |> Upcast.enumerable
428
+ ISeq.skipWhile p ( toISeq source) :> seq <_>
434
429
435
430
[<CompiledName( " ForAll2" ) >]
436
431
let forall2 p ( source1 : seq < _ >) ( source2 : seq < _ >) =
@@ -452,7 +447,7 @@ namespace Microsoft.FSharp.Collections
452
447
453
448
[<CompiledName( " Tail" ) >]
454
449
let tail ( source : seq < 'T >) =
455
- ISeq.tail ( toISeq source) |> Upcast.enumerable
450
+ ISeq.tail ( toISeq source) :> seq <_>
456
451
457
452
[<CompiledName( " Last" ) >]
458
453
let last ( source : seq < _ >) =
@@ -468,28 +463,28 @@ namespace Microsoft.FSharp.Collections
468
463
469
464
[<CompiledName( " Reverse" ) >]
470
465
let rev source =
471
- ISeq.rev ( toISeq source) |> Upcast.enumerable
466
+ ISeq.rev ( toISeq source) :> seq <_>
472
467
473
468
[<CompiledName( " Permute" ) >]
474
469
let permute f ( source : seq < _ >) =
475
- ISeq.permute f ( toISeq source) |> Upcast.enumerable
470
+ ISeq.permute f ( toISeq source) :> seq <_>
476
471
477
472
[<CompiledName( " MapFold" ) >]
478
473
let mapFold < 'T , 'State , 'Result > ( f : 'State -> 'T -> 'Result * 'State ) acc source =
479
- ISeq.mapFold f acc ( toISeq source) |> fun ( iseq , state ) -> Upcast.enumerable iseq, state
474
+ ISeq.mapFold f acc ( toISeq source) |> fun ( iseq , state ) -> iseq :> seq <_> , state
480
475
481
476
[<CompiledName( " MapFoldBack" ) >]
482
477
let mapFoldBack < 'T , 'State , 'Result > ( f : 'T -> 'State -> 'Result * 'State ) source acc =
483
- ISeq.mapFoldBack f ( toISeq source) acc |> fun ( iseq , state ) -> Upcast.enumerable iseq, state
478
+ ISeq.mapFoldBack f ( toISeq source) acc |> fun ( iseq , state ) -> iseq :> seq <_> , state
484
479
485
480
[<CompiledName( " Except" ) >]
486
481
let except ( itemsToExclude : seq < 'T >) ( source : seq < 'T >) =
487
- ISeq.except itemsToExclude ( toISeq source) |> Upcast.enumerable
482
+ ISeq.except itemsToExclude ( toISeq source) :> seq <_>
488
483
489
484
[<CompiledName( " ChunkBySize" ) >]
490
485
let chunkBySize chunkSize ( source : seq < _ >) =
491
- ISeq.chunkBySize chunkSize ( toISeq source) |> Upcast.enumerable
486
+ ISeq.chunkBySize chunkSize ( toISeq source) :> seq <_>
492
487
493
488
[<CompiledName( " SplitInto" ) >]
494
489
let splitInto count source =
495
- ISeq.splitInto count ( toISeq source) |> Upcast.enumerable
490
+ ISeq.splitInto count ( toISeq source) :> seq <_>
0 commit comments