I have a Scala code that uses existential types, which I upgrade to 2.10, and I noticed a warning about adding "import language.existentials", which makes me think that there should be a better way to write this. The code that I have comes down to:
class A { private var values = Set.empty[(Class[_], String)] def add(klass: Class[_], id: String) { val key = (klass, id) if (!values(key)) { values += key
I get this warning:
[warn] test.scala:4 inferred existential type (Class[_$2], String) forSome { type _$2 }, which cannot be expressed by wildcards, should be enabled [warn] by making the implicit value language.existentials visible. [warn] This can be achieved by adding the import clause 'import language.existentials' [warn] or by setting the compiler option -language:existentials. [warn] See the Scala docs for value scala.language.existentials for a discussion [warn] why the feature should be explicitly enabled. [warn] val key = (klass, id)
Is there a way in which I can rewrite my code, not generate this warning (or require import), or is this the most idiomatic way to express it? I never ask about a parameter of type Class anywhere in the code.
Mike
source share