Skip to content

Commit 31435b2

Browse files
authored
Merge pull request #64292 from DougGregor/move-only-types-opaque-read-ownership-cycle-break-ugly
Break cycle with OpaqueReadOwnershipRequest and @objc property selectors
2 parents ad3fec4 + b829e86 commit 31435b2

File tree

3 files changed

+39
-2
lines changed

3 files changed

+39
-2
lines changed

lib/AST/Decl.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6309,7 +6309,7 @@ getNameFromObjcAttribute(const ObjCAttr *attr, DeclName preferredName) {
63096309
ObjCSelector
63106310
AbstractStorageDecl::getObjCGetterSelector(Identifier preferredName) const {
63116311
// If the getter has an @objc attribute with a name, use that.
6312-
if (auto getter = getOpaqueAccessor(AccessorKind::Get)) {
6312+
if (auto getter = getAccessor(AccessorKind::Get)) {
63136313
if (auto name = getNameFromObjcAttribute(getter->getAttrs().
63146314
getAttribute<ObjCAttr>(), preferredName))
63156315
return *name;
@@ -6339,7 +6339,7 @@ AbstractStorageDecl::getObjCGetterSelector(Identifier preferredName) const {
63396339
ObjCSelector
63406340
AbstractStorageDecl::getObjCSetterSelector(Identifier preferredName) const {
63416341
// If the setter has an @objc attribute with a name, use that.
6342-
auto setter = getOpaqueAccessor(AccessorKind::Set);
6342+
auto setter = getAccessor(AccessorKind::Set);
63436343
auto objcAttr = setter ? setter->getAttrs().getAttribute<ObjCAttr>()
63446344
: nullptr;
63456345
if (auto name = getNameFromObjcAttribute(objcAttr, DeclName(preferredName))) {
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#import <Foundation/NSObject.h>
2+
#import <Foundation/NSUUID.h>
3+
4+
__attribute__((objc_subclassing_restricted))
5+
__attribute__((swift_name("TricksyClass")))
6+
__attribute__((external_source_symbol(language="Swift", defined_in="MyModule", generated_declaration)))
7+
@interface CPTricksyClass : NSObject
8+
9+
@end
10+
11+
@protocol P
12+
@property(readonly) NSUUID *uuid;
13+
@end
14+
15+
@interface CPTricksyClass() <P>
16+
@end
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// RUN: %target-typecheck-verify-swift -target %target-cpu-apple-macosx10.15 -swift-version 5 -import-objc-header %S/Inputs/move_only_types_cycle.h
2+
// REQUIRES: objc_interop
3+
// REQUIRES: OS=macosx
4+
5+
// This test triggered a cyclic dependency between @objc getter selector
6+
// checking and some checking for move-only types, which is both horrifying and
7+
// exciting at the same time.
8+
9+
import Foundation
10+
11+
@objc(CPTricksyClass)
12+
public class TricksyClass: NSObject {
13+
public enum Color {
14+
case red
15+
}
16+
17+
var id = UUID()
18+
}
19+
20+
extension TricksyClass.Color {
21+
}

0 commit comments

Comments
 (0)