mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Allow @NSManaged to be applied to methods.
Core Data synthesizes Key-Value-Coding-compliant accessors for @NSManaged properties, but Swift won't allow them to be called without predeclaring them. In practice, '@NSManaged' on a method is the same as 'dynamic', except you /can't/ provide a body and overriding it won't work. This is not the long-term model we want (see rdar://problem/20829214), but it fixes a short-term issue with an unfortunate workaround (go through mutableOrderedSetValueForKey(_:) and similar methods). rdar://problem/17583057 Swift SVN r30523
This commit is contained in:
@@ -109,13 +109,18 @@ private:
|
||||
if (auto *VD = dyn_cast<ValueDecl>(member))
|
||||
if (VD->isFinal() && VD->getOverriddenDecl() == nullptr)
|
||||
continue;
|
||||
|
||||
|
||||
// @NSManaged properties and methods don't have vtable entries.
|
||||
if (member->getAttrs().hasAttribute<NSManagedAttr>())
|
||||
continue;
|
||||
|
||||
// Add entries for methods.
|
||||
if (auto fn = dyn_cast<FuncDecl>(member)) {
|
||||
// Ignore accessors. These get added when their AbstractStorageDecl is
|
||||
// visited.
|
||||
if (fn->isAccessor())
|
||||
continue;
|
||||
|
||||
addMethodEntries(fn);
|
||||
} else if (auto ctor = dyn_cast<ConstructorDecl>(member)) {
|
||||
// Stub constructors don't get an entry.
|
||||
@@ -128,9 +133,6 @@ private:
|
||||
// FIXME: Stored properties should either be final or have accessors.
|
||||
if (!asd->hasAccessorFunctions()) continue;
|
||||
|
||||
// @NSManaged properties don't have vtable entries.
|
||||
if (asd->getAttrs().hasAttribute<NSManagedAttr>()) continue;
|
||||
|
||||
addMethodEntries(asd->getGetter());
|
||||
if (auto *setter = asd->getSetter())
|
||||
addMethodEntries(setter);
|
||||
|
||||
Reference in New Issue
Block a user