@@ -707,7 +707,7 @@ void TypeChecker::checkDistributedActor(SourceFile *SF, NominalTypeDecl *nominal
707707 // on as differenciators in remote calls - the call will always be "async"
708708 // since it will go through a thunk, and then be asynchronously transferred
709709 // to the called process.
710- llvm::SmallDenseSet<DeclName, 2 > diagnosedAmbiguity;
710+ // llvm::SmallDenseSet<DeclName, 2> diagnosedAmbiguity;
711711
712712 for (auto member : nominal->getMembers ()) {
713713 // --- Ensure 'distributed func' all thunks
@@ -734,63 +734,6 @@ void TypeChecker::checkDistributedActor(SourceFile *SF, NominalTypeDecl *nominal
734734 nominal->getName ());
735735 return ;
736736 }
737-
738- // Check there's no async/no-async overloads, since those are more
739- // fragile in distribution than we'd want distributed calls to be.
740- // A remote call is always 'async throws', and we can always record
741- // an async throws "accessor" (see AccessibleFunction.cpp) as such.
742- // This means, if we allowed async/no-async overloads of functions,
743- // we'd have to store the precise "it was not throwing" information,
744- // but we'll _never_ make use of such because all remote calls are
745- // necessarily going to async to the actor in the recipient process,
746- // and for the remote caller, they are always as-if-async.
747- //
748- // By banning such overloads, which may be useful in local APIs,
749- // but too fragile in distributed APIs, we allow a remote 'v2' version
750- // of an implementation to add or remove `async` to their implementation
751- // without breaking calls which were made on previous 'v1' versions of
752- // the same interface; Callers are never broken this way, and rollouts
753- // are simpler.
754- //
755- // The restriction on overloads is not a problem for distributed calls,
756- // as we don't have a vast swab of APIs which must compatibly get async
757- // versions, as that is what the async overloading aimed to address.
758- //
759- // Note also, that overloading on throws is already illegal anyway.
760- if (!diagnosedAmbiguity.contains (func->getName ())) {
761- auto candidates = nominal->lookupDirect (func->getName ());
762- if (candidates.size () > 1 ) {
763- auto firstDecl = dyn_cast<AbstractFunctionDecl>(candidates.back ());
764- for (auto candidate: candidates) {
765- if (auto candidateFunc = dyn_cast<AbstractFunctionDecl>(candidate)) {
766- assert (candidateFunc->getParameters ()->size () ==
767- firstDecl->getParameters ()->size ());
768- bool allSame = true ;
769- for (size_t i = 0 ; i < candidateFunc->getParameters ()->size (); ++i) {
770- auto lhs = firstDecl->getParameters ()->get (i);
771- auto rhs = candidateFunc->getParameters ()->get (i);
772- if (!lhs->getInterfaceType ()->isEqual (rhs->getInterfaceType ())) {
773- allSame = false ;
774- break ;
775- }
776- }
777-
778- if (candidate != firstDecl && // can't be ambiguous with itself
779- allSame && // diagnose if ambiguous
780- !diagnosedAmbiguity.contains (func->getName ())) {
781- candidate->diagnose (
782- diag::distributed_func_cannot_overload_on_async_only,
783- candidate->getName ());
784- diagnosedAmbiguity.insert (func->getName ());
785- } else if (diagnosedAmbiguity.contains (func->getName ())) {
786- candidate->diagnose (
787- diag::distributed_func_other_ambiguous_overload_here,
788- candidate->getName ());
789- }
790- }
791- }
792- }
793- }
794737 }
795738
796739 if (auto thunk = func->getDistributedThunk ()) {
0 commit comments