@@ -1238,9 +1238,9 @@ void Solution::dump(raw_ostream &out) const {
1238
1238
1239
1239
SourceManager *sm = &getConstraintSystem ().getASTContext ().SourceMgr ;
1240
1240
1241
- out << " Fixed score: " << FixedScore << " \n " ;
1241
+ out << " Fixed score: " << FixedScore;
1242
1242
1243
- out << " Type variables:\n " ;
1243
+ out << " \n Type variables:\n " ;
1244
1244
std::vector<std::pair<TypeVariableType *, Type>> bindings (
1245
1245
typeBindings.begin (), typeBindings.end ());
1246
1246
llvm::sort (bindings, [](const std::pair<TypeVariableType *, Type> &lhs,
@@ -1260,77 +1260,85 @@ void Solution::dump(raw_ostream &out) const {
1260
1260
out << " \n " ;
1261
1261
}
1262
1262
1263
- out << " \n " ;
1264
- out << " Overload choices:\n " ;
1265
- for (auto ovl : overloadChoices) {
1266
- out.indent (2 );
1267
- if (ovl.first )
1268
- ovl.first ->dump (sm, out);
1269
- out << " with " ;
1270
-
1271
- auto choice = ovl.second .choice ;
1272
- switch (choice.getKind ()) {
1273
- case OverloadChoiceKind::Decl:
1274
- case OverloadChoiceKind::DeclViaDynamic:
1275
- case OverloadChoiceKind::DeclViaBridge:
1276
- case OverloadChoiceKind::DeclViaUnwrappedOptional:
1277
- choice.getDecl ()->dumpRef (out);
1278
- out << " as " ;
1279
- if (choice.getBaseType ())
1280
- out << choice.getBaseType ()->getString (PO) << " ." ;
1281
-
1282
- out << choice.getDecl ()->getBaseName () << " : "
1283
- << ovl.second .adjustedOpenedType ->getString (PO) << " \n " ;
1284
- break ;
1263
+ if (!overloadChoices.empty ()) {
1264
+ out << " \n Overload choices:" ;
1265
+ for (auto ovl : overloadChoices) {
1266
+ out.indent (2 );
1267
+ if (ovl.first ) {
1268
+ out << " \n " ;
1269
+ ovl.first ->dump (sm, out);
1270
+ }
1271
+ out << " with " ;
1285
1272
1286
- case OverloadChoiceKind::KeyPathApplication:
1287
- out << " key path application root "
1288
- << choice.getBaseType ()->getString (PO) << " \n " ;
1289
- break ;
1273
+ auto choice = ovl.second .choice ;
1274
+ switch (choice.getKind ()) {
1275
+ case OverloadChoiceKind::Decl:
1276
+ case OverloadChoiceKind::DeclViaDynamic:
1277
+ case OverloadChoiceKind::DeclViaBridge:
1278
+ case OverloadChoiceKind::DeclViaUnwrappedOptional:
1279
+ choice.getDecl ()->dumpRef (out);
1280
+ out << " as " ;
1281
+ if (choice.getBaseType ())
1282
+ out << choice.getBaseType ()->getString (PO) << " ." ;
1290
1283
1291
- case OverloadChoiceKind::DynamicMemberLookup:
1292
- case OverloadChoiceKind::KeyPathDynamicMemberLookup:
1293
- out << " dynamic member lookup root "
1294
- << choice.getBaseType ()->getString (PO)
1295
- << " name='" << choice.getName () << " '\n " ;
1296
- break ;
1297
-
1298
- case OverloadChoiceKind::TupleIndex:
1299
- out << " tuple " << choice.getBaseType ()->getString (PO) << " index "
1300
- << choice.getTupleIndex () << " \n " ;
1301
- break ;
1284
+ out << choice.getDecl ()->getBaseName () << " : "
1285
+ << ovl.second .adjustedOpenedType ->getString (PO);
1286
+ break ;
1287
+
1288
+ case OverloadChoiceKind::KeyPathApplication:
1289
+ out << " key path application root "
1290
+ << choice.getBaseType ()->getString (PO);
1291
+ break ;
1292
+
1293
+ case OverloadChoiceKind::DynamicMemberLookup:
1294
+ case OverloadChoiceKind::KeyPathDynamicMemberLookup:
1295
+ out << " dynamic member lookup root "
1296
+ << choice.getBaseType ()->getString (PO)
1297
+ << " name='" << choice.getName ();
1298
+ break ;
1299
+
1300
+ case OverloadChoiceKind::TupleIndex:
1301
+ out << " tuple " << choice.getBaseType ()->getString (PO) << " index "
1302
+ << choice.getTupleIndex ();
1303
+ break ;
1304
+ }
1302
1305
}
1303
1306
out << " \n " ;
1304
1307
}
1305
1308
1306
- out << " \n " ;
1307
- out << " Constraint restrictions:\n " ;
1308
- for (auto &restriction : ConstraintRestrictions) {
1309
- out.indent (2 ) << restriction.first .first
1310
- << " to " << restriction.first .second
1311
- << " is " << getName (restriction.second ) << " \n " ;
1309
+
1310
+ if (!ConstraintRestrictions.empty ()) {
1311
+ out << " \n Constraint restrictions:\n " ;
1312
+ for (auto &restriction : ConstraintRestrictions) {
1313
+ out.indent (2 ) << restriction.first .first
1314
+ << " to " << restriction.first .second
1315
+ << " is " << getName (restriction.second ) << " \n " ;
1316
+ }
1312
1317
}
1313
1318
1314
- out << " \n " ;
1315
- out << " Trailing closure matching:\n " ;
1316
- for (auto &argumentMatching : argumentMatchingChoices) {
1317
- out.indent (2 );
1318
- argumentMatching.first ->dump (sm, out);
1319
- switch (argumentMatching.second .trailingClosureMatching ) {
1320
- case TrailingClosureMatching::Forward:
1321
- out << " : forward\n " ;
1322
- break ;
1323
- case TrailingClosureMatching::Backward:
1324
- out << " : backward\n " ;
1325
- break ;
1319
+ if (!argumentMatchingChoices.empty ()) {
1320
+ out << " \n Trailing closure matching:\n " ;
1321
+ for (auto &argumentMatching : argumentMatchingChoices) {
1322
+ out.indent (2 );
1323
+ argumentMatching.first ->dump (sm, out);
1324
+ switch (argumentMatching.second .trailingClosureMatching ) {
1325
+ case TrailingClosureMatching::Forward:
1326
+ out << " : forward\n " ;
1327
+ break ;
1328
+ case TrailingClosureMatching::Backward:
1329
+ out << " : backward\n " ;
1330
+ break ;
1331
+ }
1326
1332
}
1327
1333
}
1328
1334
1329
- out << " \n Disjunction choices:\n " ;
1330
- for (auto &choice : DisjunctionChoices) {
1331
- out.indent (2 );
1332
- choice.first ->dump (sm, out);
1333
- out << " is #" << choice.second << " \n " ;
1335
+ if (!DisjunctionChoices.empty ()) {
1336
+ out << " \n Disjunction choices:\n " ;
1337
+ for (auto &choice : DisjunctionChoices) {
1338
+ out.indent (2 );
1339
+ choice.first ->dump (sm, out);
1340
+ out << " is #" << choice.second << " \n " ;
1341
+ }
1334
1342
}
1335
1343
1336
1344
if (!OpenedTypes.empty ()) {
@@ -1413,20 +1421,21 @@ void ConstraintSystem::print(raw_ostream &out) const {
1413
1421
// Print all type variables as $T0 instead of _ here.
1414
1422
PrintOptions PO;
1415
1423
PO.PrintTypesForDebugging = true ;
1416
-
1417
- out << " Score: " << CurrentScore << " \n " ;
1424
+
1425
+ out << " Score: " << CurrentScore;
1418
1426
1419
1427
for (const auto &contextualTypeEntry : contextualTypes) {
1420
1428
auto info = contextualTypeEntry.second .first ;
1421
- out << " Contextual Type: " << info.getType ().getString (PO);
1422
- if (TypeRepr *TR = info.typeLoc .getTypeRepr ()) {
1423
- out << " at " ;
1424
- TR->getSourceRange ().print (out, getASTContext ().SourceMgr , /* text*/ false );
1429
+ if (!info.getType ().isNull ()) {
1430
+ out << " \n Contextual Type: " << info.getType ().getString (PO);
1431
+ if (TypeRepr *TR = info.typeLoc .getTypeRepr ()) {
1432
+ out << " at " ;
1433
+ TR->getSourceRange ().print (out, getASTContext ().SourceMgr , /* text*/ false );
1434
+ }
1425
1435
}
1426
- out << " \n " ;
1427
1436
}
1428
1437
1429
- out << " Type Variables:\n " ;
1438
+ out << " \n Type Variables:\n " ;
1430
1439
std::vector<TypeVariableType *> typeVariables (getTypeVariables ().begin (),
1431
1440
getTypeVariables ().end ());
1432
1441
llvm::sort (typeVariables,
@@ -1457,18 +1466,22 @@ void ConstraintSystem::print(raw_ostream &out) const {
1457
1466
out << " \n " ;
1458
1467
}
1459
1468
1460
- out << " \n Active Constraints:\n " ;
1461
- for (auto &constraint : ActiveConstraints) {
1462
- out.indent (2 );
1463
- constraint.print (out, &getASTContext ().SourceMgr );
1464
- out << " \n " ;
1469
+ if (!ActiveConstraints.empty ()) {
1470
+ out << " \n Active Constraints:\n " ;
1471
+ for (auto &constraint : ActiveConstraints) {
1472
+ out.indent (2 );
1473
+ constraint.print (out, &getASTContext ().SourceMgr );
1474
+ out << " \n " ;
1475
+ }
1465
1476
}
1466
1477
1467
- out << " \n Inactive Constraints:\n " ;
1468
- for (auto &constraint : InactiveConstraints) {
1469
- out.indent (2 );
1470
- constraint.print (out, &getASTContext ().SourceMgr );
1471
- out << " \n " ;
1478
+ if (!InactiveConstraints.empty ()) {
1479
+ out << " \n Inactive Constraints:\n " ;
1480
+ for (auto &constraint : InactiveConstraints) {
1481
+ out.indent (2 );
1482
+ constraint.print (out, &getASTContext ().SourceMgr );
1483
+ out << " \n " ;
1484
+ }
1472
1485
}
1473
1486
1474
1487
if (solverState && solverState->hasRetiredConstraints ()) {
@@ -1481,7 +1494,7 @@ void ConstraintSystem::print(raw_ostream &out) const {
1481
1494
}
1482
1495
1483
1496
if (!ResolvedOverloads.empty ()) {
1484
- out << " Resolved overloads:\n " ;
1497
+ out << " \n Resolved overloads:\n " ;
1485
1498
1486
1499
// Otherwise, report the resolved overloads.
1487
1500
for (auto elt : ResolvedOverloads) {
@@ -1521,7 +1534,6 @@ void ConstraintSystem::print(raw_ostream &out) const {
1521
1534
elt.first ->dump (&getASTContext ().SourceMgr , out);
1522
1535
out << " \n " ;
1523
1536
}
1524
- out << " \n " ;
1525
1537
}
1526
1538
1527
1539
if (!DisjunctionChoices.empty ()) {
@@ -1562,7 +1574,7 @@ void ConstraintSystem::print(raw_ostream &out) const {
1562
1574
}
1563
1575
1564
1576
if (!DefaultedConstraints.empty ()) {
1565
- out << " \n Defaulted constraints: " ;
1577
+ out << " \n Defaulted constraints:\n " ;
1566
1578
interleave (DefaultedConstraints, [&](ConstraintLocator *locator) {
1567
1579
locator->dump (&getASTContext ().SourceMgr , out);
1568
1580
}, [&] {
0 commit comments