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

Validate constraints on created MethodTables #84613

Merged
merged 1 commit into from
Apr 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,16 @@ private static TypeDesc EnsureLoadableTypeUncached(TypeDesc type)
{
ThrowHelper.ThrowTypeLoadException(ExceptionStringID.ClassLoadGeneral, type);
}
}

// TODO: validate constraints
// Don't validate constraints with crossgen2 - the type system is not set up correctly
// and doesn't see generic interfaces on arrays.
#if !READYTORUN
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I peeled this off from #84404. See the failing test leg with crossgen2. This file is shared with crossgen2, but crossgen2 sets up the type system in a way that object[] doesn't implement IEnumerable<object> so we can't run this logic there:

/// <summary>
/// CoreCLR has no Array`1 type to hang the various generic interfaces off.
/// Return nothing at compile time so the runtime figures it out.
/// </summary>
protected override RuntimeInterfacesAlgorithm GetRuntimeInterfacesAlgorithmForNonPointerArrayType(ArrayType type)
{
return BaseTypeRuntimeInterfacesAlgorithm.Instance;
}

if (!defType.IsCanonicalSubtype(CanonicalFormKind.Any) && !defType.CheckConstraints())
{
ThrowHelper.ThrowTypeLoadException(ExceptionStringID.ClassLoadGeneral, type);
}
#endif

// Check the type doesn't have bogus MethodImpls or overrides and we can get the finalizer.
defType.GetFinalizer();
Expand Down