File tree Expand file tree Collapse file tree 2 files changed +16
-4
lines changed
FSharp.Core.Unittests/FSharp.Core/Microsoft.FSharp.Collections Expand file tree Collapse file tree 2 files changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -260,7 +260,19 @@ type SeqModule() =
260260 let expectedNullSeq = seq [ null ; null ]
261261
262262 VerifySeqsEqual expectedNullSeq NullSeq
263-
263+
264+ CheckThrowsExn< System.InvalidCastException>( fun () ->
265+ let strings =
266+ integerArray
267+ |> Seq.cast< string>
268+ for o in strings do ())
269+
270+ CheckThrowsExn< System.InvalidCastException>( fun () ->
271+ let strings =
272+ integerArray
273+ |> Seq.cast< string>
274+ :> System.Collections.IEnumerable // without this upcast the for loop throws, so it should with this upcast too
275+ for o in strings do ())
264276
265277 ()
266278
Original file line number Diff line number Diff line change @@ -25,11 +25,11 @@ namespace Microsoft.FSharp.Collections
2525
2626 let cast ( e : IEnumerator ) : IEnumerator < 'T > =
2727 { new IEnumerator< 'T> with
28- member x.Current = unbox e.Current
28+ member x.Current = unbox< 'T > e.Current
2929 interface IEnumerator with
30- member x.Current = unbox e.Current
30+ member x.Current = unbox< 'T > e.Current :> obj
3131 member x.MoveNext () = e.MoveNext()
32- member x.Reset () = noReset();
32+ member x.Reset () = noReset()
3333 interface System.IDisposable with
3434 member x.Dispose () =
3535 match e with
You can’t perform that action at this time.
0 commit comments