@@ -8025,132 +8025,6 @@ void GenericSignatureBuilder::addGenericSignature(GenericSignature sig) {
8025
8025
addRequirement (reqt, FloatingRequirementSource::forAbstract (), nullptr );
8026
8026
}
8027
8027
8028
- #ifndef NDEBUG
8029
-
8030
- static void checkGenericSignature (CanGenericSignature canSig,
8031
- GenericSignatureBuilder &builder) {
8032
- PrettyStackTraceGenericSignature debugStack (" checking" , canSig);
8033
-
8034
- auto canonicalRequirements = canSig.getRequirements ();
8035
-
8036
- // We collect conformance requirements to check that they're minimal.
8037
- llvm::SmallDenseMap<CanType, SmallVector<ProtocolDecl *, 2 >, 2 > conformances;
8038
-
8039
- // Check that the signature is canonical.
8040
- for (unsigned idx : indices (canonicalRequirements)) {
8041
- debugStack.setRequirement (idx);
8042
-
8043
- const auto &reqt = canonicalRequirements[idx];
8044
-
8045
- // Left-hand side must be canonical in its context.
8046
- // Check canonicalization of requirement itself.
8047
- switch (reqt.getKind ()) {
8048
- case RequirementKind::Superclass:
8049
- assert (canSig->isCanonicalTypeInContext (reqt.getFirstType (), builder) &&
8050
- " Left-hand side is not canonical" );
8051
- assert (canSig->isCanonicalTypeInContext (reqt.getSecondType (), builder) &&
8052
- " Superclass type isn't canonical in its own context" );
8053
- break ;
8054
-
8055
- case RequirementKind::Layout:
8056
- assert (canSig->isCanonicalTypeInContext (reqt.getFirstType (), builder) &&
8057
- " Left-hand side is not canonical" );
8058
- break ;
8059
-
8060
- case RequirementKind::SameType: {
8061
- auto isCanonicalAnchor = [&](Type type) {
8062
- if (auto *dmt = type->getAs <DependentMemberType>())
8063
- return canSig->isCanonicalTypeInContext (dmt->getBase (), builder);
8064
- return type->is <GenericTypeParamType>();
8065
- };
8066
-
8067
- auto firstType = reqt.getFirstType ();
8068
- auto secondType = reqt.getSecondType ();
8069
- assert (isCanonicalAnchor (firstType));
8070
-
8071
- if (reqt.getSecondType ()->isTypeParameter ()) {
8072
- assert (isCanonicalAnchor (secondType));
8073
- assert (compareDependentTypes (firstType, secondType) < 0 &&
8074
- " Out-of-order type parameters in same-type constraint" );
8075
- } else {
8076
- assert (canSig->isCanonicalTypeInContext (secondType, builder) &&
8077
- " Concrete same-type isn't canonical in its own context" );
8078
- }
8079
- break ;
8080
- }
8081
-
8082
- case RequirementKind::Conformance:
8083
- assert (canSig->isCanonicalTypeInContext (reqt.getFirstType (), builder) &&
8084
- " Left-hand side is not canonical" );
8085
- assert (reqt.getFirstType ()->isTypeParameter () &&
8086
- " Left-hand side must be a type parameter" );
8087
- assert (isa<ProtocolType>(reqt.getSecondType ().getPointer ()) &&
8088
- " Right-hand side of conformance isn't a protocol type" );
8089
-
8090
- // Collect all conformance requirements on each type parameter.
8091
- conformances[CanType (reqt.getFirstType ())].push_back (
8092
- reqt.getProtocolDecl ());
8093
- break ;
8094
- }
8095
-
8096
- // From here on, we're only interested in requirements beyond the first.
8097
- if (idx == 0 ) continue ;
8098
-
8099
- // Make sure that the left-hand sides are in nondecreasing order.
8100
- const auto &prevReqt = canonicalRequirements[idx-1 ];
8101
- int compareLHS =
8102
- compareDependentTypes (prevReqt.getFirstType (), reqt.getFirstType ());
8103
- assert (compareLHS <= 0 && " Out-of-order left-hand sides" );
8104
-
8105
- // If we have two same-type requirements where the left-hand sides differ
8106
- // but fall into the same equivalence class, we can check the form.
8107
- if (compareLHS < 0 && reqt.getKind () == RequirementKind::SameType &&
8108
- prevReqt.getKind () == RequirementKind::SameType &&
8109
- canSig->areSameTypeParameterInContext (prevReqt.getFirstType (),
8110
- reqt.getFirstType (),
8111
- builder)) {
8112
- // If it's a it's a type parameter, make sure the equivalence class is
8113
- // wired together sanely.
8114
- if (prevReqt.getSecondType ()->isTypeParameter ()) {
8115
- assert (prevReqt.getSecondType ()->isEqual (reqt.getFirstType ()) &&
8116
- " same-type constraints within an equiv. class are out-of-order" );
8117
- } else {
8118
- // Otherwise, the concrete types must match up.
8119
- assert (prevReqt.getSecondType ()->isEqual (reqt.getSecondType ()) &&
8120
- " inconsistent concrete same-type constraints in equiv. class" );
8121
- }
8122
- }
8123
-
8124
- // If we have a concrete same-type requirement, we shouldn't have any
8125
- // other requirements on the same type.
8126
- if (reqt.getKind () == RequirementKind::SameType &&
8127
- !reqt.getSecondType ()->isTypeParameter ()) {
8128
- assert (compareLHS < 0 &&
8129
- " Concrete subject type should not have any other requirements" );
8130
- }
8131
-
8132
- assert (prevReqt.compare (reqt) < 0 &&
8133
- " Out-of-order requirements" );
8134
- }
8135
-
8136
- // Make sure we don't have redundant protocol conformance requirements.
8137
- for (auto pair : conformances) {
8138
- const auto &protos = pair.second ;
8139
- auto canonicalProtos = protos;
8140
-
8141
- // canonicalizeProtocols() will sort them and filter out any protocols that
8142
- // are refined by other protocols in the list. It should be a no-op at this
8143
- // point.
8144
- ProtocolType::canonicalizeProtocols (canonicalProtos);
8145
-
8146
- assert (protos.size () == canonicalProtos.size () &&
8147
- " redundant conformance requirements" );
8148
- assert (std::equal (protos.begin (), protos.end (), canonicalProtos.begin ()) &&
8149
- " out-of-order conformance requirements" );
8150
- }
8151
- }
8152
- #endif
8153
-
8154
8028
static Type stripBoundDependentMemberTypes (Type t) {
8155
8029
if (auto *depMemTy = t->getAs <DependentMemberType>()) {
8156
8030
return DependentMemberType::get (
@@ -8444,15 +8318,8 @@ GenericSignature GenericSignatureBuilder::computeGenericSignature(
8444
8318
// Form the generic signature.
8445
8319
auto sig = GenericSignature::get (getGenericParams (), requirements);
8446
8320
8447
- #ifndef NDEBUG
8448
8321
bool hadAnyError = Impl->HadAnyError ;
8449
8322
8450
- if (requirementSignatureSelfProto &&
8451
- !hadAnyError) {
8452
- checkGenericSignature (sig.getCanonicalSignature (), *this );
8453
- }
8454
- #endif
8455
-
8456
8323
// When we can, move this generic signature builder to make it the canonical
8457
8324
// builder, rather than constructing a new generic signature builder that
8458
8325
// will produce the same thing.
@@ -8461,7 +8328,7 @@ GenericSignature GenericSignatureBuilder::computeGenericSignature(
8461
8328
//
8462
8329
// Also, we cannot do this when building a requirement signature.
8463
8330
if (requirementSignatureSelfProto == nullptr &&
8464
- !Impl-> HadAnyError ) {
8331
+ !hadAnyError ) {
8465
8332
// Register this generic signature builder as the canonical builder for the
8466
8333
// given signature.
8467
8334
Context.registerGenericSignatureBuilder (sig, std::move (*this ));
@@ -8472,7 +8339,7 @@ GenericSignature GenericSignatureBuilder::computeGenericSignature(
8472
8339
Impl.reset ();
8473
8340
8474
8341
#ifndef NDEBUG
8475
- if (! requirementSignatureSelfProto &&
8342
+ if (requirementSignatureSelfProto == nullptr &&
8476
8343
!hadAnyError) {
8477
8344
sig.verify ();
8478
8345
}
0 commit comments