Kotlin: 'This type has a constructor and thus must be initialized here', but no constructor is declared

Viewed 13907

Recently started with Kotlin

According to Kotlin docs, there can be one primary constructor and one or more secondary constructor.

I don't understand why I see this error enter image description here

Since class test has no primary constructor.

This works fine:

open class test {
}

class test2 : test() {
}

And here is another difficulty I have faced, when I define a secondary constructor the IDE shows another error saying

Supertype initialization is impossible without primary constructor enter image description here

But in the previous working example, I did initialize it, yet it worked fine. What did I get wrong?

1 Answers
Related