Open mhsmith opened 3 months ago
It's worse in Kotlin because the Map get/remove/containsKey functions, which apparently used to accept any object like Java, now appear to be fully type-safe. For example, attempting to call pyobject.asMap().containsKey("string")
fails to compile with a type inference error, and the IDE shows it's resolved to an extension function whose purpose is unclear to me.
Ideally we'd like to be able to change this (from Electron Cash):
val iMap = i.asMap()
iMap[fromJava("address")] = fromJava(iMap[fromJava("address")].toString())
To something like this:
val iMap = i.asMap(String::class, Any::class)
iMap["address"] = iMap["address"].toString()
Also consider how element nullability could be expressed, e.g. SendContactsDialog.contacts
in Electron Cash.
This would be particularly helpful in avoiding the need to call
fromJava
when modifying the container. For example, see theos.environ
example on the Java API documentation page.API could be something like
List<T> asList(Class<T> elementType)
-- see note atPyList.set
.