Inspectopedia Help

Delegating to 'var' property

Reports interface delegation to a var property.

Only initial value of a property is used for delegation, any later assignments do not affect it.

Example:

class Example(var text: CharSequence): CharSequence by text

The quick-fix replaces a property with immutable one:

class Example(val text: CharSequence): CharSequence by text

Alternative way, if you rely on mutability for some reason:

class Example(text: CharSequence): CharSequence by text { var text = text }

Inspection Details

Available in:

IntelliJ IDEA 2023.3, Qodana for JVM 2023.3

Plugin:

Kotlin, @snapshot@

Last modified: 13 July 2023