@@ -663,6 +663,9 @@ struct GenericSignatureBuilder::Implementation {
663
663
// / Whether there were any errors.
664
664
bool HadAnyError = false ;
665
665
666
+ // / Set this to true to get some debug output.
667
+ bool DebugRedundantRequirements = false ;
668
+
666
669
// / All explicit non-same type requirements that were added to the builder.
667
670
SmallSetVector<ExplicitRequirement, 2 > ExplicitRequirements;
668
671
@@ -5770,7 +5773,12 @@ void GenericSignatureBuilder::ExplicitRequirement::dump(
5770
5773
break ;
5771
5774
}
5772
5775
5773
- out << getSubjectType () << " : " ;
5776
+ out << getSubjectType ();
5777
+ if (getKind () == RequirementKind::SameType)
5778
+ out << " : " ;
5779
+ else
5780
+ out << " == " ;
5781
+
5774
5782
if (auto type = rhs.dyn_cast <Type>())
5775
5783
out << type;
5776
5784
else if (auto *proto = rhs.dyn_cast <ProtocolDecl *>())
@@ -8435,12 +8443,22 @@ GenericSignature GenericSignatureBuilder::rebuildSignatureWithoutRedundantRequir
8435
8443
};
8436
8444
8437
8445
for (const auto &req : Impl->ExplicitRequirements ) {
8446
+ if (Impl->DebugRedundantRequirements ) {
8447
+ req.dump (llvm::dbgs (), &Context.SourceMgr );
8448
+ llvm::dbgs () << " \n " ;
8449
+ }
8450
+
8438
8451
assert (req.getKind () != RequirementKind::SameType &&
8439
8452
" Should not see same-type requirement here" );
8440
8453
8441
8454
if (isRedundantExplicitRequirement (req) &&
8442
- Impl->ExplicitConformancesImpliedByConcrete .count (req))
8455
+ Impl->ExplicitConformancesImpliedByConcrete .count (req)) {
8456
+ if (Impl->DebugRedundantRequirements ) {
8457
+ llvm::dbgs () << " ... skipping\n " ;
8458
+ }
8459
+
8443
8460
continue ;
8461
+ }
8444
8462
8445
8463
auto subjectType = req.getSubjectType ();
8446
8464
subjectType = stripBoundDependentMemberTypes (subjectType);
@@ -8471,6 +8489,11 @@ GenericSignature GenericSignatureBuilder::rebuildSignatureWithoutRedundantRequir
8471
8489
}
8472
8490
8473
8491
for (const auto &req : Impl->ExplicitSameTypeRequirements ) {
8492
+ if (Impl->DebugRedundantRequirements ) {
8493
+ req.dump (llvm::dbgs (), &Context.SourceMgr );
8494
+ llvm::dbgs () << " \n " ;
8495
+ }
8496
+
8474
8497
auto resolveType = [this ](Type t) -> Type {
8475
8498
t = stripBoundDependentMemberTypes (t);
8476
8499
if (t->is <GenericTypeParamType>()) {
@@ -8499,6 +8522,11 @@ GenericSignature GenericSignatureBuilder::rebuildSignatureWithoutRedundantRequir
8499
8522
Requirement (RequirementKind::SameType,
8500
8523
subjectType, constraintType));
8501
8524
8525
+ if (Impl->DebugRedundantRequirements ) {
8526
+ llvm::dbgs () << " => " ;
8527
+ newReq.dump (llvm::dbgs ());
8528
+ llvm::dbgs () << " \n " ;
8529
+ }
8502
8530
newBuilder.addRequirement (newReq, getRebuiltSource (req.getSource ()),
8503
8531
nullptr );
8504
8532
}
@@ -8535,16 +8563,27 @@ GenericSignature GenericSignatureBuilder::computeGenericSignature(
8535
8563
diagnoseRedundantRequirements (
8536
8564
/* onlyDiagnoseExplicitConformancesImpliedByConcrete=*/ true );
8537
8565
8566
+ if (Impl->DebugRedundantRequirements ) {
8567
+ llvm::dbgs () << " Going to rebuild signature\n " ;
8568
+ }
8538
8569
return std::move (*this ).rebuildSignatureWithoutRedundantRequirements (
8539
8570
allowConcreteGenericParams,
8540
8571
requirementSignatureSelfProto);
8541
8572
}
8542
8573
8543
8574
if (Impl->RebuildingWithoutRedundantConformances ) {
8575
+ if (Impl->DebugRedundantRequirements ) {
8576
+ llvm::dbgs () << " Rebuilding signature\n " ;
8577
+ }
8578
+
8544
8579
#ifndef NDEBUG
8545
8580
for (const auto &req : Impl->ExplicitConformancesImpliedByConcrete ) {
8546
- assert (!isRedundantExplicitRequirement (req) &&
8547
- " Rebuilt signature still had redundant conformance requirements" );
8581
+ if (isRedundantExplicitRequirement (req)) {
8582
+ llvm::errs () << " Rebuilt signature still had redundant conformance requirement\n " ;
8583
+ req.dump (llvm::errs (), &Context.SourceMgr );
8584
+ llvm::errs () << " \n " ;
8585
+ abort ();
8586
+ }
8548
8587
}
8549
8588
#endif
8550
8589
}
0 commit comments