mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Use custom attributes to apply property delegates to variables.
A custom attribute can be resolved to a property delegate type. Allow this for property declarations (only), and diagnose the various places where properties cannot have property delegates.
This commit is contained in:
@@ -5200,6 +5200,14 @@ StaticSpellingKind AbstractStorageDecl::getCorrectStaticSpelling() const {
|
||||
return getCorrectStaticSpellingForDecl(this);
|
||||
}
|
||||
|
||||
CustomAttr *VarDecl::getAttachedPropertyDelegate() const {
|
||||
auto &ctx = getASTContext();
|
||||
auto mutableThis = const_cast<VarDecl *>(this);
|
||||
return evaluateOrDefault(ctx.evaluator,
|
||||
AttachedPropertyDelegateRequest{mutableThis},
|
||||
nullptr);
|
||||
}
|
||||
|
||||
Identifier VarDecl::getObjCPropertyName() const {
|
||||
if (auto attr = getAttrs().getAttribute<ObjCAttr>()) {
|
||||
if (auto name = attr->getName())
|
||||
|
||||
Reference in New Issue
Block a user