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

Pattern mathing on generic types does not work #18981

Closed
fanoI opened this issue Apr 25, 2017 · 4 comments
Closed

Pattern mathing on generic types does not work #18981

fanoI opened this issue Apr 25, 2017 · 4 comments
Assignees
Labels
Resolution-Duplicate The described behavior is tracked in another issue

Comments

@fanoI
Copy link

fanoI commented Apr 25, 2017

Version Used:
Visual Studio 2017

Steps to Reproduce:

Create a function like this:

     void TestGenericPatternMatching<T>(T anT)
        {
            switch (anT)
            {
                case int v: 
                    break;
               case string s:
                    break;
            }
        }
```cs

**Expected Behavior**:
Pattern matching works

**Actual Behavior**:
The code above does not compiles with a strange error "an expression of type T can not be handled by an int", the match with object is OK but well not really useful (anything matches with object).
@sharwell
Copy link
Member

This looks like a duplicate of #16195. If this is not correct let me know! 👍

@sharwell sharwell added the Resolution-Duplicate The described behavior is tracked in another issue label Apr 25, 2017
@sharwell sharwell self-assigned this Apr 25, 2017
@sharwell
Copy link
Member

📝 Also very relevant is dotnet/csharplang#154.

@fanoI
Copy link
Author

fanoI commented Apr 25, 2017

But then there will be a 7.1 version of C# to download? Or we have to wait until C# 8.0?
It seems really a big bug!

@sharwell
Copy link
Member

@fanoI The milestone indicators say 7.1, but those aren't always correct. Best way to find out would be to ask in one of the linked issues. 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution-Duplicate The described behavior is tracked in another issue
Projects
None yet
Development

No branches or pull requests

2 participants