Having something like:
data class Article(...)
data class Blog(
val articles: Map<String, Article>
)
private lateinit var blog: Blog
// ... loading Blog from JSON
fun getArticle(id: String): Article {
return blog.articles[id]
}
IDE reports correctly that I can’t return blog.articles[id] since it can be null and I specified return type as non-null and suggests a) to change the return type to Article? or b) add non-null assert call.
When I use ALT+ENTER on the line return blog.articles[id] and select Add non-null assert (!!) call, I get:
return blog.articles!![id]
which is incorrect and should be:
return blog.articles[id]!!
PS: It works correctly when the line is return blog.articles.get(id), so this issue is related to the indexed access operator.