Open
Description
Compiler version
3.5.0-RC1-bin-20240405-85672a0-NIGHTLY
Minimized code
opaque type MyInt <: Int = Int
object MyInt:
def apply(v: Int): MyInt = v
def f1[A, B](box: B => A)(unbox: A => B): B = ???
def f2[A, B](box: B => A): B = ???
@main
def main =
val a = f1(MyInt.apply)(identity)
val b = f1(MyInt(_))(identity)
val c = f2(MyInt.apply)
val d = f2(MyInt(_))
Output
The types of a
, b
, c
, and d
are inferred as MyInt
, Int
, Nothing
, and Int
, respectively.
Expectation
In the best possible world, I would like all four vals to be of type Int
because box
is of type Int => MyInt
. Since MyInt <: Int
, I can understand why MyInt
might be inferred, but I would at least expect the types of a
and b
to be the same, and also the types of c
and d
to be the same.