@@ -340,21 +340,16 @@ swift::getDistributedSerializationRequirements(
340
340
if (existentialRequirementTy->isAny ())
341
341
return true ; // we're done here, any means there are no requirements
342
342
343
- if (!existentialRequirementTy->isExistentialType ()) {
344
- // SerializationRequirement must be an existential type
345
- return false ;
346
- }
347
-
348
343
ExistentialType *serialReqType = existentialRequirementTy
349
- ->castTo <ExistentialType>();
344
+ ->getAs <ExistentialType>();
350
345
if (!serialReqType || serialReqType->hasError ()) {
351
346
return false ;
352
347
}
353
348
354
- auto desugaredTy = serialReqType->getConstraintType ()-> getDesugaredType () ;
349
+ auto desugaredTy = serialReqType->getConstraintType ();
355
350
auto flattenedRequirements =
356
351
flattenDistributedSerializationTypeToRequiredProtocols (
357
- desugaredTy);
352
+ desugaredTy. getPointer () );
358
353
for (auto p : flattenedRequirements) {
359
354
requirementProtos.insert (p);
360
355
}
@@ -565,25 +560,19 @@ bool AbstractFunctionDecl::isDistributedActorSystemRemoteCall(bool isVoidReturn)
565
560
566
561
// --- Check requirement: conforms_to: Act DistributedActor
567
562
auto actorReq = requirements[0 ];
568
- auto distActorTy = C.getProtocol (KnownProtocolKind::DistributedActor)
569
- ->getInterfaceType ()
570
- ->getMetatypeInstanceType ();
571
563
if (actorReq.getKind () != RequirementKind::Conformance) {
572
564
return false ;
573
565
}
574
- if (!actorReq.getSecondType ()->isEqual (distActorTy )) {
566
+ if (!actorReq.getProtocolDecl ()->isSpecificProtocol (KnownProtocolKind::DistributedActor )) {
575
567
return false ;
576
568
}
577
569
578
570
// --- Check requirement: conforms_to: Err Error
579
571
auto errorReq = requirements[1 ];
580
- auto errorTy = C.getProtocol (KnownProtocolKind::Error)
581
- ->getInterfaceType ()
582
- ->getMetatypeInstanceType ();
583
572
if (errorReq.getKind () != RequirementKind::Conformance) {
584
573
return false ;
585
574
}
586
- if (!errorReq.getSecondType ()->isEqual (errorTy )) {
575
+ if (!errorReq.getProtocolDecl ()->isSpecificProtocol (KnownProtocolKind::Error )) {
587
576
return false ;
588
577
}
589
578
@@ -598,10 +587,9 @@ bool AbstractFunctionDecl::isDistributedActorSystemRemoteCall(bool isVoidReturn)
598
587
assert (ResParam && " Non void function, yet no Res generic parameter found" );
599
588
if (auto func = dyn_cast<FuncDecl>(this )) {
600
589
auto resultType = func->mapTypeIntoContext (func->getResultInterfaceType ())
601
- ->getMetatypeInstanceType ()
602
- ->getDesugaredType ();
590
+ ->getMetatypeInstanceType ();
603
591
auto resultParamType = func->mapTypeIntoContext (
604
- ResParam->getInterfaceType ()-> getMetatypeInstanceType ());
592
+ ResParam->getDeclaredInterfaceType ());
605
593
// The result of the function must be the `Res` generic argument.
606
594
if (!resultType->isEqual (resultParamType)) {
607
595
return false ;
@@ -797,12 +785,10 @@ AbstractFunctionDecl::isDistributedTargetInvocationEncoderRecordArgument() const
797
785
798
786
// the <Value> of the RemoteCallArgument<Value>
799
787
auto remoteCallArgValueGenericTy =
800
- mapTypeIntoContext (argGenericParams[0 ]->getInterfaceType ())
801
- ->getDesugaredType ()
802
- ->getMetatypeInstanceType ();
788
+ mapTypeIntoContext (argGenericParams[0 ]->getDeclaredInterfaceType ());
803
789
// expected (the <Value> from the recordArgument<Value>)
804
790
auto expectedGenericParamTy = mapTypeIntoContext (
805
- ArgumentParam->getInterfaceType ()-> getMetatypeInstanceType ());
791
+ ArgumentParam->getDeclaredInterfaceType ());
806
792
807
793
if (!remoteCallArgValueGenericTy->isEqual (expectedGenericParamTy)) {
808
794
return false ;
@@ -932,11 +918,10 @@ AbstractFunctionDecl::isDistributedTargetInvocationEncoderRecordReturnType() con
932
918
// ...
933
919
934
920
auto resultType = func->mapTypeIntoContext (argumentParam->getInterfaceType ())
935
- ->getMetatypeInstanceType ()
936
- ->getDesugaredType ();
921
+ ->getMetatypeInstanceType ();
937
922
938
923
auto resultParamType = func->mapTypeIntoContext (
939
- ArgumentParam->getInterfaceType ()-> getMetatypeInstanceType ());
924
+ ArgumentParam->getDeclaredInterfaceType ());
940
925
941
926
// The result of the function must be the `Res` generic argument.
942
927
if (!resultType->isEqual (resultParamType)) {
@@ -1046,13 +1031,10 @@ AbstractFunctionDecl::isDistributedTargetInvocationEncoderRecordErrorType() cons
1046
1031
1047
1032
// --- Check requirement: conforms_to: Err Error
1048
1033
auto errorReq = requirements[0 ];
1049
- auto errorTy = C.getProtocol (KnownProtocolKind::Error)
1050
- ->getInterfaceType ()
1051
- ->getMetatypeInstanceType ();
1052
1034
if (errorReq.getKind () != RequirementKind::Conformance) {
1053
1035
return false ;
1054
1036
}
1055
- if (!errorReq.getSecondType ()->isEqual (errorTy )) {
1037
+ if (!errorReq.getProtocolDecl ()->isSpecificProtocol (KnownProtocolKind::Error )) {
1056
1038
return false ;
1057
1039
}
1058
1040
@@ -1139,10 +1121,9 @@ AbstractFunctionDecl::isDistributedTargetInvocationDecoderDecodeNextArgument() c
1139
1121
// --- Check: Argument: SerializationRequirement
1140
1122
GenericTypeParamDecl *ArgumentParam = genericParams->getParams ()[0 ];
1141
1123
auto resultType = func->mapTypeIntoContext (func->getResultInterfaceType ())
1142
- ->getMetatypeInstanceType ()
1143
- ->getDesugaredType ();
1124
+ ->getMetatypeInstanceType ();
1144
1125
auto resultParamType = func->mapTypeIntoContext (
1145
- ArgumentParam->getInterfaceType ()-> getMetatypeInstanceType ());
1126
+ ArgumentParam->getDeclaredInterfaceType ());
1146
1127
// The result of the function must be the `Res` generic argument.
1147
1128
if (!resultType->isEqual (resultParamType)) {
1148
1129
return false ;
@@ -1237,11 +1218,10 @@ AbstractFunctionDecl::isDistributedTargetInvocationResultHandlerOnReturn() const
1237
1218
// === Check generic parameters in detail
1238
1219
// --- Check: Argument: SerializationRequirement
1239
1220
GenericTypeParamDecl *ArgumentParam = genericParams->getParams ()[0 ];
1240
- auto argumentType = func->mapTypeIntoContext (valueParam->getInterfaceType ())
1241
- ->getMetatypeInstanceType ()
1242
- ->getDesugaredType ();
1221
+ auto argumentType = func->mapTypeIntoContext (
1222
+ valueParam->getInterfaceType ()->getMetatypeInstanceType ());
1243
1223
auto resultParamType = func->mapTypeIntoContext (
1244
- ArgumentParam->getInterfaceType ()-> getMetatypeInstanceType ());
1224
+ ArgumentParam->getDeclaredInterfaceType ());
1245
1225
// The result of the function must be the `Res` generic argument.
1246
1226
if (!argumentType->isEqual (resultParamType)) {
1247
1227
return false ;
@@ -1269,7 +1249,6 @@ swift::extractDistributedSerializationRequirements(
1269
1249
auto DA = C.getDistributedActorDecl ();
1270
1250
auto daSerializationReqAssocType =
1271
1251
DA->getAssociatedType (C.Id_SerializationRequirement );
1272
- auto daSystemSerializationReqTy = daSerializationReqAssocType->getInterfaceType ();
1273
1252
1274
1253
for (auto req : allRequirements) {
1275
1254
if (req.getSecondType ()->isAny ()) {
@@ -1280,21 +1259,17 @@ swift::extractDistributedSerializationRequirements(
1280
1259
1281
1260
if (auto dependentMemberType =
1282
1261
req.getFirstType ()->castTo <DependentMemberType>()) {
1283
- auto dependentTy =
1284
- dependentMemberType->getAssocType ()->getInterfaceType ();
1285
-
1286
- if (dependentTy->isEqual (daSystemSerializationReqTy)) {
1262
+ if (dependentMemberType->getAssocType () == daSerializationReqAssocType) {
1287
1263
auto requirementProto = req.getSecondType ();
1288
1264
if (auto proto = dyn_cast_or_null<ProtocolDecl>(
1289
1265
requirementProto->getAnyNominal ())) {
1290
1266
serializationReqs.insert (proto);
1291
1267
} else {
1292
1268
auto serialReqType = requirementProto->castTo <ExistentialType>()
1293
- ->getConstraintType ()
1294
- ->getDesugaredType ();
1269
+ ->getConstraintType ();
1295
1270
auto flattenedRequirements =
1296
1271
flattenDistributedSerializationTypeToRequiredProtocols (
1297
- serialReqType);
1272
+ serialReqType. getPointer () );
1298
1273
for (auto p : flattenedRequirements) {
1299
1274
serializationReqs.insert (p);
1300
1275
}
0 commit comments