Skip to content

Commit 3791207

Browse files
Merge pull request #40990 from aschwaighofer/fix_isNativeMethodReplacement
AST: Fix ValueDecl::isNativeMethodReplacement
2 parents 993ccda + 1447cde commit 3791207

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

lib/AST/Decl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3063,7 +3063,7 @@ bool ValueDecl::isNativeMethodReplacement() const {
30633063
if (isNativeDynamic())
30643064
return true;
30653065

3066-
if (isObjCDynamicInGenericClass())
3066+
if (replacedDecl->isObjCDynamicInGenericClass())
30673067
return replacedDecl->getModuleContext()->isImplicitDynamicEnabled();
30683068

30693069
return false;

test/SILGen/Inputs/objc_dynamic_replacement_ext.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,13 @@ public class Generic<ItemType>: NSObject {
1414

1515
@objc public dynamic var y: Int = 0
1616
}
17+
18+
@objc
19+
public protocol MyProto {
20+
func doIt()
21+
}
22+
23+
public final class MyGeneric<Item>: NSObject, MyProto {
24+
public dynamic func doIt() {
25+
}
26+
}

test/SILGen/objc_dynamic_replacement_ext.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,11 @@ extension Generic {
7979
// CHECK-NOT: sil {{.*}} @$s10SomeModule7GenericC28objc_dynamic_replacement_extE02__F2_ySivsTo : $@convention(objc_method) <ItemType> (Int, Generic<ItemType>) -> ()
8080
// CHECK-DAG: sil [dynamic_replacement_for "$s10SomeModule7GenericC1ySivs"] [ossa] @$s10SomeModule7GenericC28objc_dynamic_replacement_extE02__F2_ySivs : $@convention(method) <ItemType> (Int, @guaranteed Generic<ItemType>) -> ()
8181
}
82+
83+
// IMPORT-DAG: sil [dynamically_replacable] [ossa] @$s10SomeModule9MyGenericC4doItyyF
84+
// IMPORT-DAG: sil [thunk] [ossa] @$s10SomeModule9MyGenericC4doItyyFTo
85+
// CHECK-NOT: s10SomeModule9MyGenericC28objc_dynamic_replacement_extE02__G6__doItyyFTo
86+
// CHECK-DAG: sil hidden [dynamic_replacement_for "$s10SomeModule9MyGenericC4doItyyF"] [ossa] @$s10SomeModule9MyGenericC28objc_dynamic_replacement_extE02__G6__doItyyF : $@convention(method) <Item>
87+
extension MyGeneric {
88+
@_dynamicReplacement(for: doIt()) func __replacement__doIt() {}
89+
}

0 commit comments

Comments
 (0)