Gotyanov
(Gotyanov)
1
I'm trying to implement a macro that expands the following code
class Klass {
@ThreadSafe lazy var value: Int = compute()
func compute() -> Int { 42 }
}
to
class Klass {
var value: Int {
_read {
__macro_local_valueLock.lock()
defer { __macro_local_valueLock.unlock() }
yield __macro_local_value
}
_modify {
__macro_local_valueLock.lock()
defer { __macro_local_valueLock.unlock() }
yield &__macro_local_value
}
}
private nonisolated(unsafe) lazy var __macro_local_value: Int = compute()
private nonisolated let __macro_local_valueLock = UnfairLock()
func compute() -> Int { 42 }
}
but I'm getting an error
'lazy' cannot be used on a computed property
I suppose that the lazy properties aren't being handled.
The compiler removes the initializer for the generated property. Could it also remove the 'lazy' modifier?