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:
Doug Gregor
2019-03-31 20:57:27 -07:00
parent f9c716df87
commit 96279c7044
11 changed files with 342 additions and 0 deletions

View File

@@ -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())