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

Missing warning: the given expression is never of the provided type #26098

Closed
gafter opened this issue Apr 11, 2018 · 2 comments
Closed

Missing warning: the given expression is never of the provided type #26098

gafter opened this issue Apr 11, 2018 · 2 comments

Comments

@gafter
Copy link
Member

gafter commented Apr 11, 2018

In this code

class C<T>
{
    void M(int x)
    {
        if (x is C<T>) { } // warning: the given expression is never of the provided ('C<T>') type.
    }
    void M(C<T> x)
    {
        if (x is int) { } // MISSING warning: the given expression is never of the provided ('int') type.
    }
}

We give a warning where indicated, but are missing the warning on the second case.

@gafter gafter self-assigned this Apr 11, 2018
@gafter gafter added this to the 16.0 milestone Apr 11, 2018
@gafter gafter added the 4 - In Review A fix for the issue is submitted for review. label Apr 11, 2018
@gafter
Copy link
Member Author

gafter commented Apr 11, 2018

The code to detect this (missing) warning is common with the code to detect this case for pattern-matching

    void M(C<T> x)
    {
        if (x is 3) { } // error: input of type 'C<T>' can never match a pattern of type 'int'.
    }

@gafter gafter added this to In Review in Compiler: Pattern-Matching Apr 11, 2018
gafter added a commit to gafter/roslyn that referenced this issue Apr 11, 2018
@gafter
Copy link
Member Author

gafter commented Apr 12, 2018

Fixed in #25995

@gafter gafter closed this as completed Apr 12, 2018
@gafter gafter removed this from In Review in Compiler: Pattern-Matching Apr 12, 2018
@gafter gafter removed 4 - In Review A fix for the issue is submitted for review. labels Dec 18, 2018
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