Skip to content

Commit b23e5dc

Browse files
authored
Merge pull request swiftlang#60164 from amritpan/fix-conjunction-indentations
[ConstraintSystem] Fix indentations of AST in Conjunction Steps.
2 parents 01c22b7 + 64800d5 commit b23e5dc

File tree

5 files changed

+15
-12
lines changed

5 files changed

+15
-12
lines changed

include/swift/Sema/Constraint.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -855,7 +855,8 @@ class Constraint final : public llvm::ilist_node<Constraint>,
855855
/// Print constraint placed on type and constraint properties.
856856
///
857857
/// \c skipLocator skips printing of locators.
858-
void print(llvm::raw_ostream &Out, SourceManager *sm, bool skipLocator = false) const;
858+
void print(llvm::raw_ostream &Out, SourceManager *sm, unsigned indent = 0,
859+
bool skipLocator = false) const;
859860

860861
SWIFT_DEBUG_DUMPER(dump(SourceManager *SM));
861862

include/swift/Sema/ConstraintSystem.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6117,7 +6117,7 @@ class DisjunctionChoice {
61176117
bool isSymmetricOperator() const;
61186118
bool isUnaryOperator() const;
61196119

6120-
void print(llvm::raw_ostream &Out, SourceManager *SM) const {
6120+
void print(llvm::raw_ostream &Out, SourceManager *SM, unsigned indent = 0) const {
61216121
Out << "disjunction choice ";
61226122
Choice->print(Out, SM);
61236123
}
@@ -6149,9 +6149,9 @@ class ConjunctionElement {
61496149

61506150
ConstraintLocator *getLocator() const { return Element->getLocator(); }
61516151

6152-
void print(llvm::raw_ostream &Out, SourceManager *SM) const {
6152+
void print(llvm::raw_ostream &Out, SourceManager *SM, unsigned indent) const {
61536153
Out << "conjunction element ";
6154-
Element->print(Out, SM);
6154+
Element->print(Out, SM, indent);
61556155
}
61566156

61576157
private:
@@ -6186,7 +6186,7 @@ class TypeVariableBinding {
61866186
Optional<std::pair<ConstraintFix *, unsigned>>
61876187
fixForHole(ConstraintSystem &cs) const;
61886188

6189-
void print(llvm::raw_ostream &Out, SourceManager *) const {
6189+
void print(llvm::raw_ostream &Out, SourceManager *, unsigned indent) const {
61906190
PrintOptions PO;
61916191
PO.PrintTypesForDebugging = true;
61926192
Out << "type variable " << TypeVar->getString(PO)

lib/Sema/CSStep.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -843,9 +843,6 @@ StepResult ConjunctionStep::resume(bool prevFailed) {
843843
// attempted to apply information gained from the
844844
// isolated constraint to the outer context.
845845
if (Snapshot && Snapshot->isScoped()) {
846-
if (CS.isDebugMode())
847-
getDebugLogger() << ")\n";
848-
849846
return done(/*isSuccess=*/!prevFailed);
850847
}
851848

lib/Sema/CSStep.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ template <typename P> class BindingStep : public SolverStep {
519519
if (CS.isDebugMode()) {
520520
auto &log = getDebugLogger();
521521
log << "(attempting ";
522-
choice->print(log, &CS.getASTContext().SourceMgr);
522+
choice->print(log, &CS.getASTContext().SourceMgr, CS.solverState->depth * 2 + 2);
523523
log << '\n';
524524
}
525525

@@ -974,6 +974,9 @@ class ConjunctionStep : public BindingStep<ConjunctionElementProducer> {
974974
auto remainingTime = OuterTimeRemaining->second;
975975
CS.Timer.emplace(anchor, CS, remainingTime);
976976
}
977+
978+
if (CS.isDebugMode())
979+
getDebugLogger() << ")\n";
977980
}
978981

979982
StepResult resume(bool prevFailed) override;

lib/Sema/Constraint.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ Constraint *Constraint::clone(ConstraintSystem &cs) const {
322322
llvm_unreachable("Unhandled ConstraintKind in switch.");
323323
}
324324

325-
void Constraint::print(llvm::raw_ostream &Out, SourceManager *sm, bool skipLocator) const {
325+
void Constraint::print(llvm::raw_ostream &Out, SourceManager *sm, unsigned indent, bool skipLocator) const {
326326
// Print all type variables as $T0 instead of _ here.
327327
PrintOptions PO;
328328
PO.PrintTypesForDebugging = true;
@@ -382,10 +382,12 @@ void Constraint::print(llvm::raw_ostream &Out, SourceManager *sm, bool skipLocat
382382
auto *patternBinding = cast<PatternBindingDecl>(element.get<Decl *>());
383383
Out << "pattern binding element @ ";
384384
Out << patternBindingElt->getIndex() << " : ";
385-
patternBinding->getPattern(patternBindingElt->getIndex())->dump(Out);
385+
Out << '\n';
386+
patternBinding->getPattern(patternBindingElt->getIndex())->dump(Out, indent);
386387
} else {
387388
Out << "syntactic element ";
388-
element.dump(Out);
389+
Out << '\n';
390+
element.dump(Out, indent);
389391
}
390392

391393
return;

0 commit comments

Comments
 (0)