Skip to content

Commit

Permalink
Try to fix Native AOT
Browse files Browse the repository at this point in the history
  • Loading branch information
stephentoub committed Jul 18, 2024
1 parent 58e341d commit 3ae4df4
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,17 @@ public static MethodIL EmitIL(
{
ceArgType = method.Context.GetWellKnownType(WellKnownType.Object);
}
else if ((tType.IsPrimitive || tType.IsEnum) && (tType.UnderlyingType.Category is not (TypeFlags.Single or TypeFlags.Double)))
else if (tType.IsPrimitive || tType.IsEnum)
{
int size = tType.GetElementSize().AsInt;
Debug.Assert(size is 1 or 2 or 4 or 8);
ceArgType = size switch
{
1 => method.Context.GetWellKnownType(WellKnownType.Byte),
2 => method.Context.GetWellKnownType(WellKnownType.UInt16),
4 when tType.UnderlyingType.Category is TypeFlags.Single => method.Context.GetWellKnownType(WellKnownType.Single),
4 => method.Context.GetWellKnownType(WellKnownType.Int32),
_ when tType.UnderlyingType.Category is TypeFlags.Double => method.Context.GetWellKnownType(WellKnownType.Double),
_ => method.Context.GetWellKnownType(WellKnownType.Int64),
};
}
Expand Down

0 comments on commit 3ae4df4

Please sign in to comment.