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

[BUG?] Method reference doesn't know/respect parent generic constrains #1967

Open
Fusioon opened this issue May 5, 2024 · 0 comments
Open

Comments

@Fusioon
Copy link
Contributor

Fusioon commented May 5, 2024

Code to reproduce:

static
{
	static int Compare<T, AltT, CompareT>(T lhs, AltT rhs, CompareT comp)
		where CompareT : delegate int (T lhs, AltT rhs)
	{
		return comp(lhs, rhs);
	}

	static int CompareSpaceship<T, AltT>(T lhs, AltT rhs)
		where int : operator T <=> AltT
	{
		return lhs <=> rhs;
	}

	public static int CompareAlt<T>(T lhs)
		where int : operator T <=> T
	{
		//return Compare<T, T, ?>(lhs, lhs, scope (lhs, rhs) => { return lhs <=> rhs; }); 	// Works
		//return Compare<T, T, ?>(lhs, lhs, => CompareSpaceship<T, T>);				// Works
		return Compare<T, T, ?>(lhs, lhs, (lhs, rhs) => { return rhs <=> rhs; });		// Doesn't
	}	
}

Expected behavior is that the lambda version would work the same as CompareSpaceship

Tested with: (Nightly 04/28/2024) Build aa4f9f7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant