Skip to content

Commit 8b662a7

Browse files
committed
[Sema] Allow implicit dynamic @nonobjc.
Back in #24959, marking a decl both dynamic and @nonobjc was allowed. So implicitly mark decls that are @nonobjc dynamic when -enable-implicit-dynamic is specified. rdar://112152116
1 parent 69cbb45 commit 8b662a7

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

lib/Sema/TypeCheckAttr.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4615,8 +4615,7 @@ TypeChecker::diagnosticIfDeclCannotBeUnavailable(const Decl *D) {
46154615
}
46164616

46174617
static bool shouldBlockImplicitDynamic(Decl *D) {
4618-
if (D->getAttrs().hasAttribute<NonObjCAttr>() ||
4619-
D->getAttrs().hasAttribute<SILGenNameAttr>() ||
4618+
if (D->getAttrs().hasAttribute<SILGenNameAttr>() ||
46204619
D->getAttrs().hasAttribute<TransparentAttr>() ||
46214620
D->getAttrs().hasAttribute<InlinableAttr>())
46224621
return true;
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// RUN: %target-run-simple-swift(-Xfrontend -enable-implicit-dynamic) | %FileCheck %s
2+
3+
// REQUIRES: executable_test
4+
// REQUIRES: objc_interop
5+
6+
import Foundation
7+
8+
class C : NSObject {
9+
@nonobjc func foo() {
10+
print("original")
11+
}
12+
}
13+
14+
extension C {
15+
@_dynamicReplacement(for: foo()) @nonobjc private func replacement_for_foo() {
16+
print("replacement")
17+
}
18+
}
19+
20+
func doit() {
21+
let c = C()
22+
c.foo()
23+
}
24+
25+
// CHECK: replacement
26+
doit()

0 commit comments

Comments
 (0)