@@ -3192,21 +3192,6 @@ void ASTMangler::appendEntity(const ValueDecl *decl) {
31923192 // Handle accessors specially, they are mangled as modifiers on the accessed
31933193 // declaration.
31943194 if (auto accessor = dyn_cast<AccessorDecl>(decl)) {
3195- // Distributed thunks associated with computed properties
3196- // are currently implemented as accessors but they don't
3197- // have to be and that could be changed in the future.
3198- //
3199- // Let's mangle them as `distributed func`s to make it easier
3200- // to change implementation and because runtime needs a function
3201- // type associated with the thunk to form a call to it.
3202- if (accessor->isDistributedThunk ()) {
3203- appendContextOf (decl);
3204- appendDeclName (accessor->getStorage ());
3205- appendDeclType (accessor, FunctionMangling);
3206- appendOperator (" F" );
3207- return ;
3208- }
3209-
32103195 return appendAccessorEntity (
32113196 getCodeForAccessorKind (accessor->getAccessorKind ()),
32123197 accessor->getStorage (), accessor->isStatic ());
@@ -3506,5 +3491,28 @@ std::string ASTMangler::mangleDistributedThunk(const AbstractFunctionDecl *thunk
35063491 // in recording them for distributed thunks.
35073492 llvm::SaveAndRestore<bool > savedAllowMarkerProtocols (AllowMarkerProtocols,
35083493 false );
3494+
3495+ // Since computed property SILDeclRef's refer to the "originator"
3496+ // of the thunk, we need to mangle distributed thunks of accessors
3497+ // specially.
3498+ if (auto *accessor = dyn_cast<AccessorDecl>(thunk)) {
3499+ // TODO: This needs to use accessor type instead of
3500+ // distributed thunk after all SILDeclRefs are switched
3501+ // to use "originator" instead of the thunk itself.
3502+ //
3503+ // ```
3504+ // beginMangling();
3505+ // appendContextOf(thunk);
3506+ // appendDeclName(accessor->getStorage());
3507+ // appendDeclType(accessor, FunctionMangling);
3508+ // appendOperator("F");
3509+ // appendSymbolKind(SymbolKind::DistributedThunk);
3510+ // return finalize();
3511+ // ```
3512+ auto *storage = accessor->getStorage ();
3513+ thunk = storage->getDistributedThunk ();
3514+ assert (thunk);
3515+ }
3516+
35093517 return mangleEntity (thunk, SymbolKind::DistributedThunk);
35103518}
0 commit comments