Skip to content
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

Define equals manually for Swift JitInterface InlineArray types. #104843

Merged
merged 8 commits into from
Jul 18, 2024
41 changes: 41 additions & 0 deletions src/coreclr/tools/Common/JitInterface/CorInfoTypes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1529,6 +1529,47 @@

public nint numLoweredElements;

public override bool Equals(object obj)
{
if (obj is not CORINFO_SWIFT_LOWERING other)
{
return false;
}

if (byReference != other.byReference)
{
return false;
}

// If both are by-ref, the rest of the bits mean nothing.
if (byReference)
{
return true;
}

return LoweredElements.Slice(0, (int)numLoweredElements).SequenceEqual(other.LoweredElements.Slice(0, (int)other.numLoweredElements);

Check failure on line 1550 in src/coreclr/tools/Common/JitInterface/CorInfoTypes.cs

View check run for this annotation

Azure Pipelines / runtime (Build tvos-arm64 Release AllSubsets_NativeAOT)

src/coreclr/tools/Common/JitInterface/CorInfoTypes.cs#L1550

src/coreclr/tools/Common/JitInterface/CorInfoTypes.cs(1550,145): error CS1026: (NETCORE_ENGINEERING_TELEMETRY=Build) ) expected

Check failure on line 1550 in src/coreclr/tools/Common/JitInterface/CorInfoTypes.cs

View check run for this annotation

Azure Pipelines / runtime (Build tvos-arm64 Release AllSubsets_NativeAOT)

src/coreclr/tools/Common/JitInterface/CorInfoTypes.cs#L1550

src/coreclr/tools/Common/JitInterface/CorInfoTypes.cs(1550,146): error CS1525: (NETCORE_ENGINEERING_TELEMETRY=Build) Invalid expression term '&&'

Check failure on line 1550 in src/coreclr/tools/Common/JitInterface/CorInfoTypes.cs

View check run for this annotation

Azure Pipelines / runtime (Build ios-arm64 Release AllSubsets_NativeAOT)

src/coreclr/tools/Common/JitInterface/CorInfoTypes.cs#L1550

src/coreclr/tools/Common/JitInterface/CorInfoTypes.cs(1550,145): error CS1026: (NETCORE_ENGINEERING_TELEMETRY=Build) ) expected

Check failure on line 1550 in src/coreclr/tools/Common/JitInterface/CorInfoTypes.cs

View check run for this annotation

Azure Pipelines / runtime (Build ios-arm64 Release AllSubsets_NativeAOT)

src/coreclr/tools/Common/JitInterface/CorInfoTypes.cs#L1550

src/coreclr/tools/Common/JitInterface/CorInfoTypes.cs(1550,146): error CS1525: (NETCORE_ENGINEERING_TELEMETRY=Build) Invalid expression term '&&'
&& Offsets.Slice(0, (int)numLoweredElements).SequenceEqual(other.Offsets).Slice(0, (int)other.numLoweredElements);
}

public override int GetHashCode()
{
HashCode code = new HashCode();
code.Add(byReference);

if (byReference)
{
return code.ToHashCode();
}

for (int i = 0; i < numLoweredElements; i++)
{
code.Add(LoweredElements[i]);
code.Add(Offsets[i]);
}

return code.ToHashCode();
}

// Override for a better unit test experience
public override string ToString()
{
Expand Down
Loading