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

Exception on MakeGenericMethod called on a static interface method from GetInterfaceMap's TargetMethods for a default interface implementation #90863

Closed
hamarb123 opened this issue Aug 20, 2023 · 2 comments · Fixed by #98790
Assignees
Labels
area-TypeSystem-coreclr disabled-test The test is disabled in source code against the issue
Milestone

Comments

@hamarb123
Copy link
Contributor

Description

When you have a generic interface I2<S>, providing a default interface implementation for a generic method void G<T>() on a generic interface I1<S>, and you have a class C2Implicit<S> which implements I2<S> implicitly, and then you call GetInterfaceMap on a specific generic instantiation of these (e.g., I1 and C2Implicit<string>), the the target method for void I1<S>.G<T>() is invalid.

Reproduction Steps

var x1 = typeof(I2<string>).GetMethod("I1<S>.G", (BindingFlags)(-1));
var x2 = typeof(C2<string>).GetInterfaceMap(typeof(I1<string>)).TargetMethods.Single((x) => x.Name == "I1<S>.G");
Console.WriteLine(x1 == x2);
Console.WriteLine(x1.MakeGenericMethod(typeof(int)).ContainsGenericParameters);
Console.WriteLine(x2.MakeGenericMethod(typeof(int)).ContainsGenericParameters);

interface I1<S>
{
	static abstract void G<T>();
}

interface I2<S> : I1<S>
{
	static void I1<S>.G<T>() { }
}

class C2<S> : I2<S>
{
}

Expected behavior

Prints:

True
False
False

Actual behavior

False
False
Unhandled exception. System.InvalidOperationException: Void I1<S>.G[T]() is not a GenericMethodDefinition. MakeGenericMethod may only be called on a method for which MethodBase.IsGenericMethodDefinition is true.
   at System.Reflection.RuntimeMethodInfo.MakeGenericMethod(Type[] methodInstantiation)

Regression?

No response

Known Workarounds

No response

Configuration

No response

Other information

Follow up to #90351 (comment) and #90518 (comment)

@ghost ghost added the untriaged New issue has not been triaged by the area owner label Aug 20, 2023
@hamarb123
Copy link
Contributor Author

A fix to this should remove the "[ActiveIssue]" in 7dbb3ea.

@jkotas jkotas added the disabled-test The test is disabled in source code against the issue label Aug 21, 2023
@mangod9 mangod9 removed the untriaged New issue has not been triaged by the area owner label Aug 31, 2023
@mangod9 mangod9 added this to the 9.0.0 milestone Aug 31, 2023
@lambdageek
Copy link
Member

/cc @steveisok

@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Feb 23, 2024
@kg kg closed this as completed in #98790 Feb 27, 2024
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Feb 27, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Mar 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-TypeSystem-coreclr disabled-test The test is disabled in source code against the issue
Projects
None yet
6 participants