Open som-snytt opened 1 year ago
are you claiming this isn't behaving as spec'ed.... or you're suggesting a spec change?
The spec is that when the expected type is Byte
, the lexeme with digits is a Byte
, not Int
.
Actually, Scala 2 does not inject any conversion in this case. b
works in Scala 3 only. This change would probably go in the doc page that is still under construction, the one that invites you to watch the old smarter video. Also it's a wonder more people don't complain about Scala 3 ignoring wildcard import of language features. Dotty is like that quirky roommate who wears thin.
class C {
def b[A <: Byte](a: A) = "hi"
def f(x: Byte) = "hi"
}
class D {
val c = new C
val x = "123"
import language._
import language.implicitConversions
implicit def cv(s: String): Byte = java.lang.Byte.parseByte(s)
def test() = {
println {(
c.b(x),
c.f(x),
)}
}
}
object Test extends App {
new D().test()
}
Also the issue template needs to add:
Are you sure this is a bug or did you just have a question?
Reproduction steps
Scala version: 2.13.10
Problem
It's not about me and my expectations.
b
expects aByte
, so52
ought to oblige.