Commit Graph

783 Commits

Author SHA1 Message Date
Pavel Yaskevich 4201e579be Merge pull request #88162 from CognitiveDisson/feat/scope-based-expression-type-checking-warnings
[Sema] Add scope-based analogues of -warn-long-expression-type-checking
2026-05-04 06:35:35 -07:00
CognitiveDisson 1d8432121f Rename ExpressionTimer to ComplexityTracker and pass thresholds in ctor 2026-04-30 13:43:49 +01:00
CognitiveDisson 575e69f90e [Sema] Add scope-based analogues of -warn-long-expression-type-checking 2026-04-23 10:46:03 +01:00
Pavel Yaskevich 974346026f [ConstraintSystem] NFC: Extract logic to detect whether function is generic only over thrown type 2026-03-31 13:34:54 -07:00
Aidan Hall c4d32f901d Merge pull request #87281 from aidan-hall/lifedep-protocol-check
Require compatible lifetimes in protocol conformance checking and function type matching
2026-03-24 14:16:56 +00:00
Aidan Hall 0659f07ab9 LifetimeDependence: Lifetime subtyping for type and witness matching
- rdar://169975618 ([nonescapable] Type conversion for function types with lifetime dependencies)
- rdar://160970376 ([nonescapable] [type checker] [source compat] protocol requirements should require matching methods signatures, including @lifetime)
2026-03-23 12:53:09 +00:00
Hamish Knight 54c0870a25 [CS] Better handle rewriting implicit callAsFunction call splitting
The previous logic was relying on doing `coerceCallArguments` with the
full argument list instead of only the non-trailing args, and wasn't
handling the non-shorthand-init case. Update the logic to fix-up the
apply during the pre-walk, ensuring it gets applied consistently.

rdar://170076966
2026-03-21 13:45:27 +00:00
Slava Pestov 601e253fd8 Sema: Inline findResolvedMemberRef() into its only caller 2026-03-10 14:47:30 -04:00
Slava Pestov 2763ec3a2c Sema: Remove unused allowMembers parameter from getEffectiveOverloadType() 2026-03-10 10:12:57 -04:00
Pavel Yaskevich dcaf02215d Merge pull request #87575 from xedin/real-rdar-170475422
[Concurrency] InferSendableFromCaptures: Capturing non-`SendableMetatype` archetypes affects sendability of a reference
2026-03-03 06:13:58 -08:00
Slava Pestov 8e271c3c5a Sema: Move getApplicableFnConstraint() from CSOptimizer.cpp to CSDisjunction.cpp 2026-02-28 14:54:07 -05:00
Slava Pestov 7a717654c7 Sema: Inline collectDisjunctions() into its only caller 2026-02-28 14:54:07 -05:00
Slava Pestov 6466a84a8d Sema: Split off Solution.h from ConstraintSystem.h 2026-02-28 14:54:07 -05:00
Pavel Yaskevich ba9ae14775 [Concurrency] InferSendableFromCaptures: Capturing non-SendableMetatype archetypes affects sendability of a reference
If a partial application captures any non-`SendableMetatype` type parameter,
then it can call methods that are isolated to the current context and so the
function value cannot be `@Sendable`.

Resolves: rdar://170475422
2026-02-27 13:13:26 -08:00
Slava Pestov ccc59af184 Sema: Factor out getImpliedResultConversionKind() from matchTypes() 2026-02-24 21:34:38 -05:00
Slava Pestov 26c274a48d Sema: Remove unused variable 2026-02-20 19:30:35 -05:00
Slava Pestov 4f70388ee1 Sema: Incremental disjunction pruning 2026-02-20 19:30:35 -05:00
Slava Pestov aa512046b5 Sema: Add ConstraintSystem::isProtocolTransitiveFor{Super,Sub}type() 2026-02-15 14:00:52 -05:00
Slava Pestov 54789c12c7 Sema: Split off Subtyping.cpp from CSBindings.cpp 2026-02-15 14:00:51 -05:00
Hamish Knight 681c4d22c6 Merge pull request #87031 from hamishknight/revert-hack
Revert "[CS] Add `for` loop compatibility hack for `makeIterator`/`next` ranking"
2026-02-06 22:54:16 +00:00
Hamish Knight 0036130988 Revert "[CS] Add for loop compatibility hack for makeIterator/next ranking"
This reverts commit 7b729933f6.
2026-02-06 12:47:25 +00:00
Kavon Farvardin ae77ba81e3 Merge pull request #87013 from kavon/revert-84789
Back out #84789 after additional testing
2026-02-06 02:58:00 -08:00
Kavon Farvardin d5f9a1eeeb Revert "Merge pull request #84789 from nickolas-pohilets/mpokhylets/fix-82618"
This reverts commit b633bd37ac, reversing
changes made to b27bb64b03.
2026-02-05 11:34:59 -08:00
Slava Pestov 9036602aa1 Sema: Split off BindingProducer.h/.cpp 2026-02-05 09:19:01 -05:00
Slava Pestov 78e9329184 Sema: Move OpenUnboundGenericType to CSGen.cpp 2026-02-05 09:19:01 -05:00
Slava Pestov b1e1cba094 Sema: Remove unused OverloadSetCounter 2026-02-05 09:19:01 -05:00
Slava Pestov cfb6e2db30 Sema: Move InputMatcher from ConstraintSystem.h to CSRanking.cpp 2026-02-05 09:19:01 -05:00
Slava Pestov 7cd06a5088 Sema: Split off TypeVariableType.h/.cpp 2026-02-05 09:19:01 -05:00
Hamish Knight 6453800b93 Merge pull request #85730 from hamishknight/wayfarer
[CS] Introduce Sendable-dependent functions
2026-01-29 19:42:37 +00:00
Hamish Knight 7b729933f6 [CS] Add for loop compatibility hack for makeIterator/next ranking
Still record overload choices for `makeIterator` and `next` when
solving a `ForEachElement` constraint. This maintains compatibility
with the previous behavior where we would solve these in the constraint
system, since the choices can affect ranking if e.g Collection's
default `makeIterator` is compared with a concrete `makeIterator`
overload. This is a complete hack though and we ought to rip this out
as soon as we can.

