Closed as not planned
Description
Compiler version
3.2.0
Minimized code
type LeafElem[X] = X match
case String => Char
case Array[t] => LeafElem[t]
case Iterable[t] => LeafElem[t]
case AnyVal => X
def leafElem[X](x: X): LeafElem[X] = x match
case x: String => x.charAt(0)
case x: Array[t] => leafElem(x(0))
case x: Iterable[t] => leafElem(x.head)
case x: AnyVal => {
val p: LeafElem[X] = x
p
}
Output
the p
is not inferred correctly
Expectation
p
, which has the same type signature as the return type, gets inferred correctly.