Open mateoatr opened 2 years ago
I just remembered there was a problem when I introduced this optimization in IL Linker. CoreLib does an Unsafe.As<SomeNeverAllocatedType>()
cast and then accesses a field on the result of the cast but we stripped the unused fields from it, making things misaligned.
The fix was to also keep all the instance fields if any instance field on an Sequential/Explicit reference type is kept.
Maybe a good fix for that would be to:
InstanceFieldLayoutNode
that will be similar to ConstructedTypeNode
except: No conditional static dependencies on this one, and the static dependencies are all the instance fields + the InstanceFieldLayoutNode of the base type.
This was a TODO in TypeDefinitionNode.cs