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

Do not generate unconstructed EEType for arrays that have a template #113951

Merged
merged 1 commit into from
Mar 28, 2025
Merged
Show file tree
Hide file tree
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 @@ -253,7 +253,7 @@ private bool CanonFormTypeMayExist
{
get
{
if (!_type.HasInstantiation)
if (_type.IsArrayTypeWithoutGenericInterfaces())
Copy link
Preview

Copilot AI Mar 26, 2025

Choose a reason for hiding this comment

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

Consider adding a clarifying comment here to explain why array types without generic interfaces should immediately return false, aiding future maintenance.

Copilot is powered by AI, so mistakes are possible. Review output carefully before use.

return false;

if (!_type.Context.SupportsCanon)
Expand Down
17 changes: 17 additions & 0 deletions src/tests/nativeaot/SmokeTests/Reflection/Reflection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ private static int Main()
TestTypesInMethodSignatures.Run();

TestAttributeInheritance.Run();
Test113750Regression.Run();
TestStringConstructor.Run();
TestAssemblyAndModuleAttributes.Run();
TestAttributeExpressions.Run();
Expand Down Expand Up @@ -1202,6 +1203,22 @@ public ClassToConstruct(int i)
}
}

class Test113750Regression
{
class Atom;

Comment on lines +1208 to +1209
Copy link
Preview

Copilot AI Mar 26, 2025

Choose a reason for hiding this comment

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

The declaration 'class Atom;' is incomplete in C# and may cause a compilation error. It should be defined with a body, e.g., 'class Atom { }'.

Suggested change
class Atom;
class Atom { }

Copilot is powered by AI, so mistakes are possible. Review output carefully before use.

public static void Run()
{
var arr = Array.CreateInstance(GetAtom(), 0);

[MethodImpl(MethodImplOptions.NoInlining)]
static Type GetAtom() => typeof(Atom);

if (!(arr is Atom[]))
throw new Exception();
}
}

class TestStringConstructor
{
public static void Run()
Expand Down
Loading