-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Is T expressions result in CS8121 error if sealed class, implementing a generic interface, is used for T #16993
Comments
Hm, ordinary |
Indeed, it's only when the new |
I notice you have only tagged this as "Area-Language-Design", rather than as a bug. Does this mean that the |
Just trying to get it closer to the right people looking at it :) |
Also note that the "use pattern matching" analyzer produces an incorrect code fix (IDE0019) that results in non-compilable code in these cases. |
tagging @gafter I believe this is a manifestation of dotnet/csharplang#154, which is something he's aware of and which we're taking a fix for for 7.1. However, i'ts not 100% clear to me this is the same issue. So i'd like him to weigh in. |
The simple way to demonstrate that this is the same issue is to see if you get an error when the body of F is rewritten this way: //if (x is Test1 z) { }
var z = (Test1)x;
//if (x is Test2 y) { }
var y = (Test2)x; Indeed, the second cast results in an error. So this is a dup of dotnet/csharplang#154 |
Visual C# 2017 RC 00369-50000-00000-AA146
Visual Studio/15.0.0-RC.3+26127.3:
Steps to Reproduce:
Attempt to compile the following code:
Expected Behavior:
All compiles OK.
Actual Behavior:
The
if (x is Test2 y) { }
line results in the error:CS8121 An expression of type ITest<T> cannot be handled by a pattern of type Test2
The text was updated successfully, but these errors were encountered: