Hello,
I just realised that this doesn’t compile (using Kotlin 0.11.1014):
val coll: java.util.Collection<String> = java.util.ArrayList<String>()
I get this error:
Error:(14, 46) Kotlin: Type mismatch: inferred type is java.util.ArrayList<kotlin.String> but java.util.Collection<kotlin.String> was expected
It works when I do an explicit cast:
val coll: java.util.Collection<String> = java.util.ArrayList<String>() as java.util.Collection<String>
It is not clear to me whether this should work or whether I'm missing something. At least, I would expect this to work. It's not intuitive to me why I need to add the cast to java.util.Collection<String>. If someone could illuminate me on this.
Thanks, Oliver