Use the distributed thunk for non-distributed protocol requirements (#59513)

When a distributed-actor-isolated witness is provided for a
non-distributed-actor-isolated requirement, always hop to the
distributed thunk.

While here, mark distributed thunks as being `final`, to ensure that
we always statically call them vs. trying to retrieve them from the
vtable (since they aren't in the vtable).
This commit is contained in:
Doug Gregor
2022-06-16 19:13:59 -07:00
committed by GitHub
parent 7e843559ef
commit 74503f00ff
4 changed files with 60 additions and 25 deletions

View File

@@ -699,6 +699,10 @@ static FuncDecl *createDistributedThunkFunction(FuncDecl *func) {
func->getResultInterfaceType(), DC);
thunk->setSynthesized(true);
thunk->getAttrs().add(new (C) NonisolatedAttr(/*isImplicit=*/true));
if (isa<ClassDecl>(DC))
thunk->getAttrs().add(new (C) FinalAttr(/*isImplicit=*/true));
thunk->setGenericSignature(baseSignature);
thunk->copyFormalAccessFrom(func, /*sourceIsParentContext=*/false);
thunk->setBodySynthesizer(deriveBodyDistributed_thunk, func);