Open
Description
Consider the following behavior, post SIP23 implementation.
def fooInt[T <: Int](t : T) : T = t
def fooXInt[T <: Int with Singleton](t : T) : T = t
val one = 1
fooInt(1) //Int = 1
fooInt(one) //Int = 1
fooXInt(1) //Int(1) = 1
fooXInt(one) //fails
The above forces the user to express two different functions, if the narrow literal type information needs to be preserved, in case a literal is used.
Can this be considered a bug? To resolve this we need to either change the widening semantics or add some kind of language construct that forces the narrowed type.
also discussed briefly at: https://gitter.im/typelevel/scala?at=5ad895596bbe1d273902766d
Metadata
Metadata
Assignees
Labels
No labels