Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected WRN_NullReferenceReturn warning for an async method producing non-generic Task #29957

Open
AlekseyTs opened this issue Sep 17, 2018 · 1 comment

Comments

@AlekseyTs
Copy link
Contributor

        // PROTOTYPE(NullableReferenceTypes): Should not report WRN_NullReferenceReturn for F0.
        [WorkItem(23275, "https://github.com/dotnet/roslyn/issues/23275")]
        [Fact]
        public void AsyncTaskMethodReturningNull()
        {
            var source =
@"#pragma warning disable 1998
using System.Threading.Tasks;
class C
{
    static async Task F0() { return null; }
}";
            var comp = CreateCompilationWithMscorlib46(new[] { source, NonNullTypesTrue, NonNullTypesAttributesDefinition });
            comp.VerifyDiagnostics(
                // (5,30): error CS1997: Since 'C.F0()' is an async method that returns 'Task', a return keyword must not be followed by an object expression. Did you intend to return 'Task<T>'?
                //     static async Task F0() { return null; }
                Diagnostic(ErrorCode.ERR_TaskRetNoObjectRequired, "return").WithArguments("C.F0()").WithLocation(5, 30),
                // (5,37): warning CS8603: Possible null reference return.
                //     static async Task F0() { return null; }
                Diagnostic(ErrorCode.WRN_NullReferenceReturn, "null").WithLocation(5, 37));
        }
@jcouv jcouv added this to the 16.0 milestone Sep 17, 2018
@jaredpar jaredpar added the Bug label Sep 18, 2018
@jaredpar jaredpar added this to Misc in Nullable Board Jan 28, 2019
@gafter gafter modified the milestones: 16.0, 16.1 Feb 26, 2019
@jaredpar jaredpar assigned RikkiGibson and chsienki and unassigned RikkiGibson Apr 9, 2019
@jcouv jcouv modified the milestones: 16.1, 16.2 Apr 23, 2019
@jcouv jcouv modified the milestones: 16.2, 16.3 Jun 25, 2019
@jcouv
Copy link
Member

jcouv commented Jul 11, 2019

Need to confirm whether there is still an issue. Pushing out to Compiler.Next.

@jcouv jcouv modified the milestones: 16.3, Compiler.Next Jul 11, 2019
@jcouv jcouv moved this from Misc to Task<T> in Nullable Board Jan 29, 2020
@jaredpar jaredpar modified the milestones: Compiler.Next, Backlog Sep 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

No branches or pull requests

6 participants