Inspectopedia Help

Recursive property accessor

Reports recursive property accessor calls which can end up with a StackOverflowError. Such calls are usually confused with backing field access.

Example:

var counter: Int = 0 set(value) { counter = if (value < 0) 0 else value }

After the quick-fix is applied:

var counter: Int = 0 set(value) { field = if (value < 0) 0 else value }

Inspection Details

Available in:

IntelliJ IDEA 2023.3, Qodana for JVM 2023.3

Plugin:

Kotlin, @snapshot@

Last modified: 13 July 2023