File tree Expand file tree Collapse file tree 4 files changed +18
-10
lines changed
lib/AST/RequirementMachine Expand file tree Collapse file tree 4 files changed +18
-10
lines changed Original file line number Diff line number Diff line change @@ -371,7 +371,7 @@ void RequirementMachine::addGenericSignature(CanGenericSignature sig) {
371371 std::move (builder.RequirementRules ),
372372 std::move (builder.Protocols ));
373373
374- computeCompletion ();
374+ computeCompletion (RewriteSystem::DisallowInvalidRequirements );
375375
376376 if (Dump) {
377377 llvm::dbgs () << " }\n " ;
@@ -380,7 +380,7 @@ void RequirementMachine::addGenericSignature(CanGenericSignature sig) {
380380
381381// / Attempt to obtain a confluent rewrite system using the completion
382382// / procedure.
383- void RequirementMachine::computeCompletion () {
383+ void RequirementMachine::computeCompletion (RewriteSystem::ValidityPolicy policy ) {
384384 while (true ) {
385385 // First, run the Knuth-Bendix algorithm to resolve overlapping rules.
386386 auto result = System.computeConfluentCompletion (
@@ -415,7 +415,7 @@ void RequirementMachine::computeCompletion() {
415415 checkCompletionResult ();
416416
417417 // Check invariants.
418- System.verifyRewriteRules ();
418+ System.verifyRewriteRules (policy );
419419 System.verifyHomotopyGenerators ();
420420
421421 // Build the property map, which also performs concrete term
Original file line number Diff line number Diff line change @@ -80,7 +80,8 @@ class RequirementMachine final {
8080 void addGenericSignature (CanGenericSignature sig);
8181
8282 bool isComplete () const ;
83- void computeCompletion ();
83+
84+ void computeCompletion (RewriteSystem::ValidityPolicy policy);
8485
8586 MutableTerm getLongestValidPrefix (const MutableTerm &term) const ;
8687
Original file line number Diff line number Diff line change @@ -358,7 +358,7 @@ void RewriteSystem::simplifyRewriteSystem() {
358358 }
359359}
360360
361- void RewriteSystem::verifyRewriteRules () const {
361+ void RewriteSystem::verifyRewriteRules (ValidityPolicy policy ) const {
362362#ifndef NDEBUG
363363
364364#define ASSERT_RULE (expr ) \
@@ -396,10 +396,12 @@ void RewriteSystem::verifyRewriteRules() const {
396396 for (unsigned index : indices (rhs)) {
397397 auto symbol = rhs[index];
398398
399- // FIXME: This is only true if the input requirements were valid.
400- // On invalid code, we'll need to skip this assertion (and instead
401- // assert that we diagnosed an error!)
402- ASSERT_RULE (symbol.getKind () != Symbol::Kind::Name);
399+ // This is only true if the input requirements were valid.
400+ if (policy == DisallowInvalidRequirements) {
401+ ASSERT_RULE (symbol.getKind () != Symbol::Kind::Name);
402+ } else {
403+ // FIXME: Assert that we diagnosed an error
404+ }
403405
404406 ASSERT_RULE (symbol.getKind () != Symbol::Kind::Layout);
405407 ASSERT_RULE (!symbol.isSuperclassOrConcreteType ());
Original file line number Diff line number Diff line change @@ -406,7 +406,12 @@ class RewriteSystem final {
406406
407407 void minimizeRewriteSystem ();
408408
409- void verifyRewriteRules () const ;
409+ enum ValidityPolicy {
410+ AllowInvalidRequirements,
411+ DisallowInvalidRequirements
412+ };
413+
414+ void verifyRewriteRules (ValidityPolicy policy) const ;
410415
411416 void verifyHomotopyGenerators () const ;
412417
You can’t perform that action at this time.
0 commit comments