generics - How to declare a covariant type correctly in Scala? -
I have created a property with the following symptoms and methods (descriptions are omitted):
< Code> property trash [A and lieutenant;: java.io.Serializable] {Def Push (key: string, value: a) = ??? Def bridge (key: string): A = ??? }
The following code is not compiled (the document
class implies java.io.Serializable
, and the list tool Scala.Sableializable
which extends java.io.Serializable
):
Class Docs enhances service waste [list [document]] {. ..}
The error message said something like this: The Cachable [list [document]] type does not correspond to Cachable [A & lt;: java.io.Serializable].
If I understand the issue properly, the compiler means that Cachable [scala.Serializable]
Cachable [java.io.Serializable]
Does not have a subtype.
I thought, & lt ;:
is like the statement of Java?
How can this fix in scale?
Comments
Post a Comment