Skip to content

Commit ceb123b

Browse files
committed
AssociatedTypeInference: Add -dump-type-witness-systems flag to enable debug output
1 parent a40aa11 commit ceb123b

File tree

4 files changed

+12
-0
lines changed

4 files changed

+12
-0
lines changed

include/swift/Basic/LangOptions.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,9 @@ namespace swift {
534534
RequirementMachineMode RequirementMachineInferredSignatures =
535535
RequirementMachineMode::Disabled;
536536

537+
/// Enables dumping type witness systems from associated type inference.
538+
bool DumpTypeWitnessSystems = false;
539+
537540
/// Sets the target we are building for and updates platform conditions
538541
/// to match.
539542
///

include/swift/Option/FrontendOptions.td

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,9 @@ def requirement_machine_max_concrete_nesting : Joined<["-"], "requirement-machin
356356
Flags<[FrontendOption, HelpHidden, DoesNotAffectIncrementalBuild]>,
357357
HelpText<"Set the maximum concrete type nesting depth before giving up">;
358358

359+
def dump_type_witness_systems : Flag<["-"], "dump-type-witness-systems">,
360+
HelpText<"Enables dumping type witness systems from associated type inference">;
361+
359362
def debug_generic_signatures : Flag<["-"], "debug-generic-signatures">,
360363
HelpText<"Debug generic signatures">;
361364

lib/Frontend/CompilerInvocation.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -955,6 +955,8 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
955955
}
956956
}
957957

958+
Opts.DumpTypeWitnessSystems = Args.hasArg(OPT_dump_type_witness_systems);
959+
958960
return HadError || UnsupportedOS || UnsupportedArch;
959961
}
960962

lib/Sema/TypeCheckProtocolInference.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1225,6 +1225,10 @@ AssociatedTypeDecl *AssociatedTypeInference::inferAbstractTypeWitnesses(
12251225
TypeWitnessSystem system(unresolvedAssocTypes);
12261226
collectAbstractTypeWitnesses(system, unresolvedAssocTypes);
12271227

1228+
if (ctx.LangOpts.DumpTypeWitnessSystems) {
1229+
system.dump(llvm::dbgs(), conformance);
1230+
}
1231+
12281232
// If we couldn't resolve an associated type, bail out.
12291233
for (auto *assocType : unresolvedAssocTypes) {
12301234
if (!system.hasResolvedTypeWitness(assocType->getName())) {

0 commit comments

Comments
 (0)