Transpiler created Kotlin code:
internal open fun example() {var lazyVariable = l@{ -> return@l Int.random(in_ = 1..10) }private var lazyVariableinitialized = falseprint(lazyVariable)}
Which results in error:
Modifier 'private' is not applicable to 'local variable'
Do you think you could improve your logic for creating lazy variables equivalents in Kotlin so they could also work in function scope, not only the class scope?
Thanks for the report! I'll think about how we might implement this. At the very least we need to issue an unsupported error rather than generating bad code.
I noticed the problem after creating a lazy var inside a function.
Swift:
func example() {
lazy var lazyVariable = { return Int.random(in: 1...10) }
print(lazyVariable)
}
Transpiler created Kotlin code:
internal open fun example() {
var lazyVariable = l@{ -> return@l Int.random(in_ = 1..10) }
private var lazyVariableinitialized = false
print(lazyVariable)
}
Which results in error:
Do you think you could improve your logic for creating lazy variables equivalents in Kotlin so they could also work in function scope, not only the class scope?