diff --git a/src/core/Akka/Actor/ActorRef.cs b/src/core/Akka/Actor/ActorRef.cs index 104b9b179de..7f17324dfaf 100644 --- a/src/core/Akka/Actor/ActorRef.cs +++ b/src/core/Akka/Actor/ActorRef.cs @@ -113,13 +113,13 @@ protected override void TellInternal(object message, IActorRef sender) case ISystemMessage msg: handled = _result.TrySetException(new InvalidOperationException($"system message of type '{msg.GetType().Name}' is invalid for {nameof(FutureActorRef)}")); break; - case Status.Failure f: + case Status.Failure f when typeof(T) != typeof(Status.Failure): handled = _result.TrySetException(f.Cause ?? new TaskCanceledException("Task cancelled by actor via Failure message.")); break; #pragma warning disable CS0618 // for backwards compatibility - case Failure f: + case Failure f when !typeof(T).IsAssignableTo(typeof(Failure)): handled = _result.TrySetException(f.Exception ?? new TaskCanceledException("Task cancelled by actor via Failure message.")); #pragma warning restore CS0618