rdar://168840696
2026-01-27 23:30:43 +00:00
Hamish Knight a615b4cf02 [CS] Use Sendable dependence in adjustFunctionTypeForConcurrency
If the base captured type still has type variables when we bind the
member function type, form a Sendable dependent function type with
the base type. This will then be eliminated by TypeSimplifier once
all the type variables in the base type have been resolved.

This then allows us to remove the delaying logic from member lookup.
2026-01-27 11:06:54 +00:00
Slava Pestov 3f659d3085 Merge pull request #86687 from slavapestov/disjunction-selection-experiments-2
Sema: Disjunction pruning optimization
2026-01-27 10:51:59 +00:00
Slava Pestov 95a54ce82a Sema: Yet another constraint optimization pass
- Fixes https://github.com/swiftlang/swift/issues/55762
- Fixes rdar://32034560
2026-01-26 21:48:59 +00:00
Slava Pestov dfbce49ff7 Sema: Better -debug-constraints output in determineBestBindings() 2026-01-26 21:48:58 +00:00
Slava Pestov ee0f6dd681 Sema: Narrow down the skipProtocolSelfConstraint hack
We actually have to check this constraint, otherwise we accept invalid
code where we're referencing a protocol requirement with a concrete
base type which conditionally conforms to the protocol, but the
conditional requirements are unsatisfied.

However, we still need to skip it for AnyObject lookup, Distributed
Actors, and some weird edge case in conformance checking for isolated
conformances.

We should clean this up further later, but for now this closes a soundness
hole.

Fixes rdar://168129757.
2026-01-25 21:11:59 +00:00
Slava Pestov d860523944 Merge pull request #86760 from slavapestov/solver-shuffle
Sema: Add -solver-shuffle-disjunctions= and -solver-shuffle-choices= flags for debugging
2026-01-24 12:30:43 -05:00
elsa 5e9f215f31 Merge pull request #86010 from elsakeirouz/rework-for-each-desugar
Rework ForEachStmt Desugaring
2026-01-24 13:55:51 +00:00
Slava Pestov f3cfd65f3b Sema: Remove some dead code related to favoring 2026-01-23 20:02:21 -05:00
Hamish Knight d3270fdf1e [CS] Remove ValueWitness constraint
The specialized type-checking for `for` loops was the only client of
this, it's now unused.
2026-01-23 15:17:30 +00:00
Elsa Keirouz 075fa2a8f1 [CS] introduce ForEachElement constraint 2026-01-23 15:17:28 +00:00
Elsa Keirouz 27cef65d56 [AST] Introduce opaque AST nodes 2026-01-23 15:17:28 +00:00
Pavel Yaskevich 411d396eb8 Merge pull request #86695 from xedin/remove-old-perf-hacks
[ConstraintSystem] Remove old performance hacks from the solver and related flags
2026-01-22 09:01:50 -08:00
Pavel Yaskevich a33ec97216 [ConstraintSystem] Remove old performance hacks from the solver
The hacks have been disabled for a while now, so it's time to
completely remove them in favor of CSOptimizer.
2026-01-21 11:53:19 -08:00
Mykola Pokhylets 551a2cec6c Using ClosureExpr instead of ConversionPair in CollectionUpcastConversionExpr 2026-01-20 14:49:56 +01:00
Slava Pestov 9157d984e9 Sema: Convert solver arena usage into an always-on statistic 2025-12-19 17:26:19 -05:00
Slava Pestov d795c185b5 Sema: Remove BindingSet::getConstraintSystem()
We shouldn't store a pointer to the ConstraintSystem inside every
BindingSet, but there are some annoying things to untangle before
we can do that.

As a starting point toward that, remove the getConstraintSystem()
getter so that at least we can't reach up to the ConstraintSystem
from the outside.
2025-12-13 21:16:44 -05:00
Slava Pestov 205d8e6640 Sema: Remove unnecessary operator new overload 2025-12-10 18:48:47 -05:00
Slava Pestov ba7df4013e Sema: Avoid copying BindingSets
They're stored inside the ConstraintGraphNode now, so returning a
`const BindingSet *` from within determineBestBindings() should
be safe.
2025-12-10 18:48:00 -05:00
Slava Pestov d8cf185a13 Sema: Fix source location bookkeeping for 'reasonable time' diagnostic
We already had bookkeeping to track which statement in a multi-statement
closure we were looking at, but this was only used for the 'reasonable time'
diagnostic in the case that we hit the expression timer, which was almost
never hit, and is now off by default. The scope, memory, and trial limits
couldn't use this information, so they would always diagnose the entire
target being type checked.

Move it up from ExpressionTimer to ConstraintSystem, so that we get the
right source location there too. Also, factor out some code duplication
in BuilderTransform to ensure we get the same benefit for result builders
applied to function bodies too.
2025-12-06 20:31:08 -05:00
Hamish Knight 6dfff1ce9c [CS] Remove getImplicitValueConversionLocator & ImplicitConversion
These are now unused.
2025-11-15 19:26:46 +00:00