I have a Java object OldFashioned
that extends Java 1.4 List
:
[Java]
class OldFashioned extends List { ... }
That is, OldFashioned
doesn't take any type parameters. I need to add SomeObject
to it. In Java there's no problem, since it treats List
1.4 as List<Object>
1.5 and allows to add any subclasses of Object
to the collection. But Scala doesn't. So next code doesn't work:
[Scala]
val oldFashioned = new OldFashioned()
oldFashioned.add(new SomeObject) // found: SomeObject; required: E
That is, Scala compiler requires to pass type parameters to OldFashioned
that actually doesn't take them:
[Scala]
var oldFashioned: OldFashioned[SomeObject] = null // OldFashioned does not take type parameters
How can I overcome it and add SomeObject
to OldFashined
?