@@ -13,11 +13,6 @@ namespace Microsoft.FSharp.Collections
1313 open Microsoft.FSharp .Control
1414 open Microsoft.FSharp .Collections
1515
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-
2116 module Internal =
2217 module IEnumerator =
2318 open Microsoft.FSharp .Collections .IEnumerator
@@ -66,18 +61,18 @@ namespace Microsoft.FSharp.Collections
6661
6762 [<CompiledName( " Unfold" ) >]
6863 let unfold f x =
69- ISeq.unfold f x |> Upcast.enumerable
64+ ISeq.unfold f x :> seq <_>
7065
7166 [<CompiledName( " Empty" ) >]
7267 let empty < 'T > = ( EmptyEnumerable :> seq< 'T>)
7368
7469 [<CompiledName( " InitializeInfinite" ) >]
7570 let initInfinite f =
76- ISeq.initInfinite f |> Upcast.enumerable
71+ ISeq.initInfinite f :> seq <_>
7772
7873 [<CompiledName( " Initialize" ) >]
7974 let init count f =
80- ISeq.init count f |> Upcast.enumerable
75+ ISeq.init count f :> seq <_>
8176
8277 [<CompiledName( " Iterate" ) >]
8378 let iter f ( source : seq < 'T >) =
@@ -126,52 +121,52 @@ namespace Microsoft.FSharp.Collections
126121
127122 [<CompiledName( " Filter" ) >]
128123 let filter f source =
129- ISeq.filter f ( toISeq source) |> Upcast.enumerable
124+ ISeq.filter f ( toISeq source) :> seq <_>
130125
131126 [<CompiledName( " Where" ) >]
132127 let where f source = filter f source
133128
134129 [<CompiledName( " Map" ) >]
135130 let map f source =
136- ISeq.map f ( toISeq source) |> Upcast.enumerable
131+ ISeq.map f ( toISeq source) :> seq <_>
137132
138133 [<CompiledName( " MapIndexed" ) >]
139134 let mapi f source =
140135 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 <_>
142137
143138 [<CompiledName( " MapIndexed2" ) >]
144139 let mapi2 f source1 source2 =
145140 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 <_>
147142
148143 [<CompiledName( " Map2" ) >]
149144 let map2 f source1 source2 =
150- ISeq.map2 f ( source1 |> toISeq1) ( source2 |> toISeq2) |> Upcast.enumerable
145+ ISeq.map2 f ( source1 |> toISeq1) ( source2 |> toISeq2) :> seq <_>
151146
152147 [<CompiledName( " Map3" ) >]
153148 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 <_>
155150
156151 [<CompiledName( " Choose" ) >]
157152 let choose f source =
158- ISeq.choose f ( toISeq source) |> Upcast.enumerable
153+ ISeq.choose f ( toISeq source) :> seq <_>
159154
160155 [<CompiledName( " Indexed" ) >]
161156 let indexed source =
162- ISeq.indexed ( toISeq source) |> Upcast.enumerable
157+ ISeq.indexed ( toISeq source) :> seq <_>
163158
164159 [<CompiledName( " Zip" ) >]
165160 let zip source1 source2 =
166- ISeq.zip ( source1 |> toISeq1) ( source2 |> toISeq2) |> Upcast.enumerable
161+ ISeq.zip ( source1 |> toISeq1) ( source2 |> toISeq2) :> seq <_>
167162
168163 [<CompiledName( " Zip3" ) >]
169164 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 <_>
171166
172167 [<CompiledName( " Cast" ) >]
173168 let cast ( source : IEnumerable ) =
174- source |> ISeq.cast |> Upcast.enumerable
169+ source |> ISeq.cast :> seq <_>
175170
176171 [<CompiledName( " TryPick" ) >]
177172 let tryPick f ( source : seq < 'T >) =
@@ -191,7 +186,7 @@ namespace Microsoft.FSharp.Collections
191186
192187 [<CompiledName( " Take" ) >]
193188 let take count ( source : seq < 'T >) =
194- ISeq.take count ( toISeq source) |> Upcast.enumerable
189+ ISeq.take count ( toISeq source) :> seq <_>
195190
196191 [<CompiledName( " IsEmpty" ) >]
197192 let isEmpty ( source : seq < 'T >) =
@@ -206,7 +201,7 @@ namespace Microsoft.FSharp.Collections
206201
207202 [<CompiledName( " Concat" ) >]
208203 let concat sources =
209- sources |> toISeqs |> ISeq.map toISeq |> ISeq.concat |> Upcast.enumerable
204+ sources |> toISeqs |> ISeq.map toISeq |> ISeq.concat :> seq <_>
210205
211206 [<CompiledName( " Length" ) >]
212207 let length ( source : seq < 'T >) =
@@ -229,11 +224,11 @@ namespace Microsoft.FSharp.Collections
229224
230225 [<CompiledName( " Replicate" ) >]
231226 let replicate count x =
232- ISeq.replicate count x |> Upcast.enumerable
227+ ISeq.replicate count x :> seq <_>
233228
234229 [<CompiledName( " Append" ) >]
235230 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 <_>
237232
238233 [<CompiledName( " Collect" ) >]
239234 let collect f sources = map f sources |> concat
@@ -245,15 +240,15 @@ namespace Microsoft.FSharp.Collections
245240
246241 [<CompiledName( " OfList" ) >]
247242 let ofList ( source : 'T list ) =
248- ISeq.ofList source |> Upcast.enumerable
243+ ISeq.ofList source :> seq <_>
249244
250245 [<CompiledName( " ToList" ) >]
251246 let toList ( source : seq < 'T >) =
252247 ISeq.toList ( toISeq source)
253248
254249 [<CompiledName( " OfArray" ) >]
255250 let ofArray ( source : 'T array ) =
256- ISeq.ofArray source |> Upcast.enumerable
251+ ISeq.ofArray source :> seq <_>
257252
258253 [<CompiledName( " ToArray" ) >]
259254 let toArray ( source : seq < 'T >) =
@@ -273,19 +268,19 @@ namespace Microsoft.FSharp.Collections
273268
274269 [<CompiledName( " Singleton" ) >]
275270 let singleton x =
276- ISeq.singleton x |> Upcast.enumerable
271+ ISeq.singleton x :> seq <_>
277272
278273 [<CompiledName( " Truncate" ) >]
279274 let truncate n ( source : seq < 'T >) =
280- ISeq.truncate n ( toISeq source) |> Upcast.enumerable
275+ ISeq.truncate n ( toISeq source) :> seq <_>
281276
282277 [<CompiledName( " Pairwise" ) >]
283278 let pairwise ( source : seq < 'T >) =
284- ISeq.pairwise ( toISeq source) |> Upcast.enumerable
279+ ISeq.pairwise ( toISeq source) :> seq <_>
285280
286281 [<CompiledName( " Scan" ) >]
287282 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 <_>
289284
290285 [<CompiledName( " TryFindBack" ) >]
291286 let tryFindBack f ( source : seq < 'T >) =
@@ -297,7 +292,7 @@ namespace Microsoft.FSharp.Collections
297292
298293 [<CompiledName( " ScanBack" ) >]
299294 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 <_>
301296
302297 [<CompiledName( " FindIndex" ) >]
303298 let findIndex p ( source : seq < _ >) =
@@ -318,15 +313,15 @@ namespace Microsoft.FSharp.Collections
318313 // windowed : int -> seq<'T> -> seq<'T[]>
319314 [<CompiledName( " Windowed" ) >]
320315 let windowed windowSize ( source : seq < _ >) =
321- ISeq.windowed windowSize ( toISeq source) |> Upcast.enumerable
316+ ISeq.windowed windowSize ( toISeq source) :> seq <_>
322317
323318 [<CompiledName( " Cache" ) >]
324319 let cache ( source : seq < 'T >) =
325- ISeq.cache ( toISeq source) |> Upcast.enumerable
320+ ISeq.cache ( toISeq source) :> seq <_>
326321
327322 [<CompiledName( " AllPairs" ) >]
328323 let allPairs source1 source2 =
329- ISeq.allPairs ( source1 |> toISeq1) ( source2 |> toISeq2) |> Upcast.enumerable
324+ ISeq.allPairs ( source1 |> toISeq1) ( source2 |> toISeq2) :> seq <_>
330325
331326 [<CodeAnalysis.SuppressMessage( " Microsoft.Naming" , " CA1709:IdentifiersShouldBeCasedCorrectly" ); CodeAnalysis.SuppressMessage( " Microsoft.Naming" , " CA1707:IdentifiersShouldNotContainUnderscores" ); CodeAnalysis.SuppressMessage( " Microsoft.Naming" , " CA1704:IdentifiersShouldBeSpelledCorrectly" ) >]
332327 [<CompiledName( " ReadOnly" ) >]
@@ -347,36 +342,36 @@ namespace Microsoft.FSharp.Collections
347342 else seq |> toISeq |> ISeq.GroupBy.byRef keyf
348343
349344 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 <_> )
352347
353348 [<CompiledName( " Distinct" ) >]
354349 let distinct source =
355- ISeq.distinct ( toISeq source) |> Upcast.enumerable
350+ ISeq.distinct ( toISeq source) :> seq <_>
356351
357352 [<CompiledName( " DistinctBy" ) >]
358353 let distinctBy keyf source =
359- ISeq.distinctBy keyf ( toISeq source) |> Upcast.enumerable
354+ ISeq.distinctBy keyf ( toISeq source) :> seq <_>
360355
361356 [<CompiledName( " SortBy" ) >]
362357 let sortBy keyf source =
363- ISeq.sortBy keyf ( toISeq source) |> Upcast.enumerable
358+ ISeq.sortBy keyf ( toISeq source) :> seq <_>
364359
365360 [<CompiledName( " Sort" ) >]
366361 let sort source =
367- ISeq.sort ( toISeq source) |> Upcast.enumerable
362+ ISeq.sort ( toISeq source) :> seq <_>
368363
369364 [<CompiledName( " SortWith" ) >]
370365 let sortWith f source =
371- ISeq.sortWith f ( toISeq source) |> Upcast.enumerable
366+ ISeq.sortWith f ( toISeq source) :> seq <_>
372367
373368 [<CompiledName( " SortByDescending" ) >]
374369 let inline sortByDescending keyf source =
375- ISeq.sortByDescending keyf ( toISeq source) |> Upcast.enumerable
370+ ISeq.sortByDescending keyf ( toISeq source) :> seq <_>
376371
377372 [<CompiledName( " SortDescending" ) >]
378373 let inline sortDescending source =
379- ISeq.sortDescending ( toISeq source) |> Upcast.enumerable
374+ ISeq.sortDescending ( toISeq source) :> seq <_>
380375
381376 [<CompiledName( " CountBy" ) >]
382377 let countBy ( keyf : 'T -> 'Key ) ( source : seq < 'T >) =
@@ -385,8 +380,8 @@ namespace Microsoft.FSharp.Collections
385380#else
386381 if typeof< 'Key>. IsValueType
387382#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 <_>
390385
391386 [<CompiledName( " Sum" ) >]
392387 let inline sum ( source : seq < ^a >) : ^a =
@@ -422,15 +417,15 @@ namespace Microsoft.FSharp.Collections
422417
423418 [<CompiledName( " TakeWhile" ) >]
424419 let takeWhile p ( source : seq < _ >) =
425- ISeq.takeWhile p ( toISeq source) |> Upcast.enumerable
420+ ISeq.takeWhile p ( toISeq source) :> seq <_>
426421
427422 [<CompiledName( " Skip" ) >]
428423 let skip count ( source : seq < _ >) =
429- ISeq.skip count ( toISeq source) |> Upcast.enumerable
424+ ISeq.skip count ( toISeq source) :> seq <_>
430425
431426 [<CompiledName( " SkipWhile" ) >]
432427 let skipWhile p ( source : seq < _ >) =
433- ISeq.skipWhile p ( toISeq source) |> Upcast.enumerable
428+ ISeq.skipWhile p ( toISeq source) :> seq <_>
434429
435430 [<CompiledName( " ForAll2" ) >]
436431 let forall2 p ( source1 : seq < _ >) ( source2 : seq < _ >) =
@@ -452,7 +447,7 @@ namespace Microsoft.FSharp.Collections
452447
453448 [<CompiledName( " Tail" ) >]
454449 let tail ( source : seq < 'T >) =
455- ISeq.tail ( toISeq source) |> Upcast.enumerable
450+ ISeq.tail ( toISeq source) :> seq <_>
456451
457452 [<CompiledName( " Last" ) >]
458453 let last ( source : seq < _ >) =
@@ -468,28 +463,28 @@ namespace Microsoft.FSharp.Collections
468463
469464 [<CompiledName( " Reverse" ) >]
470465 let rev source =
471- ISeq.rev ( toISeq source) |> Upcast.enumerable
466+ ISeq.rev ( toISeq source) :> seq <_>
472467
473468 [<CompiledName( " Permute" ) >]
474469 let permute f ( source : seq < _ >) =
475- ISeq.permute f ( toISeq source) |> Upcast.enumerable
470+ ISeq.permute f ( toISeq source) :> seq <_>
476471
477472 [<CompiledName( " MapFold" ) >]
478473 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
480475
481476 [<CompiledName( " MapFoldBack" ) >]
482477 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
484479
485480 [<CompiledName( " Except" ) >]
486481 let except ( itemsToExclude : seq < 'T >) ( source : seq < 'T >) =
487- ISeq.except itemsToExclude ( toISeq source) |> Upcast.enumerable
482+ ISeq.except itemsToExclude ( toISeq source) :> seq <_>
488483
489484 [<CompiledName( " ChunkBySize" ) >]
490485 let chunkBySize chunkSize ( source : seq < _ >) =
491- ISeq.chunkBySize chunkSize ( toISeq source) |> Upcast.enumerable
486+ ISeq.chunkBySize chunkSize ( toISeq source) :> seq <_>
492487
493488 [<CompiledName( " SplitInto" ) >]
494489 let splitInto count source =
495- ISeq.splitInto count ( toISeq source) |> Upcast.enumerable
490+ ISeq.splitInto count ( toISeq source) :> seq <_>
0 commit comments