Search code examples
javakotlinintellij-ideaintellij-pluginjava-17

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


Solution

  • 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.