Skip to content

Commit ceb78c0

Browse files
committed
[Constraint] NFC: Improve debug output of pattern binding element constraints
1 parent a5cff5a commit ceb78c0

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

lib/Sema/Constraint.cpp

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -388,8 +388,21 @@ void Constraint::print(llvm::raw_ostream &Out, SourceManager *sm) const {
388388
}
389389

390390
if (Kind == ConstraintKind::ClosureBodyElement) {
391-
Out << "closure body element ";
392-
getClosureElement().dump(Out);
391+
auto *locator = getLocator();
392+
auto element = getClosureElement();
393+
394+
if (auto patternBindingElt =
395+
locator
396+
->getLastElementAs<LocatorPathElt::PatternBindingElement>()) {
397+
auto *patternBinding = cast<PatternBindingDecl>(element.get<Decl *>());
398+
Out << "pattern binding element @ ";
399+
Out << patternBindingElt->getIndex() << " : ";
400+
patternBinding->getPattern(patternBindingElt->getIndex())->dump(Out);
401+
} else {
402+
Out << "closure body element ";
403+
getClosureElement().dump(Out);
404+
}
405+
393406
return;
394407
}
395408

0 commit comments

Comments
 (0)