I would expect this to come with build-time evaluation so life will be easier and we can quickly expand the usage. As for now the feature is still too "weak" to be utilized.
I still don’t quite like the idea of an attribute. Is there any reason that we cannot make it a part of the type system? That is, we can have a series of new types called const P (combined using existing any P rules), and, like how we’re using non-async functions as async, allow implicit transformation from const P to P?
Consider the following example:
@propertyWrapper
struct SpecialSerializationSauce {
init(key: const String) {...}
}
// compiles because string literal is inferred as `const String`
struct Foo {
@SpecialSerializationSauce(key: "title")
var someSpecialTitleProperty: String
}
P.S. If there’re any source-breaking issues, we can delay the const-prioritized inference to Swift 6.
1 Like