I am trying to limit a classes scope to within a function. This seems to work:
func foo() {
class MyClass {
var s = ""
}
}
I can create instances of MyClass within the foo() function.
However, when I attempt to add the @lazy specifier to a property...
func foo() {
class MyClass {
@lazy var s = ""
}
}
... I get the following build errors:
- Global is external, but doesn't have external or weak linkage!
- invalid linkage type for function declaration
- LLVM ERROR: Broken module found, compilation aborted!
Note: If I move the class out of the function's scope, the code compiles:
class MyClass {
@lazy var s = ""
}
Why is this failing, and how should this error be resolved? If it cannot be resolved, is there another way to use @lazy properties inside of functions?