Skip to content

Commit cf80110

Browse files
authored
Merge pull request #12153 from xedin/pretty-potentinal-bindings-output
2 parents a9c71b5 + c08610b commit cf80110

File tree

2 files changed

+35
-38
lines changed

2 files changed

+35
-38
lines changed

lib/Sema/ConstraintSystem.h

Lines changed: 26 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2641,35 +2641,32 @@ class ConstraintSystem {
26412641
if (NumDefaultableBindings > 0)
26422642
out << "#defaultable_bindings=" << NumDefaultableBindings << " ";
26432643

2644-
out << "bindings=";
2645-
if (!Bindings.empty()) {
2646-
interleave(Bindings,
2647-
[&](const PotentialBinding &binding) {
2648-
auto type = binding.BindingType;
2649-
auto &ctx = type->getASTContext();
2650-
llvm::SaveAndRestore<bool> debugConstraints(
2651-
ctx.LangOpts.DebugConstraintSolver, true);
2652-
switch (binding.Kind) {
2653-
case AllowedBindingKind::Exact:
2654-
break;
2655-
2656-
case AllowedBindingKind::Subtypes:
2657-
out << "(subtypes of) ";
2658-
break;
2659-
2660-
case AllowedBindingKind::Supertypes:
2661-
out << "(supertypes of) ";
2662-
break;
2663-
}
2664-
if (binding.DefaultedProtocol)
2665-
out << "(default from "
2666-
<< (*binding.DefaultedProtocol)->getName() << ") ";
2667-
out << type.getString();
2668-
},
2669-
[&]() { out << " "; });
2670-
} else {
2671-
out << "{}";
2672-
}
2644+
out << "bindings={";
2645+
interleave(Bindings,
2646+
[&](const PotentialBinding &binding) {
2647+
auto type = binding.BindingType;
2648+
auto &ctx = type->getASTContext();
2649+
llvm::SaveAndRestore<bool> debugConstraints(
2650+
ctx.LangOpts.DebugConstraintSolver, true);
2651+
switch (binding.Kind) {
2652+
case AllowedBindingKind::Exact:
2653+
break;
2654+
2655+
case AllowedBindingKind::Subtypes:
2656+
out << "(subtypes of) ";
2657+
break;
2658+
2659+
case AllowedBindingKind::Supertypes:
2660+
out << "(supertypes of) ";
2661+
break;
2662+
}
2663+
if (binding.DefaultedProtocol)
2664+
out << "(default from "
2665+
<< (*binding.DefaultedProtocol)->getName() << ") ";
2666+
out << type.getString();
2667+
},
2668+
[&]() { out << "; "; });
2669+
out << "}";
26732670
}
26742671

26752672
void dump(ConstraintSystem *cs,

test/Constraints/interpolation_segments.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,30 +16,30 @@
1616
// CHECK-NEXT: 9:
1717

1818
// CHECK: (solving component #
19-
// CHECK: literal=3 bindings=(subtypes of) (default from ExpressibleByStringLiteral) String)
19+
// CHECK: literal=3 bindings={(subtypes of) (default from ExpressibleByStringLiteral) String})
2020

2121
// CHECK: (solving component #
22-
// CHECK: literal=3 bindings=(subtypes of) (default from ExpressibleByIntegerLiteral) Int)
22+
// CHECK: literal=3 bindings={(subtypes of) (default from ExpressibleByIntegerLiteral) Int})
2323

2424
// CHECK: (solving component #
25-
// CHECK: literal=3 bindings=(subtypes of) (default from ExpressibleByStringLiteral) String)
25+
// CHECK: literal=3 bindings={(subtypes of) (default from ExpressibleByStringLiteral) String})
2626

2727
// CHECK: (solving component #
28-
// CHECK: literal=3 bindings=(subtypes of) (default from ExpressibleByIntegerLiteral) Int)
28+
// CHECK: literal=3 bindings={(subtypes of) (default from ExpressibleByIntegerLiteral) Int})
2929

3030
// CHECK: (solving component #
31-
// CHECK: literal=3 bindings=(subtypes of) (default from ExpressibleByStringLiteral) String)
31+
// CHECK: literal=3 bindings={(subtypes of) (default from ExpressibleByStringLiteral) String})
3232

3333
// CHECK: (solving component #
34-
// CHECK: literal=3 bindings=(subtypes of) (default from ExpressibleByIntegerLiteral) Int)
34+
// CHECK: literal=3 bindings={(subtypes of) (default from ExpressibleByIntegerLiteral) Int})
3535

3636
// CHECK: (solving component #
37-
// CHECK: literal=3 bindings=(subtypes of) (default from ExpressibleByStringLiteral) String)
37+
// CHECK: literal=3 bindings={(subtypes of) (default from ExpressibleByStringLiteral) String})
3838

3939
// CHECK: (solving component #
40-
// CHECK: literal=3 bindings=(subtypes of) (default from ExpressibleByIntegerLiteral) Int)
40+
// CHECK: literal=3 bindings={(subtypes of) (default from ExpressibleByIntegerLiteral) Int})
4141

4242
// CHECK: (solving component #
43-
// CHECK: literal=3 bindings=(subtypes of) (default from ExpressibleByStringLiteral) String)
43+
// CHECK: literal=3 bindings={(subtypes of) (default from ExpressibleByStringLiteral) String})
4444

4545
_ = "\(1), \(2), \(3), \(4)"

0 commit comments

Comments
 (0)