-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Do not generate unconstructed EEType for arrays that have a template #113951
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
Conversation
When `CanonFormTypeMayExist` was written, it was okay for arrays to return false since arrays were always compared structurally (it was allowed to have multiple `MethodTable`s for a single array type). We stopped allowing this some time ago and we now have to maintain the same invariant as for any other `MethodTable` - the address of the `MethodTable` is the unique identity. We cannot allow the compiler to generate unconstructed `MethodTable` for something that can be template-constructed at runtime.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR addresses issue #113750 by ensuring that unconstructed EETypes for arrays with a template are not generated, maintaining the invariant that a MethodTable's address uniquely identifies it. Key changes include adding a new regression test in the SmokeTests to cover this scenario and modifying the EETypeNode logic to correctly handle array types.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/tests/nativeaot/SmokeTests/Reflection/Reflection.cs | Adds the Test113750Regression to validate array behavior under the new invariant |
| src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/EETypeNode.cs | Replaces a generic instantiation check with a specific array type check to enforce the invariant |
Comments suppressed due to low confidence (1)
src/tests/nativeaot/SmokeTests/Reflection/Reflection.cs:1217
- Throwing a plain Exception without a message can make debugging harder. Consider including a descriptive message to clarify the failure condition.
if (!(arr is Atom[]))
| class Atom; | ||
|
|
Copilot
AI
Mar 26, 2025
There was a problem hiding this comment.
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 { }'.
| class Atom; | |
| class Atom { } |
| get | ||
| { | ||
| if (!_type.HasInstantiation) | ||
| if (_type.IsArrayTypeWithoutGenericInterfaces()) |
Copilot
AI
Mar 26, 2025
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks
|
/ba-g timeouts in unrelated leg |
…otnet#113951) When `CanonFormTypeMayExist` was written, it was okay for arrays to return false since arrays were always compared structurally (it was allowed to have multiple `MethodTable`s for a single array type). We stopped allowing this some time ago and we now have to maintain the same invariant as for any other `MethodTable` - the address of the `MethodTable` is the unique identity. We cannot allow the compiler to generate unconstructed `MethodTable` for something that can be template-constructed at runtime.
Fixes #113750
When
CanonFormTypeMayExistwas written, it was okay for arrays to return false since arrays were always compared structurally (it was allowed to have multipleMethodTables for a single array type).We stopped allowing this some time ago and we now have to maintain the same invariant as for any other
MethodTable- the address of theMethodTableis the unique identity. We cannot allow the compiler to generate unconstructedMethodTablefor something that can be template-constructed at runtime.Cc @dotnet/ilc-contrib