Repository: dotnet/runtime
File: src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs (C#)

Code before:
            {
#if !SUPPORT_JIT
                _compilation.TypeSystemContext.EnsureLoadableMethod(method);
#endif

#if READYTORUN
                if (recordToken)
                {
                    ModuleToken methodModuleToken = HandleToModuleToken(ref pResolvedToken);
                    var resolver = _compilation.NodeFactory.Resolver;
                    resolver.AddModuleTokenForMethod(method, methodModuleToken);
                    ValidateSafetyOfUsingTypeEquivalenceInSignature(method.Signature);
                }
#else
                _compilation.NodeFactory.MetadataManager.GetDependenciesDueToAccess(ref _additionalDependencies, _compilation.NodeFactory, (MethodIL)methodIL, method);
#endif

                if (pResolvedToken.tokenType == CorInfoTokenKind.CORINFO_TOKENKIND_Await)
                {
                    // in rare cases a method that returns Task is not actually TaskReturning (i.e. returns T).
                    // we cannot resolve to an Async variant in such case.
                    // return NULL, so that caller would re-resolve as a regular method call
                    bool allowAsyncVariant = method.GetTypicalMethodDefinition().Signature.ReturnsTaskOrValueTask();

                    // Don't get async variant of Delegate.Invoke method; the pointed to method is not an async variant either.
                    allowAsyncVariant &= !method.OwningType.IsDelegate;

                    method = allowAsyncVariant
                        ? _compilation.TypeSystemContext.GetAsyncVariantMethod(method)
                        : null;
                }

                if (method != null)
                {
                    pResolvedToken.hMethod = ObjectToHandle(method);
                    pResolvedToken.hClass = ObjectToHandle(method.OwningType);
                }
                else
                {
                    pResolvedToken.hMethod = null;
                    pResolvedToken.hClass = null;
                }
            }
            else
            if (result is FieldDesc)
            {
                FieldDesc field = result as FieldDesc;

                // References to literal fields from IL body should never resolve.
                // The CLR would throw a MissingFieldException while jitting and so should we.
                if (field.IsLiteral)

Review comment (suggestion):
```suggestion
                    allowAsyncVariant = allowAsyncVariant && !method.OwningType.IsDelegate;
```
So that the right side is evaluated only when `ReturnsTaskOrValueTask` returned true.

Code after:
            {
#if !SUPPORT_JIT
                _compilation.TypeSystemContext.EnsureLoadableMethod(method);
#endif

#if READYTORUN
                if (recordToken)
                {
                    ModuleToken methodModuleToken = HandleToModuleToken(ref pResolvedToken);
                    var resolver = _compilation.NodeFactory.Resolver;
                    resolver.AddModuleTokenForMethod(method, methodModuleToken);
                    ValidateSafetyOfUsingTypeEquivalenceInSignature(method.Signature);
                }
#else
                _compilation.NodeFactory.MetadataManager.GetDependenciesDueToAccess(ref _additionalDependencies, _compilation.NodeFactory, (MethodIL)methodIL, method);
#endif

                if (pResolvedToken.tokenType == CorInfoTokenKind.CORINFO_TOKENKIND_Await)
                {
                    // in rare cases a method that returns Task is not actually TaskReturning (i.e. returns T).
                    // we cannot resolve to an Async variant in such case.
                    // return NULL, so that caller would re-resolve as a regular method call
                    bool allowAsyncVariant = method.GetTypicalMethodDefinition().Signature.ReturnsTaskOrValueTask();

                    // Don't get async variant of Delegate.Invoke method; the pointed to method is not an async variant either.
                    allowAsyncVariant = allowAsyncVariant && !method.OwningType.IsDelegate;

                    method = allowAsyncVariant
                        ? _compilation.TypeSystemContext.GetAsyncVariantMethod(method)
                        : null;
                }

                if (method != null)
                {
                    pResolvedToken.hMethod = ObjectToHandle(method);
                    pResolvedToken.hClass = ObjectToHandle(method.OwningType);
                }
                else
                {
                    pResolvedToken.hMethod = null;
                    pResolvedToken.hClass = null;
                }
            }
            else
            if (result is FieldDesc)
            {
                FieldDesc field = result as FieldDesc;

                // References to literal fields from IL body should never resolve.
                // The CLR would throw a MissingFieldException while jitting and so should we.
                if (field.IsLiteral)