Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Handle generics in methodimpls for default interface methods#20404

Merged
MichalStrehovsky merged 6 commits into
dotnet:masterfrom
MichalStrehovsky:fix16355
Nov 13, 2018
Merged

Handle generics in methodimpls for default interface methods#20404
MichalStrehovsky merged 6 commits into
dotnet:masterfrom
MichalStrehovsky:fix16355

Conversation

@MichalStrehovsky
Copy link
Copy Markdown
Member

@MichalStrehovsky MichalStrehovsky commented Oct 12, 2018

The existing logic looking at MethodImpls to find the default interface implementation was not correct in the presence of generics. The MethodImpl records we build during type load only contain inexact MethodDescs for the declMethod that are not suitable for comparisons.

The fix is to pipe through the token and resolve the declaring method from it at the time of dispatch.

Fixes #16355.
Fixes #20281.
Fixes #16354.

The existing logic looking at MethodImpls to find the default interface implementation was not correct in the presence of generics. The MethodImpl record that we build during type load only contain inexact MethodDescs for the declMethod that are not suitable for comparisons.

The fix is to pipe through the token and resolve the declaring method from it at the time of dispatch.

Fixes #16355.
@MichalStrehovsky MichalStrehovsky added this to the 3.0 milestone Oct 12, 2018
Comment thread src/vm/methodtable.cpp

// We do CanCastToInterface to also cover variance.
// We already know this is a method on the same type definition as the (generic)
// interface but we need to make sure the instantiations match.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Variant dispatch is typically done via a two pass technique. Wherein we first iterate to see if there is an exact match, and then a second iteration through the interfaces (of a particular type) to attempt to do a variant dispatch. Looking at the logic in this function, it appears that the variant matching rules here may not be followed, and the variance test cases added do not appear to cover the exact/inexact matching issue.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue of it ignoring variant interface dispatch rules and not doing two passes is orthogonal to the thing I'm fixing here.

I would prefer to track that in a separate issue/pull request for accounting purposes.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#20452

Copy link
Copy Markdown
Member

@davidwrighton davidwrighton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🕐

@MichalStrehovsky
Copy link
Copy Markdown
Member Author

@dotnet-bot test this please

@MichalStrehovsky
Copy link
Copy Markdown
Member Author

@dotnet-bot test OSX10.12 x64 Checked Innerloop Build and Test

@MichalStrehovsky
Copy link
Copy Markdown
Member Author

@dotnet-bot test OSX10.12 x64 Checked Innerloop Build and Test

Timed out...

@MichalStrehovsky MichalStrehovsky merged commit e95c1f8 into dotnet:master Nov 13, 2018
@MichalStrehovsky MichalStrehovsky deleted the fix16355 branch November 13, 2018 13:01
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
…coreclr#20404)

The existing logic looking at MethodImpls to find the default interface implementation was not correct in the presence of generics. The MethodImpl records we build during type load only contain inexact MethodDescs for the declMethod that are not suitable for comparisons.

The fix is to pipe through the token and resolve the declaring method from it at the time of dispatch.

Commit migrated from dotnet/coreclr@e95c1f8
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

2 participants