Open soronpo opened 6 months ago
Dupe of #8739 (at a glance)
I believe this is the expected behaviour. inline def
initions are not inlined within the body of other inline def
s, so when typechecking the body of baz
below we infer the type y
to be Int
:
transparent inline def foo(x: Int): Int = x
transparent inline def bar(x: Int): Int = foo(x)
transparent inline def baz(x: Int): Int =
val y/*: Int*/ = foo(x)
y
val x1 = bar(0): 0 // OK
val x2 = baz(0): 0 // Error
This is not exactly the same situation as in https://github.com/lampepfl/dotty/issues/8739.
Dupe of #8739 (at a glance)
I actually replied with a similar minimization on that issue and completely forgot about it 😃. As I mentioned there, I'm constantly hitting this if it's the same issue. This is not a recursive call though.
It seems that this issue cobined the issue in https://github.com/lampepfl/dotty/issues/8739 and the minimization above and possibly also an extra hurdle with type avoidance.
Notice that { val f = foo; Box[f.Out] }
is ascribed with { val f = foo; Box[f.Out]: Box[?] }
to avoid the local reference to f
.
Compiler version
v3.4.0-RC3
Minimized code
Output
Expectation
No error.