-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Open
Labels
area-NativeAOT-coreclrin-prThere is an active PR which will close this issue when it is mergedThere is an active PR which will close this issue when it is merged
Milestone
Description
-
MakeGenericTypeover reference types is supported in native AOT, so the following should not warn:
void Foo(Type t) {
if (!t.IsValueType)
typeof(G<>).MakeGenericType(t); // currently warns with IL3050
}- Probably the
classconstraint should be supported as well:
void Foo<T>() where T : class {
typeof(G<>).MakeGenericType(typeof(T));
}- We may also want to introduce an annotation to propagate the fact that a type is a reference type across methods, for example:
void Foo(Type t) {
if (!t.IsValueType)
Bar(t);
}
void Bar([ReferenceType] Type t) {
typeof(G<>).MakeGenericType(t);
}(The latter idea is something that has come up in discussion with @vitek-karas and @MichalStrehovsky, not sure if there's another tracking issue for it already.)
Context: https://github.com/dotnet/maui/pull/20058/files/7f4d26ca0aee7dc9d995e9776573125b35ad44b6#r1463169163
Copilot
Metadata
Metadata
Assignees
Labels
area-NativeAOT-coreclrin-prThere is an active PR which will close this issue when it is mergedThere is an active PR which will close this issue when it is merged
Type
Projects
Status
No status