summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/AsyncMethodBuilder.cs4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/AsyncMethodBuilder.cs b/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/AsyncMethodBuilder.cs
index 97c0535e3c..a2506481c2 100644
--- a/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/AsyncMethodBuilder.cs
+++ b/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/AsyncMethodBuilder.cs
@@ -1099,7 +1099,9 @@ namespace System.Runtime.CompilerServices
}
internal static Task? TryGetContinuationTask(Action continuation) =>
- (continuation?.Target as ContinuationWrapper)?._innerTask;
+ (continuation.Target is ContinuationWrapper wrapper) ?
+ wrapper._innerTask : // A wrapped continuation, created by an awaiter
+ continuation.Target as Task; // The continuation targets a task directly, such as with AsyncStateMachineBox
/// <summary>
/// Logically we pass just an Action (delegate) to a task for its action to 'ContinueWith' when it completes.