From 23560df5f47ac4a9ced4419aa4a36b54c14b0671 Mon Sep 17 00:00:00 2001 From: Hamish Knight Date: Sun, 7 Sep 2025 12:12:19 +0100 Subject: [PATCH] [CS] Remove `AllowUnresolvedTypeVariables` This has been unused for a while now. --- include/swift/Sema/ConstraintSystem.h | 19 ++++++------------- lib/Sema/CSSolver.cpp | 10 ---------- unittests/Sema/BindingInferenceTests.cpp | 5 +---- 3 files changed, 7 insertions(+), 27 deletions(-) diff --git a/include/swift/Sema/ConstraintSystem.h b/include/swift/Sema/ConstraintSystem.h index 407d9a5afd3f6..100acfad78a32 100644 --- a/include/swift/Sema/ConstraintSystem.h +++ b/include/swift/Sema/ConstraintSystem.h @@ -1937,13 +1937,6 @@ enum class ConstraintSystemFlags { /// Set if the client wants diagnostics suppressed. SuppressDiagnostics = 0x02, - /// If set, the client wants a best-effort solution to the constraint system, - /// but can tolerate a solution where all of the constraints are solved, but - /// not all type variables have been determined. In this case, the constraint - /// system is not applied to the expression AST, but the ConstraintSystem is - /// left in-tact. - AllowUnresolvedTypeVariables = 0x04, - /// If set, verbose output is enabled for this constraint system. /// /// Note that this flag is automatically applied to all constraint systems, @@ -1952,12 +1945,12 @@ enum class ConstraintSystemFlags { /// \c DebugConstraintSolverAttempt. Finally, it can also be automatically /// enabled for a pre-configured set of expressions on line numbers by setting /// \c DebugConstraintSolverOnLines. - DebugConstraints = 0x08, + DebugConstraints = 0x04, /// If set, we are solving specifically to determine the type of a /// CodeCompletionExpr, and should continue in the presence of errors wherever /// possible. - ForCodeCompletion = 0x10, + ForCodeCompletion = 0x08, /// Include Clang function types when checking equality for function types. /// @@ -1968,16 +1961,16 @@ enum class ConstraintSystemFlags { /// should be treated as semantically different, as they may have different /// calling conventions, say due to Clang attributes such as /// `__attribute__((ns_consumed))`. - UseClangFunctionTypes = 0x20, + UseClangFunctionTypes = 0x10, /// When set, ignore async/sync mismatches - IgnoreAsyncSyncMismatch = 0x40, + IgnoreAsyncSyncMismatch = 0x20, /// Disable macro expansions. - DisableMacroExpansions = 0x80, + DisableMacroExpansions = 0x40, /// Enable old type-checker performance hacks. - EnablePerformanceHacks = 0x100, + EnablePerformanceHacks = 0x80, }; /// Options that affect the constraint system as a whole. diff --git a/lib/Sema/CSSolver.cpp b/lib/Sema/CSSolver.cpp index 9f8e339586b2e..26c011cb256e7 100644 --- a/lib/Sema/CSSolver.cpp +++ b/lib/Sema/CSSolver.cpp @@ -1488,16 +1488,6 @@ ConstraintSystem::solve(SyntacticElementTarget &target, return std::nullopt; } - if (Options.contains( - ConstraintSystemFlags::AllowUnresolvedTypeVariables)) { - dumpSolutions(solution); - auto ambiguousSolutions = std::move(solution).takeAmbiguousSolutions(); - std::vector result( - std::make_move_iterator(ambiguousSolutions.begin()), - std::make_move_iterator(ambiguousSolutions.end())); - return std::move(result); - } - LLVM_FALLTHROUGH; case SolutionResult::UndiagnosedError: diff --git a/unittests/Sema/BindingInferenceTests.cpp b/unittests/Sema/BindingInferenceTests.cpp index 34f29ad2730d7..fdd6c6682a489 100644 --- a/unittests/Sema/BindingInferenceTests.cpp +++ b/unittests/Sema/BindingInferenceTests.cpp @@ -22,10 +22,7 @@ using namespace swift::constraints; using namespace swift::constraints::inference; TEST_F(SemaTest, TestIntLiteralBindingInference) { - ConstraintSystemOptions options; - options |= ConstraintSystemFlags::AllowUnresolvedTypeVariables; - - ConstraintSystem cs(DC, options); + ConstraintSystem cs(DC, std::nullopt); auto *intLiteral = IntegerLiteralExpr::createFromUnsigned(Context, 42, SourceLoc());