-
Notifications
You must be signed in to change notification settings - Fork 823
Disallow calling abstract methods directly on interfaces #16319
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
Disallow calling abstract methods directly on interfaces #16319
Conversation
…hub.com:edgarfgp/fsharp into disallow-calling-methods-directly-on-interfaces
|> shouldFail | ||
|> withDiagnostics [ | ||
(Error 3861, Line 13, Col 71, Line 13, Col 79, "Interfaces cannot access static abstract members directly.") | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's not right, constrained calls 'T.Parse
should work through multiple levels of inheritance, since it will know specific implementation at runtime. ISpanParsable<'T>.Parse
, if it's non-virtual, shouldn't on other hand.
Thanks for changing it @edgarfgp, do you think it makes sense to just filter those out as non-valid methods or is it just me? It's a quite unique and new situation, since we don't really have it for non-statics. |
Also, a reminder for myself for Monday: test that we still have autocomplete on type constrained call, e.g. |
I think the static nature of this methods will raise the expectation of been available through competition in a type tbh and it that case a dedicated error message explaining the reasoning of this behaviour will be desirable. That being said in this PR my main focus is to prevent the runtime errors currently happening. |
Could you also check the filtering condition please. I haven’t found yet a way to make this test pass. |
Do we really want for it to be available via completion, it it will lead to the compile time error? I.e. not usable if it's non-virtual? |
❗ Release notes required
|
Replaced by #17021 |
Fixes #14012
See:
https://source.dot.net/#System.Private.CoreLib/src/libraries/System.Private.CoreLib/src/System/Numerics/IAdditionOperators.cs,5b77e6b404819054