Closed
Description
I'd like to go back from transparent
to the earlier scheme where we used _ <: T
to indicate an upper bound for a result type. So it would be
inline def f: _ <: T = ...
inline given g: _ <: T = ...
for whitebox macros. At the same time, I'd like to allow _ <: T
as an upper bound of other result types as well. E.g.
inline val x: _ <: Byte = 1
would produce a Byte constant, which was not possible before. Similarly, if we assume #9028,
case object a extends B with C with D
def f: _ <: Product = a
f
would get type B with C with D with Product
, so there's not need anymore to list all supertypes.
The rules for this are straightforward
- When inferring the type of a val or def with
_ <: R
result type,R
is taken as the expected type of the right hand side. - The inferred type is then the type of the RHS, widened as usual, with upper bound
R