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
Slava Pestov
2fde4a50e7
Sema: Split off getTypeOfMemberReferenceImpl() from getTypeOfMemberReference()
2025-09-18 11:06:32 -04:00
Slava Pestov
35a439de24
Sema: Remove replacements parameter from getMemberReferenceTypeFromOpenedType()
2025-09-18 11:06:31 -04:00
Slava Pestov
1efc9a6d0d
Sema: Split off getTypeOfReferenceImpl() from getTypeOfReference()
2025-09-18 11:06:31 -04:00
Hamish Knight
782a5b4332
[CS] Ensure we trap in getOverloadChoice if the overload is missing
...
Using `*` previously meant we'd invoke undefined behavior.
2025-09-17 16:11:53 +01:00
Slava Pestov
60246a2889
Sema: Further split up getTypeOfMemberTypeReference()
2025-09-09 18:58:10 -04:00
Slava Pestov
6dc2e7558d
Sema: Don't modify openedType in getMemberReferenceTypeFromOpenedType()
2025-09-09 18:58:09 -04:00
Hamish Knight
23560df5f4
[CS] Remove AllowUnresolvedTypeVariables
...
This has been unused for a while now.
2025-09-07 12:17:18 +01:00
Hamish Knight
0142d0b92e
[CS] Add debug message when hitting too complex limit
...
Add a message to the constraints debugging log when hitting one of the
complexity limits.
2025-09-01 13:33:47 +01:00
Hamish Knight
5b8dfc70ab
[CS] Emit fallback diagnostic if needed for IgnoreInvalidASTNode
...
If no other error has been emitted, make sure we emit a fallback
diagnostic rather than crashing in the ASTVerifier or SILGen.
2025-08-28 15:31:48 +01:00
Hamish Knight
9c898206e8
Merge pull request #83870 from hamishknight/overrun
...
[CS] Open generic requirements for types with unbound + placeholder types
2025-08-27 23:20:33 +01:00
Hamish Knight
2e0be5afd7
[CS] Open generic requirements for types with unbound + placeholder types
...
- Introduce a generic requirements opening function for type resolution,
which is used by the constraint system in cases where we need to
impose requirements on opened type variables.
- Refactor `replaceInferableTypesWithTypeVars` to use this function
when opening generic types that contain either placeholder or unbound
generic types.
Together these changes ensure that we don't drop generic requirements
when an unbound generic or placeholder type is used as a generic
argument.
2025-08-26 12:16:54 +01:00
Slava Pestov
1972c4845f
Sema: Cache result of getUnsatisfiedAvailabilityConstraint()
...
This query is expensive and we call it a lot.
2025-08-25 17:14:35 -04:00
Slava Pestov
a399c46db7
Sema: Pull preconcurrency adjustment out of getUnopenedTypeOfReference()
2025-08-15 14:39:14 -04:00
Anthony Latsis
fec049e5e4
Address llvm::PointerUnion::{is,get} deprecations
...
These were deprecated in
https://github.com/llvm/llvm-project/pull/122623 .
2025-07-29 18:37:48 +01:00
Hamish Knight
33b58d25d8
[CS] NFC: Factor out Solution::hasAppliedSelf
2025-07-18 10:54:17 +01:00
Hamish Knight
3244bffe71
[CS] Handle TVO_CanBindToPack in mergeEquivalenceClasses
...
Previously we could incorrectly propagate `TVO_CanBindToPack` to a
type variable that cannot bound to a pack type.
2025-07-14 12:44:23 +01:00
Slava Pestov
9a8f3baa06
Sema: Add room for a PreparedOverload to BindOverload constraint
2025-07-10 19:53:19 -04:00
Slava Pestov
83f95aeaed
Sema: Allocate PreparedOverload in solver arena
2025-07-10 19:53:19 -04:00
Slava Pestov
7916ed982f
Sema: Move DeclReferenceType to PreparedOverload.h
2025-07-10 19:53:19 -04:00
Slava Pestov
f7a552385c
Sema: PreparedOverload => PreparedOverloadBuilder
2025-07-10 19:53:18 -04:00
Slava Pestov
8527e88423
Sema: Extract prepareOverload() from resolveOverload()
2025-07-10 19:53:15 -04:00
Slava Pestov
751edee921
Sema: Rework PreparedOverload to store a list of changes
2025-07-09 15:00:10 -04:00
Slava Pestov
2a0b11a22e
Sema: Collect property wrappers in PreparedOverload
2025-07-09 15:00:03 -04:00
Slava Pestov
be6cf92982
Sema: Plumb PreparedOverload through to replaceInferableTypesWithTypeVars()
2025-07-09 15:00:03 -04:00
Slava Pestov
ab72407108
Sema: Collect opened pack expansion types in PreparedOverload
2025-07-09 15:00:02 -04:00
Slava Pestov
c5741e31ed
Sema: Stash the existential archetype in PreparedOverload
2025-07-09 15:00:02 -04:00
Slava Pestov
426c7a3fdf
Sema: Collect constraints in PreparedOverload
2025-07-09 15:00:02 -04:00
Slava Pestov
543793564e
Sema: Record opened type variables in PreparedOverload
2025-07-09 15:00:02 -04:00
Slava Pestov
b9256307b5
Sema: Stub out PreparedOverload
2025-07-09 15:00:02 -04:00
Pavel Yaskevich
3efb948ad8
[ConstraintSystem] Add a option to re-enable performance hacks
...
Instead of checking `EnableConstraintSolverPerformanceHacks`
directly, let's use an option which is easier to set i.e.
when a block list is implemented.
2025-06-27 23:43:12 -07:00
Pavel Yaskevich
9e97b8e3a1
[CSOptimizer] Skip disfavored choices when they would result in a worse solution
2025-06-27 23:43:11 -07:00
Pavel Yaskevich
617338f250
[CSOptimizer] Prevent candidate inference from unresolved generic parameters and ternary expressions
...
We need to have a notion of "complete" binding set before
we can allow inference from generic parameters and ternary,
otherwise we'd make a favoring decision that might not be
correct i.e. `v ?? (<<cond>> ? nil : o)` where `o` is `Int`.
`getBindingsFor` doesn't currently infer transitive bindings
which means that for a ternary we'd only have a single
binding - `Int` which could lead to favoring overload of
`??` and has non-optional parameter on the right-hand side.
2025-06-27 23:43:11 -07:00
Pavel Yaskevich
0a5bd787d0
[ConstraintSystem] Narrowly disable tryOptimizeGenericDisjunction when some of the arguments are number literals
...
Don't attempt this optimization if call has number literals.
This is intended to narrowly fix situations like:
```swift
func test<T: FloatingPoint>(_: T) { ... }
func test<T: Numeric>(_: T) { ... }
test(42)
```
The call should use `<T: Numeric>` overload even though the
`<T: FloatingPoint>` is a more specialized version because
selecting `<T: Numeric>` doesn't introduce non-default literal
types.
(cherry picked from commit 8d5cb112ef )
2025-06-27 23:43:09 -07:00
Pavel Yaskevich
2957da3591
[ConstraintSystem] Disable performance hacks by default
...
This also changes the flag to `-enable-constraint-solver-performance-hacks`.
2025-06-27 23:43:09 -07:00
Pavel Yaskevich
c04068db1c
[ConstraintSystem] Initial implementation of disjunction optimizer
...
This brings back CSOptimizer from https://github.com/swiftlang/swift/pull/63585
2025-06-27 23:43:09 -07:00
Pavel Yaskevich
1b2ba7e059
[CSStep] Modify selectDisjunction to return favored choices directly
...
This is currently unused because current mechanism set favored choices
directly but it would be utilized by the disjunction optimizer.
(cherry picked from commit e404ed722a )
2025-06-27 23:43:09 -07:00
Slava Pestov
487918f07b
Sema: Fix -warn-long-expression-type-checking when expression timer is turned off
...
My change 983b75e1cf broke
-warn-long-expression-type-checking because now the
ExpressionTimer is not instantiated by default and that
entire code path is skipped.
Change it so that if -warn-long-expression-type-checking
is passed in, we still start the timer, we just don't
ever consider it to have 'expired'.
Fixes rdar://problem/152998878.
2025-06-25 22:07:23 -04:00
Pavel Yaskevich
286f975c29
Merge pull request #82320 from xedin/hide-solver-hacks-behind-a-flag
...
[ConstraintSystem] Guard all the performance hacks with a flag
2025-06-20 00:12:16 -07:00
Pavel Yaskevich
fc573b6612
[ConstraintSystem] Guard all the performance hacks with a flag
...
Package the flag into `performanceHacksEnabled()` method on
`ConstraintSystem` and start using it to wrap all of the hacks
in constraint generator and the solver.
2025-06-17 13:53:05 -07:00
Hamish Knight
71d20b7635
[CS] NFC: Remove FreeTypeVariableBinding::UnresolvedType
...
This is now unused.
2025-06-12 12:11:19 +01:00