In case of Right(3)
and "something"
the common type is java.io.Serializable
, so I think the issue is with choosing the candidate of type inference, not the subclassing itself.
As per interfacing the dynamic languages, for example JavaScript, the benefit of using languages like Scala.JS and TypeScript is because they have stronger type system to check programming errors, not because it’s permissible to Option(2)
getting mixed up with Int
. If people wanted that, they would use JavaScript itself. In situations where List[Any]
is actually wanted, we can ask people to write Option(2): Any
.
This should also improve situations such as List(1, 2, 3).contains("wat")
- Type-safe contains.
In Scala 2.x that would’ve caused too much false positives for ADTs, but thanks to Eq
, I don’t think it’s that far fetched of an idea.