-
Notifications
You must be signed in to change notification settings - Fork 128
Correctness fixes to interface stripping #1305
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This is actually 3 separate things: * Bugfix in linker where linker was stripping type `Foo` despite the program containing a `new Foo[x,y]` statement. * If a type is used as an array element or as a generic argument, don't strip any of its interfaces because they might be necessary for variant casting later. * If a type is visible from reflection, don't strip any of its interfaces. Fixes dotnet#1235.
@@ -2652,6 +2670,9 @@ protected virtual void MarkInstruction (Instruction instruction, MethodDefinitio | |||
} | |||
|
|||
case OperandType.InlineType: | |||
if (instruction.OpCode.Code == Code.Newarr) { | |||
Annotations.MarkRelevantToVariantCasting (((TypeReference) instruction.Operand).Resolve ()); |
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.
Resolve
may return null - in which case we will add null to the HashSet
in Annotations
. I guess it doesn't matter that much, but it might be cleaner to check for null in the MarkRelevantToVariantCasting
before adding it to the hashset.
@@ -2652,6 +2671,9 @@ protected virtual void MarkInstruction (Instruction instruction, MethodDefinitio | |||
} | |||
|
|||
case OperandType.InlineType: | |||
if (instruction.OpCode.Code == Code.Newarr) { |
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.
Are you sure this is the only relevant opcode? What about code like var foos = (IFoo[]) Array.CreateInstance (typeof (Foo), 1);
?
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.
That pattern should be fine because the typeof(Foo)
means "visible to reflection" and that's handled elsewhere in this pull request.
This is actually 3 separate things: * Bugfix in linker where linker was stripping type `Foo` despite the program containing a `new Foo[x,y]` statement. * If a type is used as an array element or as a generic argument, don't strip any of its interfaces because they might be necessary for variant casting later. * If a type is visible from reflection, don't strip any of its interfaces. Fixes dotnet/linker#1235. Commit migrated from dotnet/linker@c66de69
This is actually 3 separate things:
Foo
despite the program containing anew Foo[x,y]
statement. I hit this while writing tests for this.Fixes #1235.