Skip to content

Commit 09847e6

Browse files
authored
Merge pull request #23346 from theblixguy/fix/SR-10115
[Typechecker] Dont infer @objc for typealiases inside @objc protocol
2 parents 7d252cb + 58d25c0 commit 09847e6

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

lib/Sema/TypeCheckDeclObjC.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1131,8 +1131,11 @@ Optional<ObjCReason> shouldMarkAsObjC(const ValueDecl *VD, bool allowImplicit) {
11311131
if (VD->getAttrs().hasAttribute<NSManagedAttr>())
11321132
return ObjCReason(ObjCReason::ExplicitlyNSManaged);
11331133
// A member of an @objc protocol is implicitly @objc.
1134-
if (isMemberOfObjCProtocol)
1134+
if (isMemberOfObjCProtocol) {
1135+
if (!VD->isProtocolRequirement())
1136+
return None;
11351137
return ObjCReason(ObjCReason::MemberOfObjCProtocol);
1138+
}
11361139

11371140
// A @nonobjc is not @objc, even if it is an override of an @objc, so check
11381141
// for @nonobjc first.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %target-swift-frontend -c -enable-objc-interop -parse-as-library %s -o /dev/null -disable-objc-attr-requires-foundation-module -module-name typealias_objc -emit-module -emit-module-path %t/typealias_objc.swiftmodule
3+
// RUN: %target-swift-ide-test -skip-deinit=false -print-ast-typechecked -source-filename %s -function-definitions=true -prefer-type-repr=false -print-implicit-attrs=true -explode-pattern-binding-decls=true -disable-objc-attr-requires-foundation-module | %FileCheck %s
4+
@objc public protocol P {
5+
typealias T = () -> Bool
6+
// CHECK: typealias T = () -> Bool
7+
}

0 commit comments

Comments
 (0)