@@ -1960,7 +1960,7 @@ void SILGenFunction::emitDistributedThunk(SILDeclRef thunk) {
19601960 //
19611961 // func X_distributedThunk(...) async throws -> T {
19621962 // if __isRemoteActor(self) {
1963- // return try await Self.__remote_X (...)
1963+ // return try await self._remote_X (...)
19641964 // } else {
19651965 // return try await self.X(...)
19661966 // }
@@ -2011,19 +2011,9 @@ void SILGenFunction::emitDistributedThunk(SILDeclRef thunk) {
20112011 // ...
20122012 // }
20132013 {
2014- auto desc = UnqualifiedLookupDescriptor (
2015- DeclNameRef (ctx.Id___isRemoteActor ),
2016- fd->getDeclContext (), fd->getLoc (), UnqualifiedLookupOptions ());
2017- auto lookup =
2018- evaluateOrDefault (ctx.evaluator , UnqualifiedLookupRequest{desc}, {});
2019- FuncDecl *isRemoteFn = nullptr ;
2020- for (const auto &result : lookup) {
2021- // FIXME: Validate this further, because we're assuming the exact type.
2022- if (auto func = dyn_cast<FuncDecl>(result.getValueDecl ())) {
2023- isRemoteFn = func;
2024- break ;
2025- }
2026- }
2014+ FuncDecl* isRemoteFn = ctx.getIsRemoteDistributedActor ();
2015+ assert (isRemoteFn &&
2016+ " Could not find 'is remote' function, is the '_Distributed' module available?" );
20272017
20282018 ManagedValue selfAnyObject = B.createInitExistentialRef (loc, getLoweredType (ctx.getAnyObjectType ()),
20292019 CanType (selfType),
@@ -2037,39 +2027,37 @@ void SILGenFunction::emitDistributedThunk(SILDeclRef thunk) {
20372027 B.createCondBranch (loc, isRemoteResultUnwrapped, isRemoteBB, isLocalBB);
20382028 }
20392029
2040-
20412030 // if __isRemoteActor(self) {
2042- // return try await Self ._remote_X(...)
2031+ // return try await self ._remote_X(...)
20432032 // }
20442033 {
20452034 B.emitBlock (isRemoteBB);
20462035
20472036 auto *selfTyDecl = FunctionDC->getParent ()->getSelfNominalTypeDecl ();
2048- // FIXME: should this be an llvm_unreachable instead?
20492037 assert (selfTyDecl && " distributed function declared outside of actor" );
20502038
2051- auto selfMetatype = getLoweredType (selfTyDecl->getInterfaceType ());
2052- SILValue metatypeValue = B.createMetatype (loc, selfMetatype);
2039+ // auto selfMetatype = getLoweredType(selfTyDecl->getInterfaceType());
2040+ // SILValue metatypeValue = B.createMetatype(loc, selfMetatype);
20532041
20542042 auto remoteFnDecl = selfTyDecl->lookupDirectRemoteFunc (fd);
20552043 assert (remoteFnDecl && " Could not find _remote_<dist_func_name> function" );
20562044 auto remoteFnRef = SILDeclRef (remoteFnDecl);
20572045
20582046 SILGenFunctionBuilder builder (SGM);
20592047 auto remoteFnSIL = builder.getOrCreateFunction (loc, remoteFnRef, ForDefinition);
2060-
20612048 SILValue remoteFn = B.createFunctionRefFor (loc, remoteFnSIL);
20622049
20632050 auto subs = F.getForwardingSubstitutionMap ();
20642051
20652052 SmallVector<SILValue, 8 > remoteParams (params);
2066- remoteParams.emplace_back (metatypeValue);
2053+ // remoteParams.emplace_back(metatypeValue);
20672054
2055+ // B.createTryApply(loc, remoteFn, subs, params, remoteReturnBB, remoteErrorBB);
20682056 B.createTryApply (loc, remoteFn, subs, remoteParams, remoteReturnBB, remoteErrorBB);
20692057 }
20702058
20712059 // else {
2072- // return try await self.X(...)
2060+ // return ( try)? ( await)? self.X(...)
20732061 // }
20742062 {
20752063 B.emitBlock (isLocalBB);
0 commit comments