Skip to content

Commit b7ff05d

Browse files
committed
IRGen: Fix handling of dispatch thunks
Tests fail with the next patch.
1 parent b1f4430 commit b7ff05d

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

lib/IRGen/GenDecl.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1633,8 +1633,15 @@ bool LinkEntity::isAvailableExternally(IRGenModule &IGM) const {
16331633
switch (getKind()) {
16341634
case Kind::DispatchThunk:
16351635
case Kind::DispatchThunkInitializer:
1636-
case Kind::DispatchThunkAllocator:
1636+
case Kind::DispatchThunkAllocator: {
1637+
auto *decl = getDecl();
1638+
1639+
// Protocol requirements don't have their own access control
1640+
if (auto *proto = dyn_cast<ProtocolDecl>(decl->getDeclContext()))
1641+
decl = proto;
1642+
16371643
return ::isAvailableExternally(IGM, getDecl());
1644+
}
16381645

16391646
case Kind::ValueWitnessTable:
16401647
case Kind::TypeMetadata:

lib/IRGen/GenThunk.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ IRGenModule::getAddrOfDispatchThunk(SILDeclRef declRef,
5050
Signature signature = getSignature(fnType);
5151
LinkInfo link = LinkInfo::get(*this, entity, forDefinition);
5252

53-
return createFunction(*this, link, signature);
53+
entry = createFunction(*this, link, signature);
54+
return entry;
5455
}
5556

5657
static FunctionPointer lookupMethod(IRGenFunction &IGF,

0 commit comments

Comments
 (0)