Function literals - scope problem

Hey! I've created the following function:

fun setProp(            currentValueGetter: () -> Int?,            currentValueSetter: (Int?) -> Unit) {

          // getting value
          val oldValue = currentValueGetter();

           // setting value

          currentValueSetter(10);

  }

I'd like to use it inside property:

public var difference : Int? = null
    get() = $difference
    set(value) {
        this.setProp({() -> $difference }, {(v: Int?) -> $difference = v });
     };

Unfortunately, calling setProp causes exception:

java.lang.IllegalAccessError: tried to access field Model.UTPModel.difference from class Model.UTPModel$difference$1

I think it caused by using propery's backing field ($difference). It's a bug or by design? Can I access that field?

This is a bug. I filed an issue in our bugtracker: http://youtrack.jetbrains.com/issue/KT-4867 Thanks for the report

Thanks, I'm looking forward to bug fix.