user19320502
user19320502

Reputation:

Why Is Intellij Suggesting I Make A Private Field Private in Kotlin?

Why is Intellij suggesting I make a private field private? Am I not understanding this correctly or is it just a bug? I have posted a picture of the error and the decompiled class below. Is this something I should heed or ignore?

enter image description here

enter image description here

Upvotes: 0

Views: 162

Answers (1)

laalto
laalto

Reputation: 152917

It is a suggestion about the property, not the field. In Java side a property is essentially a field and its accessor methods.

If you changed val s to private val s, the decompiled class would have private visibility for the getS() accessor rather than public.

Upvotes: 1

Related Questions