Inference fails to properly use equality evidence #21509
Labels
area:extension-methods
area:typer
itype:language enhancement
needs-sip
A SIP needs to be raised to move this issue/PR along.
Compiler version
3.5.0
Minimized code
Consider the following program:
Two errors are reported about
next
not being a member ofU
in the expressionsself.second.next
, revealing that the compiler failed to findnext
as an extension method ofU
, which should hold under the assumption thatT
is equal toU
.Perhaps more surprisingly, the following changes also result in a type error (changed lines are highlighted with
//!
):The implementation is now incorrect but it should type check. Yet, the compiler complains in the last line about
hasEqualParts
not being a member ofPair[T, T]
, which is clearly not true. Note that the error disappear if:T =:= U
self
as an instance ofPair[T, T]
Output
In the first example:
In the second example:
Expectation
Both version of
hasEqualParts
should type check.The text was updated successfully, but these errors were encountered: