Skip to content

Commit b420190

Browse files
authored
Merge pull request #66695 from ktoso/wip-distributed-harden-empty-impls
[Distributed] Harden typechecker against completely empty DAS types
2 parents e822a6a + fc7ecc8 commit b420190

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

lib/AST/ASTContext.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1394,6 +1394,9 @@ FuncDecl *ASTContext::getMakeInvocationEncoderOnDistributedActorSystem(
13941394
FuncDecl *
13951395
ASTContext::getRecordGenericSubstitutionOnDistributedInvocationEncoder(
13961396
NominalTypeDecl *nominal) const {
1397+
if (!nominal)
1398+
return nullptr;
1399+
13971400
for (auto result : nominal->lookupDirect(Id_recordGenericSubstitution)) {
13981401
auto *func = dyn_cast<FuncDecl>(result);
13991402
if (func &&
@@ -1407,6 +1410,9 @@ ASTContext::getRecordGenericSubstitutionOnDistributedInvocationEncoder(
14071410

14081411
AbstractFunctionDecl *ASTContext::getRecordArgumentOnDistributedInvocationEncoder(
14091412
NominalTypeDecl *nominal) const {
1413+
if (!nominal)
1414+
return nullptr;
1415+
14101416
return evaluateOrDefault(
14111417
nominal->getASTContext().evaluator,
14121418
GetDistributedTargetInvocationEncoderRecordArgumentFunctionRequest{nominal},
@@ -1415,6 +1421,9 @@ AbstractFunctionDecl *ASTContext::getRecordArgumentOnDistributedInvocationEncode
14151421

14161422
AbstractFunctionDecl *ASTContext::getRecordReturnTypeOnDistributedInvocationEncoder(
14171423
NominalTypeDecl *nominal) const {
1424+
if (!nominal)
1425+
return nullptr;
1426+
14181427
return evaluateOrDefault(
14191428
nominal->getASTContext().evaluator,
14201429
GetDistributedTargetInvocationEncoderRecordReturnTypeFunctionRequest{nominal},
@@ -1423,6 +1432,9 @@ AbstractFunctionDecl *ASTContext::getRecordReturnTypeOnDistributedInvocationEnco
14231432

14241433
AbstractFunctionDecl *ASTContext::getRecordErrorTypeOnDistributedInvocationEncoder(
14251434
NominalTypeDecl *nominal) const {
1435+
if (!nominal)
1436+
return nullptr;
1437+
14261438
return evaluateOrDefault(
14271439
nominal->getASTContext().evaluator,
14281440
GetDistributedTargetInvocationEncoderRecordErrorTypeFunctionRequest{nominal},
@@ -1431,6 +1443,9 @@ AbstractFunctionDecl *ASTContext::getRecordErrorTypeOnDistributedInvocationEncod
14311443

14321444
AbstractFunctionDecl *ASTContext::getDecodeNextArgumentOnDistributedInvocationDecoder(
14331445
NominalTypeDecl *nominal) const {
1446+
if (!nominal)
1447+
return nullptr;
1448+
14341449
return evaluateOrDefault(
14351450
nominal->getASTContext().evaluator,
14361451
GetDistributedTargetInvocationDecoderDecodeNextArgumentFunctionRequest{nominal},
@@ -1439,6 +1454,9 @@ AbstractFunctionDecl *ASTContext::getDecodeNextArgumentOnDistributedInvocationDe
14391454

14401455
AbstractFunctionDecl *ASTContext::getOnReturnOnDistributedTargetInvocationResultHandler(
14411456
NominalTypeDecl *nominal) const {
1457+
if (!nominal)
1458+
return nullptr;
1459+
14421460
return evaluateOrDefault(
14431461
nominal->getASTContext().evaluator,
14441462
GetDistributedTargetInvocationResultHandlerOnReturnFunctionRequest{nominal},

test/Distributed/distributed_imcomplete_system_dont_crash.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,12 @@ public final class CompletelyHollowActorSystem: DistributedActorSystem {
3636
// expected-error@-1{{type 'CompletelyHollowActorSystem.ResultHandler' does not conform to protocol 'DistributedTargetInvocationResultHandler'}}
3737
}
3838

39+
}
40+
41+
public final class CompletelyHollowActorSystem_NotEvenTypes: DistributedActorSystem {
42+
// expected-error@-1{{type 'CompletelyHollowActorSystem_NotEvenTypes' does not conform to protocol 'DistributedActorSystem'}}
43+
// expected-error@-2{{class 'CompletelyHollowActorSystem_NotEvenTypes' is missing witness for protocol requirement 'remoteCallVoid'}}
44+
// expected-error@-3{{class 'CompletelyHollowActorSystem_NotEvenTypes' is missing witness for protocol requirement 'remoteCall'}}
45+
// expected-note@-4{{protocol 'DistributedActorSystem' requires function 'remoteCall' with signature:}}
46+
// expected-note@-5{{protocol 'DistributedActorSystem' requires function 'remoteCallVoid' with signature:}}
3947
}

0 commit comments

Comments
 (0)