How is SwiftUI entry macro possible?

Hey everyone! Since the computed property requires explicit type annotation, how is the code produced by SwiftUI Entry macro valid? The result from macro expansion written by hand gets a compiler error.

There's a special case in macros (which really should be documented somewhere) that the compiler will determine the type of the property from the initializer, even if a macro turns the property into a computed property, effectively erasing the initializer.

6 Likes

Got it, thanks for the explanation!