diff --git a/src/coreclr/tools/Common/TypeSystem/Common/MetadataFieldLayoutAlgorithm.cs b/src/coreclr/tools/Common/TypeSystem/Common/MetadataFieldLayoutAlgorithm.cs index 2bf40935a38b60..4109bb701aa9ac 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/MetadataFieldLayoutAlgorithm.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/MetadataFieldLayoutAlgorithm.cs @@ -782,10 +782,9 @@ public LayoutInt CalculateFieldBaseOffset(MetadataType type, bool requiresAlign8 if (!type.IsValueType && type.HasBaseType) { cumulativeInstanceFieldPos = type.BaseType.InstanceByteCountUnaligned; - if (!type.BaseType.InstanceByteCountUnaligned.IsIndeterminate) + if (!cumulativeInstanceFieldPos.IsIndeterminate) { - cumulativeInstanceFieldPos = type.BaseType.InstanceByteCountUnaligned; - if (type.BaseType.IsZeroSizedReferenceType && ((MetadataType)type.BaseType).HasLayout()) + if (requiresAlignedBase && type.BaseType.IsZeroSizedReferenceType && ((MetadataType)type.BaseType).HasLayout()) { cumulativeInstanceFieldPos += LayoutInt.One; } diff --git a/src/coreclr/tools/Common/TypeSystem/Interop/IL/MarshalUtils.cs b/src/coreclr/tools/Common/TypeSystem/Interop/IL/MarshalUtils.cs index 84dcc80be1323e..33c609ee23b807 100644 --- a/src/coreclr/tools/Common/TypeSystem/Interop/IL/MarshalUtils.cs +++ b/src/coreclr/tools/Common/TypeSystem/Interop/IL/MarshalUtils.cs @@ -23,8 +23,8 @@ public static bool IsBlittableType(TypeDesc type) && !baseType.IsWellKnownType(WellKnownType.Object) && !baseType.IsWellKnownType(WellKnownType.ValueType); - // Type is blittable only if parent is also blittable and is not empty. - if (hasNonTrivialParent && (!IsBlittableType(baseType) || baseType.IsZeroSizedReferenceType)) + // Type is blittable only if parent is also blittable. + if (hasNonTrivialParent && !IsBlittableType(baseType)) { return false; } diff --git a/src/coreclr/tools/aot/ILCompiler.TypeSystem.ReadyToRun.Tests/MarshalUtilsTests.cs b/src/coreclr/tools/aot/ILCompiler.TypeSystem.ReadyToRun.Tests/MarshalUtilsTests.cs index c3befa87af72d4..3523f5d62f8e14 100644 --- a/src/coreclr/tools/aot/ILCompiler.TypeSystem.ReadyToRun.Tests/MarshalUtilsTests.cs +++ b/src/coreclr/tools/aot/ILCompiler.TypeSystem.ReadyToRun.Tests/MarshalUtilsTests.cs @@ -74,10 +74,10 @@ public void IsBlittableType_TypeWithBlittableBase_ReturnsTrue(string className) [InlineData("ClassWithExplicitEmptyBase")] [InlineData("ClassWithExplicitEmptySizeZeroBase")] [InlineData("ClassWithSequentialEmptyBase")] - public void IsBlittableType_TypeWithEmptyBase_ReturnsFalse(string className) + public void IsBlittableType_TypeWithEmptyBase_ReturnsTrue(string className) { TypeDesc classWithEmptyBase = _testModule.GetType("Marshalling", className); - Assert.False(MarshalUtils.IsBlittableType(classWithEmptyBase)); + Assert.True(MarshalUtils.IsBlittableType(classWithEmptyBase)); } } } diff --git a/src/tests/issues.targets b/src/tests/issues.targets index e34d49e1455433..06867ff7ee8a1f 100644 --- a/src/tests/issues.targets +++ b/src/tests/issues.targets @@ -123,9 +123,6 @@ https://github.com/dotnet/runtime/issues/48727 - - https://github.com/dotnet/runtime/issues/54316 -