本地委托属性和内联属性不支持增加赋值和增量
如标题: Augment assignment and increment are not supported for local delegated properties ans inline properties
– 我得到这个代码如下:
var timer by someDelegate { } timer += someOtherValue
半小时前完美编译完成。 清理项目并重置Android Studio没有帮助。
这是因为这个功能还没有实现,这不是一个bug,:)。 这里是Kotlin 1.1.3中的StackValue#L1815的源代码,如下所示:
if (stackValue instanceof Delegate) { //TODO need to support throwUnsupportedComplexOperation(((Delegate) stackValue).variableDescriptor); }
为什么该属性可以使用+=
,这是因为Delegate
被getter
/ setter
包装,这意味着它从客户端代码中是不可见的。