Commit Graph

764 Commits

Author SHA1 Message Date
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
Slava Pestov 819738c83e AST: Rename mapTypeIntoContext() => mapTypeIntoEnvironment(), mapTypeOutOfContext() => mapTypeOutOfEnvironment() 2025-11-12 14:48:19 -05:00
Hamish Knight 3b57a7cd91 [CS] Clean up some property wrapper logic
These methods can be simplified a bunch since the returned decl is
always the input decl and we can refactor the lambdas to just return
the auxiliary variable and have the type computation in the caller.
2025-11-04 00:56:01 +00:00
Becca Royal-Gordon 393965090e Merge pull request #34556 from beccadax/mod-squad-2
[SE-0491] Implement lookup and diagnostics for module selectors (MyMod::someName)
2025-10-28 16:00:26 -07:00
Hamish Knight 05e3d15955 [CS] Propagate CSApply failures in a few more places
We had some cases where we weren't propagating failures to apply the
solution, and as such weren't invalidating the resulting AST. Fix up
these cases.
2025-10-26 14:49:17 +00:00
Becca Royal-Gordon 60cc537f70 Improve module selector constraint solver diagnostics 2025-10-24 16:23:49 -07:00
Hamish Knight f15fae4737 Merge pull request #84822 from hamishknight/just-a-phase
[CS] Remove `ConstraintSystemPhase`
2025-10-24 16:05:08 +01:00
Hamish Knight bb877ce3c0 [CS] Remove ConstraintSystemPhase 2025-10-19 13:14:00 +01:00
Hamish Knight 77a59383f7 [CS] Penalize implicit pointer conversions to generic parameter types
We ought to consider outright banning these conversions if the
destination is a generic parameter type, but for now let's penalize
them such that we don't end up with ambiguities if you're doing an
implicit pointer conversion through an identity generic function.

rdar://161205293
2025-10-16 14:14:53 +01:00
Slava Pestov 8600cdcc2a Sema: Remove ConstraintSystemPhase::{Diagnostics,Finalization} 2025-10-10 16:06:42 -04:00
Slava Pestov a8d896ab8f Sema: Don't reuse PreparedOverload from normal type checking in salvage()
We want to re-prepare our overloads, since now they will contain fixes.
2025-10-10 15:44:12 -04:00
Hamish Knight 9e4208b69b [CS] Remove custom logic from simplifyTypeForCodeCompletion
We ought to be able to just use `simplifyType` with an additional
parameter to tell it to produce archetypes.
2025-10-04 12:56:52 +01:00
Allan Shortlidge 2467b931a7 ConstraintSystem: Move key path type utilities to AST. 2025-09-25 07:13:17 -07:00
Hamish Knight 3141b5a8cd [AST] NFC: Introduce PrintOptions::forDebugging 2025-09-21 23:19:06 +01:00
Slava Pestov 9dea72579a Sema: Record ASTNode type changes in PreparedOverload
Also, move some methods from ConstraintSystem.h to ConstraintSystem.cpp.
2025-09-18 14:54:16 -04:00
Slava Pestov b181fcf0fd Sema: Get prepared overloads working again with the Pre()/Post() split 2025-09-18 14:54:16 -04:00
Slava Pestov c344d6b0eb Sema: Rename getTypeOf{Member,}ReferenceImpl() to Pre() and factor out Post() versions 2025-09-18 11:31:59 -04:00
Slava Pestov 182c38470b Sema: Remove replacementsPtr parameter from getTypeOfMemberReference() 2025-09-18 11:31:59 -04:00
Slava Pestov a028eb36b7 Sema: Don't need to return new baseObjTy from getTypeOfMemberReferenceImpl() 2025-09-18 11:31:59 -04:00
Slava Pestov d8ead6c5cc Sema: Refactor getTypeOf{Member,}Reference() to take the OverloadChoice 2025-09-18 11:31:59 -04:00