Skip to content

[Distributed] Harden typechecker against completely empty DAS types #66695

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions lib/AST/ASTContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1397,6 +1397,9 @@ FuncDecl *ASTContext::getMakeInvocationEncoderOnDistributedActorSystem(
FuncDecl *
ASTContext::getRecordGenericSubstitutionOnDistributedInvocationEncoder(
NominalTypeDecl *nominal) const {
if (!nominal)
return nullptr;

for (auto result : nominal->lookupDirect(Id_recordGenericSubstitution)) {
auto *func = dyn_cast<FuncDecl>(result);
if (func &&
Expand All @@ -1410,6 +1413,9 @@ ASTContext::getRecordGenericSubstitutionOnDistributedInvocationEncoder(

AbstractFunctionDecl *ASTContext::getRecordArgumentOnDistributedInvocationEncoder(
NominalTypeDecl *nominal) const {
if (!nominal)
return nullptr;

return evaluateOrDefault(
nominal->getASTContext().evaluator,
GetDistributedTargetInvocationEncoderRecordArgumentFunctionRequest{nominal},
Expand All @@ -1418,6 +1424,9 @@ AbstractFunctionDecl *ASTContext::getRecordArgumentOnDistributedInvocationEncode

AbstractFunctionDecl *ASTContext::getRecordReturnTypeOnDistributedInvocationEncoder(
NominalTypeDecl *nominal) const {
if (!nominal)
return nullptr;

return evaluateOrDefault(
nominal->getASTContext().evaluator,
GetDistributedTargetInvocationEncoderRecordReturnTypeFunctionRequest{nominal},
Expand All @@ -1426,6 +1435,9 @@ AbstractFunctionDecl *ASTContext::getRecordReturnTypeOnDistributedInvocationEnco

AbstractFunctionDecl *ASTContext::getRecordErrorTypeOnDistributedInvocationEncoder(
NominalTypeDecl *nominal) const {
if (!nominal)
return nullptr;

return evaluateOrDefault(
nominal->getASTContext().evaluator,
GetDistributedTargetInvocationEncoderRecordErrorTypeFunctionRequest{nominal},
Expand All @@ -1434,6 +1446,9 @@ AbstractFunctionDecl *ASTContext::getRecordErrorTypeOnDistributedInvocationEncod

AbstractFunctionDecl *ASTContext::getDecodeNextArgumentOnDistributedInvocationDecoder(
NominalTypeDecl *nominal) const {
if (!nominal)
return nullptr;

return evaluateOrDefault(
nominal->getASTContext().evaluator,
GetDistributedTargetInvocationDecoderDecodeNextArgumentFunctionRequest{nominal},
Expand All @@ -1442,6 +1457,9 @@ AbstractFunctionDecl *ASTContext::getDecodeNextArgumentOnDistributedInvocationDe

AbstractFunctionDecl *ASTContext::getOnReturnOnDistributedTargetInvocationResultHandler(
NominalTypeDecl *nominal) const {
if (!nominal)
return nullptr;

return evaluateOrDefault(
nominal->getASTContext().evaluator,
GetDistributedTargetInvocationResultHandlerOnReturnFunctionRequest{nominal},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,12 @@ public final class CompletelyHollowActorSystem: DistributedActorSystem {
// expected-error@-1{{type 'CompletelyHollowActorSystem.ResultHandler' does not conform to protocol 'DistributedTargetInvocationResultHandler'}}
}

}

public final class CompletelyHollowActorSystem_NotEvenTypes: DistributedActorSystem {
// expected-error@-1{{type 'CompletelyHollowActorSystem_NotEvenTypes' does not conform to protocol 'DistributedActorSystem'}}
// expected-error@-2{{class 'CompletelyHollowActorSystem_NotEvenTypes' is missing witness for protocol requirement 'remoteCallVoid'}}
// expected-error@-3{{class 'CompletelyHollowActorSystem_NotEvenTypes' is missing witness for protocol requirement 'remoteCall'}}
// expected-note@-4{{protocol 'DistributedActorSystem' requires function 'remoteCall' with signature:}}
// expected-note@-5{{protocol 'DistributedActorSystem' requires function 'remoteCallVoid' with signature:}}
}