This repository was archived by the owner on Nov 1, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 505
Add instantiating unboxing stubs #2566
Merged
MichalStrehovsky
merged 7 commits into
dotnet:master
from
MichalStrehovsky:instUnboxStubs
Jan 27, 2017
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
ab57fc7
Add instantiating unboxing stubs
MichalStrehovsky a2b2b84
Merge branch 'master' into instUnboxStubs
MichalStrehovsky f73ca7c
Add comments
MichalStrehovsky a5c381e
Comments
MichalStrehovsky 1376755
Use InstantiateAsOpen
MichalStrehovsky 26faeaa
Don't generate instantiating unboxing stubs for generic methods
MichalStrehovsky b9111be
Add test
MichalStrehovsky File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -266,11 +266,16 @@ public static MethodDesc FindVirtualFunctionTargetMethodOnObjectType(this TypeDe | |
| } | ||
|
|
||
| /// <summary> | ||
| /// Given Foo<T>, returns Foo<!0>. | ||
| /// Creates an open instantiation of a type. Given Foo<T>, returns Foo<!0>. | ||
| /// If the type is not generic, returns the <paramref name="type"/>. | ||
| /// </summary> | ||
| private static InstantiatedType InstantiateAsOpen(this MetadataType type) | ||
| public static TypeDesc InstantiateAsOpen(this TypeDesc type) | ||
| { | ||
| Debug.Assert(type.IsGenericDefinition); | ||
| if (!type.IsGenericDefinition) | ||
| { | ||
| Debug.Assert(!type.HasInstantiation); | ||
| return type; | ||
| } | ||
|
|
||
| TypeSystemContext context = type.Context; | ||
|
|
||
|
|
@@ -280,7 +285,26 @@ private static InstantiatedType InstantiateAsOpen(this MetadataType type) | |
| inst[i] = context.GetSignatureVariable(i, false); | ||
| } | ||
|
|
||
| return context.GetInstantiatedType(type, new Instantiation(inst)); | ||
| return context.GetInstantiatedType((MetadataType)type, new Instantiation(inst)); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Creates an open instantiation of a field. Given Foo<T>.Field, returns | ||
| /// Foo<!0>.Field. If the owning type is not generic, returns the <paramref name="field"/>. | ||
| /// </summary> | ||
| public static FieldDesc InstantiateAsOpen(this FieldDesc field) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same naming issue as above. I don't have a good name, but I don't like Open. |
||
| { | ||
| Debug.Assert(field.GetTypicalFieldDefinition() == field); | ||
|
|
||
| TypeDesc owner = field.OwningType; | ||
|
|
||
| if (owner.HasInstantiation) | ||
| { | ||
| var instantiatedOwner = (InstantiatedType)owner.InstantiateAsOpen(); | ||
| return field.Context.GetFieldForInstantiatedType(field, instantiatedOwner); | ||
| } | ||
|
|
||
| return field; | ||
| } | ||
|
|
||
| /// <summary> | ||
|
|
@@ -295,7 +319,7 @@ public static MethodDesc InstantiateAsOpen(this MethodDesc method) | |
|
|
||
| if (owner.HasInstantiation) | ||
| { | ||
| MetadataType instantiatedOwner = ((MetadataType)owner).InstantiateAsOpen(); | ||
| MetadataType instantiatedOwner = (MetadataType)owner.InstantiateAsOpen(); | ||
| return method.Context.GetMethodForInstantiatedType(method, (InstantiatedType)instantiatedOwner); | ||
| } | ||
|
|
||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I believe this terminology for Open is quite confusing. It really means instantiate such that if the type parameters from an open instantiation were substituted in, the result would be the same as the type definition. Which is really bizarre. (The open instantiation is used to refer to the uninstantiated form in a number of documents, and is the same thing as the typical instantiation.)