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

Emit interface generic dictionaries#3658

Merged
MichalStrehovsky merged 1 commit intodotnet:masterfrom
MichalStrehovsky:interfaceDictionary
May 20, 2017
Merged

Emit interface generic dictionaries#3658
MichalStrehovsky merged 1 commit intodotnet:masterfrom
MichalStrehovsky:interfaceDictionary

Conversation

@MichalStrehovsky
Copy link
Member

Generic interface types have a generic dictionary slot like any other
type, except sometimes the slot is null.

We can now call static methods on generic interfaces with a usable
generic context.

Got reminded of this while reading about the planned C# language support
for static methods on interfaces. I didn't want to push on it when #3100
added the logic, but it turns out this is really easy.

Generic interface types have a generic dictionary slot like any other
type, except sometimes the slot is null.

We can now call static methods on generic interfaces with a usable
generic context.

Got reminded of this while reading about the planned C# language support
for static methods on interfaces. I didn't want to push on it when dotnet#3100
added the logic, but it turns out this is really easy.
if (declType.IsInterface || declType.IsCanonicalSubtype(CanonicalFormKind.Any) || factory.LazyGenericsPolicy.UsesLazyGenerics(declType))
if (declType.IsCanonicalSubtype(CanonicalFormKind.Any)
|| factory.LazyGenericsPolicy.UsesLazyGenerics(declType)
|| isInterfaceWithAnEmptySlot)
Copy link
Member

Choose a reason for hiding this comment

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

We should probably find a way to skip adding a dictionary if it doesn't have any contents.

Copy link
Member Author

Choose a reason for hiding this comment

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

That would be a general improvement we can also do for non-interface types - do you want me to do it in this pull request though?

Copy link
Member Author

Choose a reason for hiding this comment

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

(Clarified offline - this is a topic for a future pull request.)

@MichalStrehovsky MichalStrehovsky merged commit 422c171 into dotnet:master May 20, 2017
@MichalStrehovsky MichalStrehovsky deleted the interfaceDictionary branch May 20, 2017 02:37
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