Beef icon indicating copy to clipboard operation
Beef copied to clipboard

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

Open Fusioon opened this issue 1 year ago • 0 comments

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 aa4f9f7dfa8f2ad81a6807b87192516d0ce72a1a

Fusioon avatar May 05 '24 20:05 Fusioon