Skip to content
This repository was archived by the owner on Nov 13, 2026. It is now read-only.

Fix signature instantiation for generic method on generic types - #1077

Merged
MichalStrehovsky merged 1 commit into
dotnet:masterfrom
MichalStrehovsky:instantiateSignature
Apr 4, 2016
Merged

MichalStrehovsky merged 1 commit into
dotnet:masterfrom
MichalStrehovsky:instantiateSignature

Conversation

@MichalStrehovsky

Copy link
Copy Markdown
Member

If this is something like Foo<!0>.Generic<Bar<!0>> the call to
GetTypicalMethodDefinition would strip the method instantiation away
and we would lose a piece of the context because method is now
Foo<X>.Generic.

@MichalStrehovsky

Copy link
Copy Markdown
Member Author

(This actually makes me wonder why we're trying to handle everything in MethodDesc instead of splitting this logic into overrides on InstantiatedMethod and MethodForInstantiatedType.)

@jkotas

jkotas commented Apr 2, 2016

Copy link
Copy Markdown
Member

I think to fix this bug, you just need to change Instantiation instantiation = method.Instantiation; to Instantiation instantiation = this.Instantiation;.

@jkotas

jkotas commented Apr 2, 2016

Copy link
Copy Markdown
Member

...and force the GetInstantiatedMethod at the end if necessary. We should not need to do two GetInstantiatedMethod calls.

@MichalStrehovsky

Copy link
Copy Markdown
Member Author

Fixed.

This actually makes me wonder why we're trying to handle everything in MethodDesc

OK, I see the answer to this is "perf" :)

{
method = Context.GetMethodForInstantiatedType(method.GetTypicalMethodDefinition(), (InstantiatedType)instantiatedOwningType);
if (clone == null && HasInstantiation)
return Context.GetInstantiatedMethod(method, Instantiation);

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.

Nit - this could be

if (clone == null && instantiation.Length != 0)
    return Context.GetInstantiatedMethod(method, instantiation);

@jkotas

jkotas commented Apr 4, 2016

Copy link
Copy Markdown
Member

LGTM

If `this` is something like `Foo<!0>.Generic<Bar<!0>>` the call to
`GetTypicalMethodDefinition` would strip the method instantiation away
and we would lose a piece of the context because `method` is now
`Foo<X>.Generic`.
@MichalStrehovsky
MichalStrehovsky merged commit 08e5ab8 into dotnet:master Apr 4, 2016
@MichalStrehovsky
MichalStrehovsky deleted the instantiateSignature branch April 4, 2016 17:34
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.

3 participants