Fix ClassCastException whenever the delegate of a statically compiled closure is changed