@@ -102,7 +102,6 @@ Type swift::getDistributedActorSystemActorIDRequirementType(NominalTypeDecl *sys
102
102
103
103
Type swift::getDistributedSerializationRequirementType (
104
104
NominalTypeDecl *nominal, ProtocolDecl *protocol) {
105
- assert (!nominal->isDistributedActor ());
106
105
assert (protocol);
107
106
auto &ctx = nominal->getASTContext ();
108
107
@@ -181,28 +180,19 @@ swift::getDistributedActorSystemSerializationRequirements(
181
180
auto existentialRequirementTy =
182
181
getDistributedSerializationRequirementType (nominal, protocol);
183
182
if (existentialRequirementTy->hasError ()) {
184
- fprintf (stderr, " [%s:%d] (%s) if (SerializationRequirementTy->hasError())\n " , __FILE__, __LINE__, __FUNCTION__);
185
183
return false ;
186
184
}
187
185
188
186
if (existentialRequirementTy->isAny ())
189
187
return true ; // we're done here, any means there are no requirements
190
188
191
- fprintf (stderr, " [%s:%d] (%s) existentialRequirementTy\n " , __FILE__, __LINE__, __FUNCTION__);
192
- existentialRequirementTy.dump ();
193
-
194
- fprintf (stderr, " [%s:%d] (%s) ---------------------\n " , __FILE__, __LINE__, __FUNCTION__);
195
-
196
189
auto serialReqType = existentialRequirementTy->castTo <ExistentialType>()
197
190
->getConstraintType ()
198
191
->getDesugaredType ();
199
- fprintf (stderr, " [%s:%d] (%s) serialReqType serialReqType serialReqType serialReqType serialReqType serialReqType\n " , __FILE__, __LINE__, __FUNCTION__);
200
- serialReqType->dump ();
201
192
auto flattenedRequirements =
202
193
flattenDistributedSerializationTypeToRequiredProtocols (
203
194
serialReqType);
204
195
for (auto p : flattenedRequirements) {
205
- fprintf (stderr, " [%s:%d] (%s) PROTO %s\n " , __FILE__, __LINE__, __FUNCTION__, p->getNameStr ().str ().c_str ());
206
196
requirementProtos.insert (p);
207
197
}
208
198
@@ -254,16 +244,9 @@ bool AbstractFunctionDecl::isDistributedActorSystemRemoteCall(bool isVoidReturn)
254
244
auto &C = getASTContext ();
255
245
auto module = getParentModule ();
256
246
257
- fprintf (stderr, " [%s:%d] (%s) ====================================================\n " , __FILE__, __LINE__, __FUNCTION__);
258
- fprintf (stderr, " [%s:%d] (%s) ====================================================\n " , __FILE__, __LINE__, __FUNCTION__);
259
- fprintf (stderr, " [%s:%d] (%s) ====================================================\n " , __FILE__, __LINE__, __FUNCTION__);
260
- fprintf (stderr, " [%s:%d] (%s) ====================================================\n " , __FILE__, __LINE__, __FUNCTION__);
261
- fprintf (stderr, " [%s:%d] (%s) CHECK NAME: %s\n " , __FILE__, __LINE__, __FUNCTION__, getNameStr ().str ().c_str ());
262
-
263
247
// === Check the name
264
248
auto callId = isVoidReturn ? C.Id_remoteCallVoid : C.Id_remoteCall ;
265
249
if (getBaseName () != callId) {
266
- fprintf (stderr, " [%s:%d] (%s) if (getBaseName() != callId)\n " , __FILE__, __LINE__, __FUNCTION__);
267
250
return false ;
268
251
}
269
252
@@ -276,26 +259,22 @@ bool AbstractFunctionDecl::isDistributedActorSystemRemoteCall(bool isVoidReturn)
276
259
systemNominal->getDeclaredInterfaceType (), systemProto);
277
260
278
261
if (distSystemConformance.isInvalid ()) {
279
- fprintf (stderr, " [%s:%d] (%s) if (distSystemConformance.isInvalid())\n " , __FILE__, __LINE__, __FUNCTION__);
280
262
return false ;
281
263
}
282
264
283
265
// === Structural Checks
284
266
// -- Must be throwing
285
267
if (!hasThrows ()) {
286
- fprintf (stderr, " [%s:%d] (%s) if (!hasThrows())\n " , __FILE__, __LINE__, __FUNCTION__);
287
268
return false ;
288
269
}
289
270
290
271
// -- Must be async
291
272
if (!hasAsync ()) {
292
- fprintf (stderr, " [%s:%d] (%s) if (!hasAsync())\n " , __FILE__, __LINE__, __FUNCTION__);
293
273
return false ;
294
274
}
295
275
296
276
// === Check generics
297
277
if (!isGeneric ()) {
298
- fprintf (stderr, " [%s:%d] (%s) if (!isGeneric())\n " , __FILE__, __LINE__, __FUNCTION__);
299
278
return false ;
300
279
}
301
280
@@ -304,7 +283,6 @@ bool AbstractFunctionDecl::isDistributedActorSystemRemoteCall(bool isVoidReturn)
304
283
unsigned int expectedGenericParamNum = isVoidReturn ? 2 : 3 ;
305
284
306
285
if (genericParams->size () != expectedGenericParamNum) {
307
- fprintf (stderr, " [%s:%d] (%s) if (genericParams->size() != expectedGenericParamNum)\n " , __FILE__, __LINE__, __FUNCTION__);
308
286
return false ;
309
287
}
310
288
@@ -329,7 +307,6 @@ bool AbstractFunctionDecl::isDistributedActorSystemRemoteCall(bool isVoidReturn)
329
307
// --- Count of parameters depends on if we're void returning or not
330
308
unsigned int expectedParamNum = isVoidReturn ? 4 : 5 ;
331
309
if (!params || params->size () != expectedParamNum) {
332
- fprintf (stderr, " [%s:%d] (%s) if (!params || params->size() != expectedParamNum) {\n " , __FILE__, __LINE__, __FUNCTION__);
333
310
return false ;
334
311
}
335
312
@@ -366,10 +343,6 @@ bool AbstractFunctionDecl::isDistributedActorSystemRemoteCall(bool isVoidReturn)
366
343
}
367
344
}
368
345
369
- fprintf (stderr, " [%s:%d] (%s) GENERIC PARAMS\n " , __FILE__, __LINE__, __FUNCTION__);
370
- for (auto param : genericParams->getParams ()) {
371
- param->dump ();
372
- }
373
346
// === Check generic parameters in detail
374
347
// --- Check: Act: DistributedActor,
375
348
// Act.ID == Self.ActorID
@@ -401,15 +374,6 @@ bool AbstractFunctionDecl::isDistributedActorSystemRemoteCall(bool isVoidReturn)
401
374
auto sig = getGenericSignature ();
402
375
auto requirements = sig.getRequirements ();
403
376
404
- fprintf (stderr, " [%s:%d] (%s) REQUIREMENTS requirements::::::::::::::::\n " , __FILE__, __LINE__, __FUNCTION__);
405
- for (auto r : requirements) {
406
- r.dump ();
407
- }
408
- fprintf (stderr, " [%s:%d] (%s) REQUIREMENT PROTOS ::::::::::::::::\n " , __FILE__, __LINE__, __FUNCTION__);
409
- for (auto r : requirementProtos) {
410
- r->dump ();
411
- }
412
-
413
377
if (requirements.size () != expectedRequirementsNum) {
414
378
return false ;
415
379
}
@@ -486,7 +450,7 @@ bool AbstractFunctionDecl::isDistributedActorSystemRemoteCall(bool isVoidReturn)
486
450
}
487
451
auto expectedActorIdTy =
488
452
getDistributedActorSystemActorIDRequirementType (systemNominal);
489
- actorIdReq.dump ();
453
+ // actorIdReq.dump();
490
454
if (!actorIdReq.getSecondType ()->isEqual (expectedActorIdTy)) {
491
455
return false ;
492
456
}
@@ -500,8 +464,9 @@ AbstractFunctionDecl::isDistributedTargetInvocationEncoderRecordArgument() const
500
464
auto module = getParentModule ();
501
465
502
466
// === Check base name
503
- if (getBaseIdentifier () != C.Id_recordArgument )
467
+ if (getBaseIdentifier () != C.Id_recordArgument ) {
504
468
return false ;
469
+ }
505
470
506
471
// === Must be declared in a 'DistributedTargetInvocationEncoder' conforming type
507
472
ProtocolDecl *encoderProto =
@@ -518,19 +483,16 @@ AbstractFunctionDecl::isDistributedTargetInvocationEncoderRecordArgument() const
518
483
// === Check modifiers
519
484
// --- must not be async
520
485
if (hasAsync ()) {
521
- fprintf (stderr, " [%s:%d] (%s) return false\n " , __FILE__, __LINE__, __FUNCTION__);
522
486
return false ;
523
487
}
524
488
525
489
// --- must be throwing
526
490
if (!hasThrows ()) {
527
- fprintf (stderr, " [%s:%d] (%s) return false\n " , __FILE__, __LINE__, __FUNCTION__);
528
491
return false ;
529
492
}
530
493
531
494
// === Check generics
532
495
if (!isGeneric ()) {
533
- fprintf (stderr, " [%s:%d] (%s) if (!isGeneric())\n " , __FILE__, __LINE__, __FUNCTION__);
534
496
return false ;
535
497
}
536
498
@@ -539,15 +501,13 @@ AbstractFunctionDecl::isDistributedTargetInvocationEncoderRecordArgument() const
539
501
unsigned int expectedGenericParamNum = 1 ;
540
502
541
503
if (genericParams->size () != expectedGenericParamNum) {
542
- fprintf (stderr, " [%s:%d] (%s) if (genericParams->size() != expectedGenericParamNum)\n " , __FILE__, __LINE__, __FUNCTION__);
543
504
return false ;
544
505
}
545
506
546
507
// === Get the SerializationRequirement
547
508
SmallPtrSet<ProtocolDecl*, 2 > requirementProtos;
548
509
if (!getDistributedActorSystemSerializationRequirements (
549
510
encoderNominal, encoderProto, requirementProtos)) {
550
- fprintf (stderr, " [%s:%d] (%s) return false\n " , __FILE__, __LINE__, __FUNCTION__);
551
511
return false ;
552
512
}
553
513
@@ -558,14 +518,12 @@ AbstractFunctionDecl::isDistributedTargetInvocationEncoderRecordArgument() const
558
518
// === Check all parameters
559
519
auto params = getParameters ();
560
520
if (params->size () != 1 ) {
561
- fprintf (stderr, " [%s:%d] (%s) return false\n " , __FILE__, __LINE__, __FUNCTION__);
562
521
return false ;
563
522
}
564
523
565
524
// --- Check parameter: _ argument
566
525
auto argumentParam = params->get (0 );
567
- if (!argumentParam->getArgumentName ().is (" _" )) {
568
- fprintf (stderr, " [%s:%d] (%s) return false\n " , __FILE__, __LINE__, __FUNCTION__);
526
+ if (!argumentParam->getArgumentName ().is (" " )) {
569
527
return false ;
570
528
}
571
529
@@ -577,7 +535,6 @@ AbstractFunctionDecl::isDistributedTargetInvocationEncoderRecordArgument() const
577
535
auto requirements = sig.getRequirements ();
578
536
579
537
if (requirements.size () != expectedRequirementsNum) {
580
- fprintf (stderr, " [%s:%d] (%s) return false\n " , __FILE__, __LINE__, __FUNCTION__);
581
538
return false ;
582
539
}
583
540
@@ -589,12 +546,10 @@ AbstractFunctionDecl::isDistributedTargetInvocationEncoderRecordArgument() const
589
546
590
547
auto func = dyn_cast<FuncDecl>(this );
591
548
if (!func) {
592
- fprintf (stderr, " [%s:%d] (%s) return false\n " , __FILE__, __LINE__, __FUNCTION__);
593
549
return false ;
594
550
}
595
551
596
- auto resultType = func->mapTypeIntoContext (func->getResultInterfaceType ())
597
- ->getMetatypeInstanceType ()
552
+ auto resultType = func->mapTypeIntoContext (argumentParam->getInterfaceType ())
598
553
->getDesugaredType ();
599
554
auto resultParamType = func->mapTypeIntoContext (
600
555
ArgumentParam->getInterfaceType ()->getMetatypeInstanceType ());
@@ -606,14 +561,12 @@ AbstractFunctionDecl::isDistributedTargetInvocationEncoderRecordArgument() const
606
561
for (auto requirementProto : requirementProtos) {
607
562
auto conformance = module ->lookupConformance (resultType, requirementProto);
608
563
if (conformance.isInvalid ()) {
609
- fprintf (stderr, " [%s:%d] (%s) return false\n " , __FILE__, __LINE__, __FUNCTION__);
610
564
return false ;
611
565
}
612
566
}
613
567
614
568
// === Check result type: Void
615
569
if (!func->getResultInterfaceType ()->isVoid ()) {
616
- fprintf (stderr, " [%s:%d] (%s) return false\n " , __FILE__, __LINE__, __FUNCTION__);
617
570
return false ;
618
571
}
619
572
@@ -626,8 +579,9 @@ AbstractFunctionDecl::isDistributedTargetInvocationEncoderRecordReturnType() con
626
579
auto module = getParentModule ();
627
580
628
581
// === Check base name
629
- if (getBaseIdentifier () != C.Id_recordReturnType )
582
+ if (getBaseIdentifier () != C.Id_recordReturnType ) {
630
583
return false ;
584
+ }
631
585
632
586
// === Must be declared in a 'DistributedTargetInvocationEncoder' conforming type
633
587
ProtocolDecl *encoderProto =
@@ -654,7 +608,6 @@ AbstractFunctionDecl::isDistributedTargetInvocationEncoderRecordReturnType() con
654
608
655
609
// === Check generics
656
610
if (!isGeneric ()) {
657
- fprintf (stderr, " [%s:%d] (%s) if (!isGeneric())\n " , __FILE__, __LINE__, __FUNCTION__);
658
611
return false ;
659
612
}
660
613
@@ -663,7 +616,6 @@ AbstractFunctionDecl::isDistributedTargetInvocationEncoderRecordReturnType() con
663
616
unsigned int expectedGenericParamNum = 1 ;
664
617
665
618
if (genericParams->size () != expectedGenericParamNum) {
666
- fprintf (stderr, " [%s:%d] (%s) if (genericParams->size() != expectedGenericParamNum)\n " , __FILE__, __LINE__, __FUNCTION__);
667
619
return false ;
668
620
}
669
621
@@ -686,7 +638,7 @@ AbstractFunctionDecl::isDistributedTargetInvocationEncoderRecordReturnType() con
686
638
687
639
// --- Check parameter: _ argument
688
640
auto argumentParam = params->get (0 );
689
- if (!argumentParam->getArgumentName ().is (" _ " )) {
641
+ if (!argumentParam->getArgumentName ().is (" " )) {
690
642
return false ;
691
643
}
692
644
@@ -708,14 +660,17 @@ AbstractFunctionDecl::isDistributedTargetInvocationEncoderRecordReturnType() con
708
660
// ...
709
661
710
662
auto func = dyn_cast<FuncDecl>(this );
711
- if (!func)
663
+ if (!func) {
712
664
return false ;
665
+ }
713
666
714
- auto resultType = func->mapTypeIntoContext (func-> getResultInterfaceType ())
667
+ auto resultType = func->mapTypeIntoContext (argumentParam-> getInterfaceType ())
715
668
->getMetatypeInstanceType ()
716
669
->getDesugaredType ();
670
+
717
671
auto resultParamType = func->mapTypeIntoContext (
718
672
ArgumentParam->getInterfaceType ()->getMetatypeInstanceType ());
673
+
719
674
// The result of the function must be the `Res` generic argument.
720
675
if (!resultType->isEqual (resultParamType)) {
721
676
return false ;
@@ -738,13 +693,13 @@ AbstractFunctionDecl::isDistributedTargetInvocationEncoderRecordReturnType() con
738
693
739
694
bool
740
695
AbstractFunctionDecl::isDistributedTargetInvocationEncoderRecordErrorType () const {
741
-
742
696
auto &C = getASTContext ();
743
697
auto module = getParentModule ();
744
698
745
699
// === Check base name
746
- if (getBaseIdentifier () != C.Id_recordReturnType )
700
+ if (getBaseIdentifier () != C.Id_recordErrorType ) {
747
701
return false ;
702
+ }
748
703
749
704
// === Must be declared in a 'DistributedTargetInvocationEncoder' conforming type
750
705
ProtocolDecl *encoderProto =
@@ -755,26 +710,22 @@ AbstractFunctionDecl::isDistributedTargetInvocationEncoderRecordErrorType() cons
755
710
encoderNominal->getDeclaredInterfaceType (), encoderProto);
756
711
757
712
if (protocolConformance.isInvalid ()) {
758
- fprintf (stderr, " [%s:%d] (%s) return false\n " , __FILE__, __LINE__, __FUNCTION__);
759
713
return false ;
760
714
}
761
715
762
716
// === Check modifiers
763
717
// --- must not be async
764
718
if (hasAsync ()) {
765
- fprintf (stderr, " [%s:%d] (%s) return false\n " , __FILE__, __LINE__, __FUNCTION__);
766
719
return false ;
767
720
}
768
721
769
722
// --- must be throwing
770
723
if (!hasThrows ()) {
771
- fprintf (stderr, " [%s:%d] (%s) return false\n " , __FILE__, __LINE__, __FUNCTION__);
772
724
return false ;
773
725
}
774
726
775
727
// === Check generics
776
728
if (!isGeneric ()) {
777
- fprintf (stderr, " [%s:%d] (%s) if (!isGeneric())\n " , __FILE__, __LINE__, __FUNCTION__);
778
729
return false ;
779
730
}
780
731
@@ -783,7 +734,6 @@ AbstractFunctionDecl::isDistributedTargetInvocationEncoderRecordErrorType() cons
783
734
unsigned int expectedGenericParamNum = 1 ;
784
735
785
736
if (genericParams->size () != expectedGenericParamNum) {
786
- fprintf (stderr, " [%s:%d] (%s) if (genericParams->size() != expectedGenericParamNum)\n " , __FILE__, __LINE__, __FUNCTION__);
787
737
return false ;
788
738
}
789
739
@@ -793,9 +743,9 @@ AbstractFunctionDecl::isDistributedTargetInvocationEncoderRecordErrorType() cons
793
743
return false ;
794
744
}
795
745
796
- // --- Check parameter: _ argument
746
+ // --- Check parameter: _ errorType
797
747
auto argumentParam = params->get (0 );
798
- if (!argumentParam->getArgumentName ().is (" _ " )) {
748
+ if (!argumentParam->getArgumentName ().is (" " )) {
799
749
return false ;
800
750
}
801
751
@@ -807,7 +757,14 @@ AbstractFunctionDecl::isDistributedTargetInvocationEncoderRecordErrorType() cons
807
757
}
808
758
809
759
// === Check generic parameters in detail
810
- GenericTypeParamDecl *ArgumentParam = genericParams->getParams ()[0 ];
760
+ // --- Check: Err: Error
761
+ GenericTypeParamDecl *ErrParam = genericParams->getParams ()[0 ];
762
+ auto ErrConformance = module ->lookupConformance (
763
+ mapTypeIntoContext (ErrParam->getDeclaredInterfaceType ()),
764
+ C.getProtocol (KnownProtocolKind::Error));
765
+ if (ErrConformance.isInvalid ()) {
766
+ return false ;
767
+ }
811
768
812
769
// --- Check requirement: conforms_to: Err Error
813
770
auto errorReq = requirements[0 ];
@@ -823,8 +780,9 @@ AbstractFunctionDecl::isDistributedTargetInvocationEncoderRecordErrorType() cons
823
780
824
781
// === Check result type: Void
825
782
auto func = dyn_cast<FuncDecl>(this );
826
- if (!func)
783
+ if (!func) {
827
784
return false ;
785
+ }
828
786
829
787
if (!func->getResultInterfaceType ()->isVoid ()) {
830
788
return false ;
0 commit comments