I have a crash, that only happened once in my app, due to an UnsupportedOperationException when I try to add an item to a map. For the stacktrace it seems that an AbstractMap is instantiated instead of a MutableMap. The code is in kotlin:
val productMap: MutableMap<ProductModel, Int> = binding.myView.getProductMap() as? MutableMap<ProductModel, Int> ?: mutableMapOf() presenter.getProduct()?.let { productMap.put(it, 0) }
Could it be that kotlin/java did something weird behind curtains or is there anything I am missing?
The stacktrace:
Fatal Exception: java.lang.UnsupportedOperationException at java.util.AbstractMap.put(AbstractMap.java:218) at com.package.MyView.method2(MyView.java:108) at com.package.MyParentView.method1(MyParentView.java:1278)