I started off with the tutorial for learning Kotlin in IntelliJ.When I tried running the example i.e
fun main(args: Array) {
prin
I had this issue because the linter was printing that my object was an instance of Foo whereas the compiler couldn't define its type and consider it was an Any object like (It was more complex in my case, the linter show error in below code but the idea is here) :
class Foo {
val bar: Int = 0
}
fun test(): Any {
return Foo()
}
val foo = test()
foo.bar // <-- Linter consider that foo is an Instance of Foo but not the compiler because it's an Any object so it show the error at compilation.
To fix it I had to cast my object :
val foo = test() as Foo