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

Refactoring "invert if (recursively)" causes compiler error #1131

Open
josefpihrt opened this issue Jul 25, 2023 · 0 comments
Open

Refactoring "invert if (recursively)" causes compiler error #1131

josefpihrt opened this issue Jul 25, 2023 · 0 comments

Comments

@josefpihrt
Copy link
Collaborator

Product and Version Used: 4.3.0

Before:

class C
{
    void M(bool p, bool q, bool r)
    {
        if (r) // Invoke "Invert if (recursively)" here
        {
            if (p)
            {
                var x = 1;
                M2();
            }

            if (q)
            {
                var x = 2;
                M2();
            }
        }
    }

    void M2()
    {
    }
}

After:

class C
{
    void M(bool p, bool q, bool r)
    {
        if (!r)
        {
            return;
        }

        if (p)
        {
            var x = 1; // compiler error here
            M2();
        }

        if (!q)
        {
            return;
        }

        var x = 2;
        M2();
    }

    void M2()
    {
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant