Skip to content

Emit instantiated types as external references if possible #105816

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

Merged
merged 3 commits into from
Aug 2, 2024
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 @@ -91,6 +91,7 @@ public EETypeNode(NodeFactory factory, TypeDesc type)
else if (type.IsCanonicalSubtype(CanonicalFormKind.Any))
Debug.Assert((this is CanonicalEETypeNode) || (this is NecessaryCanonicalEETypeNode));

Debug.Assert(!type.IsGenericParameter);
Debug.Assert(!type.IsRuntimeDeterminedSubtype);
_type = type;
_optionalFieldsNode = new EETypeOptionalFieldsNode(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ internal sealed class NativeLayoutMethodLdTokenVertexNode : NativeLayoutMethodEn
protected override string GetName(NodeFactory factory) => "NativeLayoutMethodLdTokenVertexNode_" + factory.NameMangler.GetMangledMethodName(_method);

public NativeLayoutMethodLdTokenVertexNode(NodeFactory factory, MethodDesc method)
: base(factory, method, 0)
: base(factory, method, method.IsRuntimeDeterminedExactMethod || method.IsGenericMethodDefinition ? 0 : MethodEntryFlags.CreateInstantiatedSignature)
{
}

Expand Down
26 changes: 26 additions & 0 deletions src/tests/nativeaot/SmokeTests/UnitTests/Generics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ internal static int Run()
Test99198Regression.Run();
Test102259Regression.Run();
Test104913Regression.Run();
Test105397Regression.Run();
TestInvokeMemberCornerCaseInGenerics.Run();
TestRefAny.Run();
TestNullableCasting.Run();
Expand Down Expand Up @@ -3629,6 +3630,31 @@ public static void Run()
}
}

class Test105397Regression
{
interface IEnumerable<T> { }

interface ITest<TResult>
{
TReturn UsingDatabaseResult<TState, TReturn>(TState state, Func<TResult, TState, TReturn> @using);
}
class Test<TResult> : ITest<TResult>
{
public TReturn UsingDatabaseResult<TState, TReturn>(TState state, Func<TResult, TState, TReturn> @using)
{
return default;
}
}

struct GenStruct<T> { }

public static void Run()
{
ITest<object> t = new Test<object>();
t.UsingDatabaseResult<IEnumerable<IEnumerable<GenStruct<double>>>, int>(null, (x, y) => 1);
}
}

class TestInvokeMemberCornerCaseInGenerics
{
class Generic<T>
Expand Down