Skip to content

Commit 7000387

Browse files
authored
Merge pull request #66697 from ktoso/pick-wip-distributed-harden-empty-impls
🍒[5.9][Distributed] Harden typechecker against completely empty DAS types
2 parents 159b05d + cf46074 commit 7000387

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
@@ -1387,6 +1387,9 @@ FuncDecl *ASTContext::getMakeInvocationEncoderOnDistributedActorSystem(
13871387
FuncDecl *
13881388
ASTContext::getRecordGenericSubstitutionOnDistributedInvocationEncoder(
13891389
NominalTypeDecl *nominal) const {
1390+
if (!nominal)
1391+
return nullptr;
1392+
13901393
for (auto result : nominal->lookupDirect(Id_recordGenericSubstitution)) {
13911394
auto *func = dyn_cast<FuncDecl>(result);
13921395
if (func &&
@@ -1400,6 +1403,9 @@ ASTContext::getRecordGenericSubstitutionOnDistributedInvocationEncoder(
14001403

14011404
AbstractFunctionDecl *ASTContext::getRecordArgumentOnDistributedInvocationEncoder(
14021405
NominalTypeDecl *nominal) const {
1406+
if (!nominal)
1407+
return nullptr;
1408+
14031409
return evaluateOrDefault(
14041410
nominal->getASTContext().evaluator,
14051411
GetDistributedTargetInvocationEncoderRecordArgumentFunctionRequest{nominal},
@@ -1408,6 +1414,9 @@ AbstractFunctionDecl *ASTContext::getRecordArgumentOnDistributedInvocationEncode
14081414

14091415
AbstractFunctionDecl *ASTContext::getRecordReturnTypeOnDistributedInvocationEncoder(
14101416
NominalTypeDecl *nominal) const {
1417+
if (!nominal)
1418+
return nullptr;
1419+
14111420
return evaluateOrDefault(
14121421
nominal->getASTContext().evaluator,
14131422
GetDistributedTargetInvocationEncoderRecordReturnTypeFunctionRequest{nominal},
@@ -1416,6 +1425,9 @@ AbstractFunctionDecl *ASTContext::getRecordReturnTypeOnDistributedInvocationEnco
14161425

14171426
AbstractFunctionDecl *ASTContext::getRecordErrorTypeOnDistributedInvocationEncoder(
14181427
NominalTypeDecl *nominal) const {
1428+
if (!nominal)
1429+
return nullptr;
1430+
14191431
return evaluateOrDefault(
14201432
nominal->getASTContext().evaluator,
14211433
GetDistributedTargetInvocationEncoderRecordErrorTypeFunctionRequest{nominal},
@@ -1424,6 +1436,9 @@ AbstractFunctionDecl *ASTContext::getRecordErrorTypeOnDistributedInvocationEncod
14241436

14251437
AbstractFunctionDecl *ASTContext::getDecodeNextArgumentOnDistributedInvocationDecoder(
14261438
NominalTypeDecl *nominal) const {
1439+
if (!nominal)
1440+
return nullptr;
1441+
14271442
return evaluateOrDefault(
14281443
nominal->getASTContext().evaluator,
14291444
GetDistributedTargetInvocationDecoderDecodeNextArgumentFunctionRequest{nominal},
@@ -1432,6 +1447,9 @@ AbstractFunctionDecl *ASTContext::getDecodeNextArgumentOnDistributedInvocationDe
14321447

14331448
AbstractFunctionDecl *ASTContext::getOnReturnOnDistributedTargetInvocationResultHandler(
14341449
NominalTypeDecl *nominal) const {
1450+
if (!nominal)
1451+
return nullptr;
1452+
14351453
return evaluateOrDefault(
14361454
nominal->getASTContext().evaluator,
14371455
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)