@@ -243,12 +243,12 @@ RequirementMachine::getLongestValidPrefix(const MutableTerm &term) const {
243243 return prefix;
244244
245245 case Symbol::Kind::Protocol:
246- assert (prefix.empty () &&
246+ ASSERT (prefix.empty () &&
247247 " Protocol symbol can only appear at the start of a type term" );
248248 break ;
249249
250250 case Symbol::Kind::GenericParam: {
251- assert (prefix.empty () &&
251+ ASSERT (prefix.empty () &&
252252 " Generic parameter symbol can only appear at the start of a type term" );
253253
254254 if (std::find_if (Params.begin (), Params.end (),
@@ -500,8 +500,6 @@ Type RequirementMachine::getReducedType(
500500// / Determine if the given type parameter is valid with respect to this
501501// / requirement machine's generic signature.
502502bool RequirementMachine::isValidTypeParameter (Type type) const {
503- assert (type->isTypeParameter ());
504-
505503 auto term = Context.getMutableTermForType (type->getCanonicalType (),
506504 /* proto=*/ nullptr );
507505 System.simplify (term);
@@ -525,23 +523,21 @@ bool RequirementMachine::isValidTypeParameter(Type type) const {
525523ConformancePath
526524RequirementMachine::getConformancePath (Type type,
527525 ProtocolDecl *protocol) {
528- assert (type->isTypeParameter ());
529-
530526 auto mutTerm = Context.getMutableTermForType (type->getCanonicalType (),
531527 /* proto=*/ nullptr );
532528 System.simplify (mutTerm);
533529 verify (mutTerm);
534530
535- # ifndef NDEBUG
536- auto *props = Map.lookUpProperties (mutTerm);
537- assert (props &&
538- " Subject type of conformance access path should be known" );
539- assert (!props->isConcreteType () &&
540- " Concrete types do not have conformance access paths" );
541- auto conformsTo = props->getConformsTo ();
542- assert (std::find (conformsTo.begin (), conformsTo.end (), protocol) &&
543- " Subject type of conformance access path must conform to protocol" );
544- # endif
531+ if ( CONDITIONAL_ASSERT_enabled ()) {
532+ auto *props = Map.lookUpProperties (mutTerm);
533+ ASSERT (props &&
534+ " Subject type of conformance access path should be known" );
535+ ASSERT (!props->isConcreteType () &&
536+ " Concrete types do not have conformance access paths" );
537+ auto conformsTo = props->getConformsTo ();
538+ ASSERT (std::find (conformsTo.begin (), conformsTo.end (), protocol) &&
539+ " Subject type of conformance access path must conform to protocol" );
540+ }
545541
546542 auto term = Term::get (mutTerm, Context);
547543
@@ -565,8 +561,7 @@ RequirementMachine::getConformancePath(Type type,
565561 auto key = std::make_pair (term, proto);
566562 auto inserted = ConformancePaths.insert (
567563 std::make_pair (key, path));
568- assert (inserted.second );
569- (void ) inserted;
564+ ASSERT (inserted.second );
570565
571566 if (Stats)
572567 ++Stats->getFrontendCounters ().NumConformancePathsRecorded ;
@@ -724,7 +719,7 @@ RequirementMachine::lookupNestedType(Type depType, Identifier name) const {
724719 }
725720
726721 if (bestAssocType) {
727- assert (bestAssocType->getOverriddenDecls ().empty () &&
722+ ASSERT (bestAssocType->getOverriddenDecls ().empty () &&
728723 " Lookup should never keep a non-anchor associated type" );
729724 return bestAssocType;
730725
@@ -738,7 +733,7 @@ RequirementMachine::lookupNestedType(Type depType, Identifier name) const {
738733
739734MutableTerm
740735RequirementMachine::getReducedShapeTerm (Type type) const {
741- assert (type->isParameterPack ());
736+ ASSERT (type->isParameterPack ());
742737
743738 auto term = Context.getMutableTermForType (type->getCanonicalType (),
744739 /* proto=*/ nullptr );
@@ -780,7 +775,9 @@ bool RequirementMachine::haveSameShape(Type type1, Type type2) const {
780775}
781776
782777void RequirementMachine::verify (const MutableTerm &term) const {
783- #ifndef NDEBUG
778+ if (!CONDITIONAL_ASSERT_enabled ())
779+ return ;
780+
784781 // If the term is in the generic parameter domain, ensure we have a valid
785782 // generic parameter.
786783 if (term.begin ()->getKind () == Symbol::Kind::GenericParam) {
@@ -828,7 +825,7 @@ void RequirementMachine::verify(const MutableTerm &term) const {
828825
829826 switch (symbol.getKind ()) {
830827 case Symbol::Kind::Name:
831- assert (!erased.empty ());
828+ ASSERT (!erased.empty ());
832829 erased.add (symbol);
833830 break ;
834831
@@ -865,5 +862,4 @@ void RequirementMachine::verify(const MutableTerm &term) const {
865862 dump (llvm::errs ());
866863 abort ();
867864 }
868- #endif
869865}
0 commit comments