SR-2673: @NSManaged property can't satisfy protocol requirement (#5141)

Targeted fix for SR-2673: if a potential protocol witness is
@NSManaged, add accessors the NSManaged way, not the stored property
way.

There's probably more weirdness around here, so I'll clone the bug to
go through maybeAddAccessorsToVariable a lot more often. (Lazy
properties could easily be broken in the same way.)
This commit is contained in:
Jordan Rose
2016-10-06 09:44:12 -07:00
committed by GitHub
parent ac3a215d9a
commit 764bf83145
2 changed files with 21 additions and 1 deletions

View File

@@ -820,7 +820,10 @@ void TypeChecker::synthesizeAccessorsForStorage(AbstractStorageDecl *storage,
// If the decl is stored, convert it to StoredWithTrivialAccessors
// by synthesizing the full set of accessors.
if (!storage->hasAccessorFunctions()) {
addTrivialAccessorsToStorage(storage, *this);
if (storage->getAttrs().hasAttribute<NSManagedAttr>())
maybeAddAccessorsToVariable(cast<VarDecl>(storage), *this);
else
addTrivialAccessorsToStorage(storage, *this);
return;
}