-
Notifications
You must be signed in to change notification settings - Fork 5k
Fixed ILVerify incorrectly flagging valid default interface implementations #61185
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
Conversation
Tagging subscribers to this area: @JulieLeeMSFT Issue DetailsThis PR fixes #46236 I moved tests regarding default implementation to a new file for visibility. If this is an undesired change, let me know and I'll revert it. The following test still fails, even though the default interface method that is re-abstracted in
|
// If no base type contains interface method, attempt to find default implementation | ||
if (result == null) | ||
{ | ||
_ = thisType.ResolveInterfaceMethodToDefaultImplementationOnType(interfaceMethodToResolve, out result); | ||
} | ||
|
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.
ILVerify needs to call ResolveInterfaceMethodToDefaultImplementationOnType
manually after this resolution fails; it cannot be done in this method. There are nuances around default interface method resolution that will not work as expected if this is done here. The nuances might not affect ILVerify right now, but will affect it eventually.
E.g. if we want to do reporting of diamond cases in ILVerify (when multiple interfaces on the type provide a default implementation for a method), we'll have to call into ResolveInterfaceMethodToDefaultImplementationOnType manually anyway.
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.
(This change breaks other consumers of TypeSystemHelper.cs)
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.
Could you elaborate on what you mean with ILVerify needs to call ResolveInterfaceMethodToDefaultImplementationOnType manually after this resolution fails
? Why is it a problem that ILVerify needs to call the method after the resolution fails? Does the method affect state in some way, meaning a second call won't succeed anymore?
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.
ResolveInterfaceMethodTarget
(which is in a source file shared with other components in this repo and not unique to ILVerify) should not call ResolveInterfaceMethodToDefaultImplementationOnType
. Instead ILVerify should call ResolveInterfaceMethodToDefaultImplementationOnType
when ResolveInterfaceMethodTarget
returns null.
This is how other components do this as well. We don't want to hide failure modes that are unique to default interface methods here (I'm referring to the value returned from ResolveInterfaceMethodToDefaultImplementationOnType
that is being swallowed here).
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.
Right I think I understand correctly now. So would it be sufficient to move the call to ResolveInterfaceMethodToDefaultImplementationOnType
into VerifyInterfaces
if ResolveInterfaceMethodTarget
returns null
?
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.
Yes, that sound good. It will also put ILVerify into a better position to report unique error messages for things like the diamond case.
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.
Thank you! I adjusted the callsite of ResolveInterfaceMethodToDefaultImplementationOnType
. Apologies for misunderstanding your original comment, thank you for elaborating :)
I'll create another issue for the bug mentioned in this PR's description.
…erfaceMethodTarget
@MichalStrehovsky Is there anything else to be done for this PR? Are we good to merge this PR? |
The change no longer touches any of the files I own (which was the reason I looked at it in the first place). The change in ILVerify looks good. I didn't look at the tests. |
/azp run runtime-coreclr outerloop |
Azure Pipelines successfully started running 1 pipeline(s). |
@bbartels Thank you! |
This PR fixes #46236
I moved tests regarding default implementation to a new file for visibility. If this is an undesired change, let me know and I'll revert it.
The following test still fails, even though the default interface method that is re-abstracted in
IReabstractDefaultImplementation
is implemented within the class. I will open another issue for this scenario./cc @EgorBo
/cc @jkotas