Suggestion: Linting for String interpolation


Hello Kotlin Team,

I am enjoying Kotlin immensely, thank you. It’s truly the Java that we always wanted!
There is one error that keeps happening for me and I think it’s an easy mistake to make. Maybe there could be a compiler / linter warning when you do this: { "selectableImages: $selectableImages.size"}

The dot strongly suggest you want “size” in your String but what you actually get is a toString() of “selectableImages” followed by “.size”. It’s fine that it works this way but I think it’s a common source of error that merrits a warning of some kind.

Thanks for your consideration!
Kind Regards


Currently, IntelliJ automatically surrounds with curly braces the expression if it matches a function or property:

So I think it is more common to make a mistake if you want to write println("List size: $list.size") because IntelliJ will autocomplete to println("List size: ${list.size}")