Your code is invalid. It will cause a stack overflow (the setter recursively calls itself). You should use the field
identifier to access the property’s storage.
var propertyWithCounter: Int? = null
set(value:Int?) {
counter++
field = value
}
Given this, the error message is not helpful. Something that provides better diagnostics would be very helpful.