Skip to content

Commit 40712f2

Browse files
T-GroedgarfgpLanayxmmitchedotnet-maestro[bot]
authored
[automated] Merge branch 'main' => 'release/dev18.0' (#18481)
* Consolidated two `SynExpr.LetOrUseBang` patterns with `isUse = true` (#18472) * `and!` support in TaskBulder (#18451) * Update package Category (#18479) * Update dependencies from https://github.com/dotnet/source-build-reference-packages build 20250423.3 (#18494) Microsoft.SourceBuild.Intermediate.source-build-reference-packages From Version 9.0.0-alpha.1.25209.1 -> To Version 9.0.0-alpha.1.25223.3 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> --------- Co-authored-by: Edgar Gonzalez <[email protected]> Co-authored-by: Vladimir Shchur <[email protected]> Co-authored-by: Matt Mitchell <[email protected]> Co-authored-by: dotnet-maestro[bot] <42748379+dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
2 parents 4c9a512 + 3a2c7ae commit 40712f2

16 files changed

+938
-328
lines changed

docs/release-notes/.FSharp.Core/9.0.300.md

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
### Added
55
* Added nullability annotations to `.Using` builder method for `async` and `task` builders ([PR #18292](https://github.com/dotnet/fsharp/pull/18292))
6+
* Support for `and!` in `TaskBuilder` ([LanguageSuggestion #1363](https://github.com/fsharp/fslang-suggestions/issues/1363), [PR #18451](https://github.com/dotnet/fsharp/pull/18451))
67

78
### Changed
89

eng/Publishing.props

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<Project>
2+
3+
<!-- Update Artifacts with Kind=Package to have additional metadata item Category="ToolingPackage".
4+
Depending on channel configuration, this means that these assets could be pushed to a different feed. -->
5+
<ItemGroup>
6+
<Artifact Update="@(Artifact->WithMetadataValue('Kind', 'Package'))" Category="ToolingPackage" />
7+
</ItemGroup>
8+
9+
</Project>

eng/Version.Details.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
<Dependencies>
33
<Source Uri="https://github.com/dotnet/dotnet" Mapping="fsharp" Sha="721dc7a2a59416b21fc49447d264009d708d6000" BarId="265489" />
44
<ProductDependencies>
5-
<Dependency Name="Microsoft.SourceBuild.Intermediate.source-build-reference-packages" Version="9.0.0-alpha.1.25209.1">
5+
<Dependency Name="Microsoft.SourceBuild.Intermediate.source-build-reference-packages" Version="9.0.0-alpha.1.25223.3">
66
<Uri>https://github.com/dotnet/source-build-reference-packages</Uri>
7-
<Sha>7dbf5deea5bdccf513df73cba179c4c0ad106010</Sha>
7+
<Sha>19eb5ea4e5f9c4e5256843a92805c8c9e942207d</Sha>
88
<SourceBuild RepoName="source-build-reference-packages" ManagedOnly="true" />
99
</Dependency>
1010
<!-- Intermediate is necessary for source build. -->

src/Compiler/Checking/Expressions/CheckComputationExpressions.fs

+81-326
Large diffs are not rendered by default.

src/FSharp.Core/fslib-extra-pervasives.fs

+1
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,7 @@ module ExtraTopLevelOperators =
325325
[<assembly: AutoOpen("Microsoft.FSharp.Collections")>]
326326
[<assembly: AutoOpen("Microsoft.FSharp.Control")>]
327327
[<assembly: AutoOpen("Microsoft.FSharp.Control.TaskBuilderExtensions.LowPriority")>]
328+
[<assembly: AutoOpen("Microsoft.FSharp.Control.TaskBuilderExtensions.LowPlusPriority")>]
328329
[<assembly: AutoOpen("Microsoft.FSharp.Control.TaskBuilderExtensions.MediumPriority")>]
329330
[<assembly: AutoOpen("Microsoft.FSharp.Control.TaskBuilderExtensions.HighPriority")>]
330331
[<assembly: AutoOpen("Microsoft.FSharp.Linq.QueryRunExtensions.LowPriority")>]

src/FSharp.Core/tasks.fs

+280
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,48 @@ 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<struct (^TResult1 * ^TResult2)> =
385+
this.Run(
386+
this.Bind(
387+
task1,
388+
fun (result1: ^TResult1) ->
389+
this.Bind(task2, fun (result2: ^TResult2) -> this.Return struct (result1, result2))
390+
)
391+
)
392+
393+
type BackgroundTaskBuilder with
394+
member inline this.MergeSources< ^TaskLike1, ^TaskLike2, ^TResult1, ^TResult2, ^Awaiter1, ^Awaiter2
395+
when ^TaskLike1: (member GetAwaiter: unit -> ^Awaiter1)
396+
and ^TaskLike2: (member GetAwaiter: unit -> ^Awaiter2)
397+
and ^Awaiter1 :> ICriticalNotifyCompletion
398+
and ^Awaiter2 :> ICriticalNotifyCompletion
399+
and ^Awaiter1: (member get_IsCompleted: unit -> bool)
400+
and ^Awaiter1: (member GetResult: unit -> ^TResult1)
401+
and ^Awaiter2: (member get_IsCompleted: unit -> bool)
402+
and ^Awaiter2: (member GetResult: unit -> ^TResult2)>
403+
(task1: ^TaskLike1, task2: ^TaskLike2)
404+
: Task<struct (^TResult1 * ^TResult2)> =
405+
this.Run(
406+
this.Bind(
407+
task1,
408+
fun (result1: ^TResult1) ->
409+
this.Bind(task2, fun (result2: ^TResult2) -> this.Return struct (result1, result2))
410+
)
411+
)
412+
373413
module HighPriority =
414+
374415
// High priority extensions
375416
type TaskBuilderBase with
376417

@@ -424,7 +465,36 @@ module HighPriority =
424465
member inline this.ReturnFrom(task: Task<'T>) : TaskCode<'T, 'T> =
425466
this.Bind(task, this.Return)
426467

468+
type TaskBuilder with
469+
470+
// This overload is required for type inference in tasks cases
471+
member inline this.MergeSources
472+
(task1: Task< ^TResult1 >, task2: Task< ^TResult2 >)
473+
: Task<struct (^TResult1 * ^TResult2)> =
474+
this.Run(
475+
this.Bind(
476+
task1,
477+
fun (result1: ^TResult1) ->
478+
this.Bind(task2, fun (result2: ^TResult2) -> this.Return struct (result1, result2))
479+
)
480+
)
481+
482+
type BackgroundTaskBuilder with
483+
484+
// This overload is required for type inference in tasks cases
485+
member inline this.MergeSources
486+
(task1: Task< ^TResult1 >, task2: Task< ^TResult2 >)
487+
: Task<struct (^TResult1 * ^TResult2)> =
488+
this.Run(
489+
this.Bind(
490+
task1,
491+
fun (result1: ^TResult1) ->
492+
this.Bind(task2, fun (result2: ^TResult2) -> this.Return struct (result1, result2))
493+
)
494+
)
495+
427496
module MediumPriority =
497+
open LowPriority
428498
open HighPriority
429499

430500
// Medium priority extensions
@@ -437,3 +507,213 @@ module MediumPriority =
437507

438508
member inline this.ReturnFrom(computation: Async<'T>) : TaskCode<'T, 'T> =
439509
this.ReturnFrom(Async.StartImmediateAsTask computation)
510+
511+
type TaskBuilder with
512+
513+
// This overload is required for type inference in tasks cases
514+
member inline this.MergeSources< ^TaskLike2, ^TResult1, ^TResult2, ^Awaiter2
515+
when ^TaskLike2: (member GetAwaiter: unit -> ^Awaiter2)
516+
and ^Awaiter2 :> ICriticalNotifyCompletion
517+
and ^Awaiter2: (member get_IsCompleted: unit -> bool)
518+
and ^Awaiter2: (member GetResult: unit -> 'TResult2)>
519+
(task1: Task< ^TResult1 >, task2: ^TaskLike2)
520+
: Task<struct (^TResult1 * ^TResult2)> =
521+
this.Run(
522+
this.Bind(
523+
task1,
524+
fun (result1: ^TResult1) ->
525+
this.Bind(task2, fun (result2: ^TResult2) -> this.Return struct (result1, result2))
526+
)
527+
)
528+
529+
// This overload is required for type inference in tasks cases
530+
member inline this.MergeSources< ^TaskLike1, ^TResult1, ^TResult2, ^Awaiter1
531+
when ^TaskLike1: (member GetAwaiter: unit -> ^Awaiter1)
532+
and ^Awaiter1 :> ICriticalNotifyCompletion
533+
and ^Awaiter1: (member get_IsCompleted: unit -> bool)
534+
and ^Awaiter1: (member GetResult: unit -> 'TResult1)>
535+
(task1: ^TaskLike1, task2: Task< ^TResult2 >)
536+
: Task<struct (^TResult1 * ^TResult2)> =
537+
this.Run(
538+
this.Bind(
539+
task1,
540+
fun (result1: ^TResult1) ->
541+
this.Bind(task2, fun (result2: ^TResult2) -> this.Return struct (result1, result2))
542+
)
543+
)
544+
545+
// This overload is required for type inference in async cases
546+
member inline this.MergeSources
547+
(computation1: Async< ^TResult1 >, computation2: Async< ^TResult2 >)
548+
: Task<struct (^TResult1 * ^TResult2)> =
549+
this.Run(
550+
this.Bind(
551+
computation1,
552+
fun (result1: ^TResult1) ->
553+
this.Bind(computation2, fun (result2: ^TResult2) -> this.Return struct (result1, result2))
554+
)
555+
)
556+
557+
// This overload is required for type inference in task + async cases
558+
member inline this.MergeSources
559+
(task: Task< ^TResult1 >, computation: Async< ^TResult2 >)
560+
: Task<struct (^TResult1 * ^TResult2)> =
561+
this.Run(
562+
this.Bind(
563+
task,
564+
fun (result1: ^TResult1) ->
565+
this.Bind(computation, fun (result2: ^TResult2) -> this.Return struct (result1, result2))
566+
)
567+
)
568+
569+
// This overload is required for type inference in async + task case
570+
member inline this.MergeSources
571+
(computation: Async< ^TResult1 >, task: Task< ^TResult2 >)
572+
: Task<struct (^TResult1 * ^TResult2)> =
573+
this.Run(
574+
this.Bind(
575+
computation,
576+
fun (result1: ^TResult1) ->
577+
this.Bind(task, fun (result2: ^TResult2) -> this.Return struct (result1, result2))
578+
)
579+
)
580+
581+
type BackgroundTaskBuilder with
582+
583+
// This overload is required for type inference in tasks cases
584+
member inline this.MergeSources< ^TaskLike2, ^TResult1, ^TResult2, ^Awaiter2
585+
when ^TaskLike2: (member GetAwaiter: unit -> ^Awaiter2)
586+
and ^Awaiter2 :> ICriticalNotifyCompletion
587+
and ^Awaiter2: (member get_IsCompleted: unit -> bool)
588+
and ^Awaiter2: (member GetResult: unit -> 'TResult2)>
589+
(task1: Task< ^TResult1 >, task2: ^TaskLike2)
590+
: Task<struct (^TResult1 * ^TResult2)> =
591+
this.Run(
592+
this.Bind(
593+
task1,
594+
fun (result1: ^TResult1) ->
595+
this.Bind(task2, fun (result2: ^TResult2) -> this.Return struct (result1, result2))
596+
)
597+
)
598+
599+
// This overload is required for type inference in tasks cases
600+
member inline this.MergeSources< ^TaskLike1, ^TResult1, ^TResult2, ^Awaiter1
601+
when ^TaskLike1: (member GetAwaiter: unit -> ^Awaiter1)
602+
and ^Awaiter1 :> ICriticalNotifyCompletion
603+
and ^Awaiter1: (member get_IsCompleted: unit -> bool)
604+
and ^Awaiter1: (member GetResult: unit -> 'TResult1)>
605+
(task1: ^TaskLike1, task2: Task< ^TResult2 >)
606+
: Task<struct (^TResult1 * ^TResult2)> =
607+
this.Run(
608+
this.Bind(
609+
task1,
610+
fun (result1: ^TResult1) ->
611+
this.Bind(task2, fun (result2: ^TResult2) -> this.Return struct (result1, result2))
612+
)
613+
)
614+
615+
// This overload is required for type inference in async cases
616+
member inline this.MergeSources
617+
(computation1: Async< ^TResult1 >, computation2: Async< ^TResult2 >)
618+
: Task<struct (^TResult1 * ^TResult2)> =
619+
this.Run(
620+
this.Bind(
621+
computation1,
622+
fun (result1: ^TResult1) ->
623+
this.Bind(computation2, fun (result2: ^TResult2) -> this.Return struct (result1, result2))
624+
)
625+
)
626+
627+
// This overload is required for type inference in task + async cases
628+
member inline this.MergeSources
629+
(task: Task< ^TResult1 >, computation: Async< ^TResult2 >)
630+
: Task<struct (^TResult1 * ^TResult2)> =
631+
this.Run(
632+
this.Bind(
633+
task,
634+
fun (result1: ^TResult1) ->
635+
this.Bind(computation, fun (result2: ^TResult2) -> this.Return struct (result1, result2))
636+
)
637+
)
638+
639+
// This overload is required for type inference in async + task case
640+
member inline this.MergeSources
641+
(computation: Async< ^TResult1 >, task: Task< ^TResult2 >)
642+
: Task<struct (^TResult1 * ^TResult2)> =
643+
this.Run(
644+
this.Bind(
645+
computation,
646+
fun (result1: ^TResult1) ->
647+
this.Bind(task, fun (result2: ^TResult2) -> this.Return struct (result1, result2))
648+
)
649+
)
650+
651+
module LowPlusPriority =
652+
open LowPriority
653+
open MediumPriority
654+
655+
type TaskBuilder with
656+
// This overload is required for type inference in async cases
657+
member inline this.MergeSources< ^TaskLike2, ^TResult1, ^TResult2, ^Awaiter2
658+
when ^TaskLike2: (member GetAwaiter: unit -> ^Awaiter2)
659+
and ^Awaiter2 :> ICriticalNotifyCompletion
660+
and ^Awaiter2: (member get_IsCompleted: unit -> bool)
661+
and ^Awaiter2: (member GetResult: unit -> 'TResult2)>
662+
(computation: Async< ^TResult1 >, task: ^TaskLike2)
663+
: Task<struct (^TResult1 * ^TResult2)> =
664+
this.Run(
665+
this.Bind(
666+
computation,
667+
fun (result1: ^TResult1) ->
668+
this.Bind(task, fun (result2: ^TResult2) -> this.Return struct (result1, result2))
669+
)
670+
)
671+
672+
// This overload is required for type inference in async cases
673+
member inline this.MergeSources< ^TaskLike1, ^TResult1, ^TResult2, ^Awaiter1
674+
when ^TaskLike1: (member GetAwaiter: unit -> ^Awaiter1)
675+
and ^Awaiter1 :> ICriticalNotifyCompletion
676+
and ^Awaiter1: (member get_IsCompleted: unit -> bool)
677+
and ^Awaiter1: (member GetResult: unit -> 'TResult1)>
678+
(task: ^TaskLike1, computation: Async< ^TResult2 >)
679+
: Task<struct (^TResult1 * ^TResult2)> =
680+
this.Run(
681+
this.Bind(
682+
task,
683+
fun (result1: ^TResult1) ->
684+
this.Bind(computation, fun (result2: ^TResult2) -> this.Return struct (result1, result2))
685+
)
686+
)
687+
688+
type BackgroundTaskBuilder with
689+
// This overload is required for type inference in async cases
690+
member inline this.MergeSources< ^TaskLike2, ^TResult1, ^TResult2, ^Awaiter2
691+
when ^TaskLike2: (member GetAwaiter: unit -> ^Awaiter2)
692+
and ^Awaiter2 :> ICriticalNotifyCompletion
693+
and ^Awaiter2: (member get_IsCompleted: unit -> bool)
694+
and ^Awaiter2: (member GetResult: unit -> 'TResult2)>
695+
(computation: Async< ^TResult1 >, task: ^TaskLike2)
696+
: Task<struct (^TResult1 * ^TResult2)> =
697+
this.Run(
698+
this.Bind(
699+
computation,
700+
fun (result1: ^TResult1) ->
701+
this.Bind(task, fun (result2: ^TResult2) -> this.Return struct (result1, result2))
702+
)
703+
)
704+
705+
// This overload is required for type inference in async cases
706+
member inline this.MergeSources< ^TaskLike1, ^TResult1, ^TResult2, ^Awaiter1
707+
when ^TaskLike1: (member GetAwaiter: unit -> ^Awaiter1)
708+
and ^Awaiter1 :> ICriticalNotifyCompletion
709+
and ^Awaiter1: (member get_IsCompleted: unit -> bool)
710+
and ^Awaiter1: (member GetResult: unit -> 'TResult1)>
711+
(task: ^TaskLike1, computation: Async< ^TResult2 >)
712+
: Task<struct (^TResult1 * ^TResult2)> =
713+
this.Run(
714+
this.Bind(
715+
task,
716+
fun (result1: ^TResult1) ->
717+
this.Bind(computation, fun (result2: ^TResult2) -> this.Return struct (result1, result2))
718+
)
719+
)

0 commit comments

Comments
 (0)