Skip to content

Fix MethodImpl decl method processing#38310

Merged
davidwrighton merged 8 commits intodotnet:masterfrom
davidwrighton:fix_methodimpl_decl
Jun 26, 2020
Merged

Fix MethodImpl decl method processing#38310
davidwrighton merged 8 commits intodotnet:masterfrom
davidwrighton:fix_methodimpl_decl

Conversation

@davidwrighton
Copy link
Member

  • Require a signature that matches the actual target method definition
  • Except for using MethodImpl records that point at base type
    • In that case, apply Substitution to provide a signature matching
      environment that matches the parent type in the MemberRef

This change allows specifying an unambiguous target when there was
previously potential for ambiguity in the presence of generics and
MethodImpl records.

- Require a signature that matches the actual target method definition
- Except for using MethodImpl records that point at base type
  - In that case, apply Substitution to provide a signature matching
  environment that matches the parent type in the MemberRef

This change allows specifying an unambiguous target when there was
previously potential for ambiguity in the presence of generics and
MethodImpl records.
@davidwrighton
Copy link
Member Author

This change needs additional tests, as well as validation that this doesn't break any of the existing language compilers going back several versions.

@davidwrighton
Copy link
Member Author

@janvorli This is the fix I've come up with for addressing issue #38119. Its a little more impactful than I had thought, so we'll need to write more extensive testing for it before we can consider checking it in.

@lambdageek I'd like to make sure that once I get this put together I write a some tests that cover some of the corner cases of what this logic does. Could you point me at some documentation that would make it easy to run some of the new tests I'm going to write on Mono?

@lambdageek
Copy link
Member

@lambdageek I'd like to make sure that once I get this put together I write a some tests that cover some of the corner cases of what this logic does. Could you point me at some documentation that would make it easy to run some of the new tests I'm going to write on Mono?

Just add them to src/coreclr/tests as usual. They will run as part of the "runtime (Mono Pri0 Runtime Tests Run OSX x64 release) " checks in CI. If you need to disable them, there's a section for Mono in issues.rsp

@davidwrighton
Copy link
Member Author

@lambdageek, the new test passes on Mono for the 99% case, but for the scenario where the overridden method on the base type is moved to its parent type, when not running the interpreter, the mono runtime fails. I've added an exclusion to the issues.rsp, so to allow checkin, but I don't consider it to be a significant problem worth holding the work up. (Moving methods like that is extremely rare in practice, but it is considered a backwards compatible change, and the framework team has made such moves in the past.)

Copy link
Member

@janvorli janvorli left a comment

Choose a reason for hiding this comment

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

I have just a couple of nits.


Substitution *pDeclSubst = &bmtMetaData->pMethodDeclSubsts[m];
MethodSignature declSig(GetModule(), szName, pSig, cbSig, pDeclSubst);
MethodSignature declSig(GetModule(), szName, pSig, cbSig, NULL);
Copy link
Member

Choose a reason for hiding this comment

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

It looks like the pDeclSubst is not used anywhere after this change.

// If the declaration method is a part of an interface, search through
// the interface map to find the matching interface so we can provide
// the correct substitution chain.
pDeclType = NULL;
Copy link
Member

Choose a reason for hiding this comment

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

A nit - this was set to NULL on the previous line, maybe just move the variable declaration here?

declSig.GetSignature(),
static_cast<DWORD>(declSig.GetSignatureLength()),
declSig.GetModule(),
NULL, // Do not use the substitution of declSig, as we have adjusted the pDeclTypeSubstituion such that it must not be used.
Copy link
Member

Choose a reason for hiding this comment

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

A nit

Suggested change
NULL, // Do not use the substitution of declSig, as we have adjusted the pDeclTypeSubstituion such that it must not be used.
NULL, // Do not use the substitution of declSig, as we have adjusted the pDeclTypeSubstitution such that it must not be used.

@davidwrighton davidwrighton marked this pull request as ready for review June 25, 2020 22:41
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants