This appears to be about companion objects.
This doesn’t compile:
class Foo
fun foo() {
Foo // Error: Please specify constructor invocation; classifier 'Foo' does not have a companion object
}
But this compiles (without warning):
class Foo {
companion object
}
fun foo() {
Foo
}
On the whole, unless I’m mistaken about what’s going on here, it seems to me that Kotlin should be warning about the unused expression in the second example above. Why isn’t it?