I am trying to limit the scope of classes inside a function. This seems to work:
func foo() { class MyClass { var s = "" } }
I can create instances of MyClass inside the foo () function.
However, when I try to add the @lazy specifier to the property ...
func foo() { class MyClass { @lazy var s = "" } }
... I get the following build errors:
- Global external, but has no external or weak connection!
- Invalid link type for function declaration
- LLVM ERROR: broken module detected, compilation canceled!
Note. If I move the class out of scope, the code compiles:
class MyClass { @lazy var s = "" }
Why does this fail, and how should this error be resolved? If it cannot be resolved, is there another way to use @lazy properties inside functions?
source share