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

See if we can optimize blocks under null checks #111256

Open
MichalStrehovsky opened this issue Jan 9, 2025 · 1 comment
Open

See if we can optimize blocks under null checks #111256

MichalStrehovsky opened this issue Jan 9, 2025 · 1 comment
Assignees
Milestone

Comments

@MichalStrehovsky
Copy link
Member

In the below program we should know that something typed as ITestOutput won't ever be non-null. We should be able to optimize out the null check branch in Foo.

using System;
using System.Runtime.CompilerServices;

class Program
{
    [MethodImpl(MethodImplOptions.NoInlining)]
    static void Foo(ITestOutput? to = null)
    {
        to?.Log("hello");
    }

    static void Main() => Foo(null);
}

interface ITestOutput
{
    void Log(string s);
}

Cc @nagya @jevansaks @EgorBo

@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged by the area owner label Jan 9, 2025
Copy link
Contributor

Tagging subscribers to this area: @agocke, @MichalStrehovsky, @jkotas
See info in area-owners.md if you want to be subscribed.

@EgorBo EgorBo self-assigned this Jan 10, 2025
@EgorBo EgorBo added this to the 10.0.0 milestone Jan 10, 2025
@EgorBo EgorBo removed the untriaged New issue has not been triaged by the area owner label Jan 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

No branches or pull requests

2 participants