@@ -370,7 +370,28 @@ module LowPriority =
370370 =
371371 ResumableCode.Using( resource, body)
372372
373+ type TaskBuilder with
374+ member inline this.MergeSources < ^TaskLike1 , ^TaskLike2 , ^TResult1 , ^TResult2 , ^Awaiter1 , ^Awaiter2
375+ when ^TaskLike1 : ( member GetAwaiter : unit -> ^Awaiter1 )
376+ and ^TaskLike2 : ( member GetAwaiter : unit -> ^Awaiter2 )
377+ and ^Awaiter1 :> ICriticalNotifyCompletion
378+ and ^Awaiter2 :> ICriticalNotifyCompletion
379+ and ^Awaiter1 : ( member get_IsCompleted : unit -> bool )
380+ and ^Awaiter1 : ( member GetResult : unit -> ^TResult1 )
381+ and ^Awaiter2 : ( member get_IsCompleted : unit -> bool )
382+ and ^Awaiter2 : ( member GetResult : unit -> ^TResult2 )>
383+ ( task1 : ^TaskLike1 , task2 : ^TaskLike2 )
384+ : Task < ^TResult1 * ^TResult2 > =
385+ this.Run(
386+ this.Bind( task1, fun ( result1 : ^TResult1 ) ->
387+ this.Bind( task2, fun ( result2 : ^TResult2 ) ->
388+ this.Return( result1, result2)
389+ )
390+ )
391+ )
392+
373393module HighPriority =
394+
374395 // High priority extensions
375396 type TaskBuilderBase with
376397
@@ -424,7 +445,21 @@ module HighPriority =
424445 member inline this.ReturnFrom ( task : Task < 'T >) : TaskCode < 'T , 'T > =
425446 this.Bind( task, this.Return)
426447
448+ type TaskBuilder with
449+
450+ // This is required for type inference in tasks cases
451+ member inline this.MergeSources ( task1 : Task < ^TResult1 >, task2 : Task < ^TResult2 >)
452+ : Task < ^TResult1 * ^TResult2 > =
453+ this.Run(
454+ this.Bind( task1, fun ( result1 : ^TResult1 ) ->
455+ this.Bind( task2, fun ( result2 : ^TResult2 ) ->
456+ this.Return( result1, result2)
457+ )
458+ )
459+ )
460+
427461module MediumPriority =
462+ open LowPriority
428463 open HighPriority
429464
430465 // Medium priority extensions
@@ -438,19 +473,9 @@ module MediumPriority =
438473 member inline this.ReturnFrom ( computation : Async < 'T >) : TaskCode < 'T , 'T > =
439474 this.ReturnFrom( Async.StartImmediateAsTask computation)
440475
476+
441477 type TaskBuilder with
442-
443- // This is required for type inference in tasks cases
444- member inline this.MergeSources ( task1 : Task < ^TResult1 >, task2 : Task < ^TResult2 >)
445- : Task < ^TResult1 * ^TResult2 > =
446- this.Run(
447- this.Bind( task1, fun ( result1 : ^TResult1 ) ->
448- this.Bind( task2, fun ( result2 : ^TResult2 ) ->
449- this.Return( result1, result2)
450- )
451- )
452- )
453-
478+
454479 // This is required for type inference in tasks cases
455480 member inline this.MergeSources < ^TaskLike2 , ^TResult1 , ^TResult2 , ^Awaiter2
456481 when ^TaskLike2 : ( member GetAwaiter : unit -> ^Awaiter2 )
@@ -482,22 +507,4 @@ module MediumPriority =
482507 )
483508 )
484509 )
485-
486- member inline this.MergeSources < ^TaskLike1 , ^TaskLike2 , ^TResult1 , ^TResult2 , ^Awaiter1 , ^Awaiter2
487- when ^TaskLike1 : ( member GetAwaiter : unit -> ^Awaiter1 )
488- and ^TaskLike2 : ( member GetAwaiter : unit -> ^Awaiter2 )
489- and ^Awaiter1 :> ICriticalNotifyCompletion
490- and ^Awaiter2 :> ICriticalNotifyCompletion
491- and ^Awaiter1 : ( member get_IsCompleted : unit -> bool )
492- and ^Awaiter1 : ( member GetResult : unit -> ^TResult1 )
493- and ^Awaiter2 : ( member get_IsCompleted : unit -> bool )
494- and ^Awaiter2 : ( member GetResult : unit -> ^TResult2 )>
495- ( task1 : ^TaskLike1 , task2 : ^TaskLike2 )
496- : Task < ^TResult1 * ^TResult2 > =
497- this.Run(
498- this.Bind( task1, fun ( result1 : ^TResult1 ) ->
499- this.Bind( task2, fun ( result2 : ^TResult2 ) ->
500- this.Return( result1, result2)
501- )
502- )
503- )
510+
0 commit comments