val x: AnyRef = 42
type mismatch: found
Int(42)
required:AnyRef
Note: an implicit exists from
scala.Int => java.lang.Integer
, but methods inherited fromObject
are rendered ambiguous. This is to avoid a blanket implicit which would convert anyscala.Int
to anyAnyRef
.You may wish to use a type ascription:
x: java.lang.Integer
I don't understand the emphasized part. What methods are rendered ambiguous, and how come? Are methods inherited from Object always "rendered ambiguous" in Scala? Is this a special scenario where methods somehow wind up multiple times in a type? I just don't see where the ambiguity comes from.