Skip to content

Commit

Permalink
Workaround check
Browse files Browse the repository at this point in the history
  • Loading branch information
Xicy committed Oct 11, 2023
1 parent 5b996d5 commit 802fbfa
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions Jint/Runtime/Interop/DelegateWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ namespace Jint.Runtime.Interop
public sealed class DelegateWrapper : FunctionInstance
{
private static readonly JsString _name = new JsString("delegate");
private static readonly Type _voidTaskResultType = Task.CompletedTask.GetType().GetGenericArguments()[0];
private readonly Delegate _d;
private readonly bool _delegateContainsParamsArgument;

Expand Down Expand Up @@ -160,17 +159,15 @@ private JsValue ConvertTaskToPromise(Task task)
}
else
{
var taskType = continuationAction.GetType();

// Special case: Marshal `async Task` as undefined, as this is `Task<VoidTaskResult>` at runtime
// See https://github.com/sebastienros/jint/pull/1567#issuecomment-1681987702
if (taskType.IsGenericType && taskType.GetGenericArguments()[0] == _voidTaskResultType)
if (Task.CompletedTask.Equals(continuationAction))
{
resolve(FromObject(Engine, JsValue.Undefined));
return;
}

var result = taskType.GetProperty(nameof(Task<object>.Result));
var result = continuationAction.GetType().GetProperty(nameof(Task<object>.Result));
if (result is not null)
{
resolve(FromObject(Engine, result.GetValue(continuationAction)));
Expand Down

0 comments on commit 802fbfa

Please sign in to comment.