Commit Graph

1656 Commits

Author SHA1 Message Date
Allan Shortlidge
c8d77c64fa Merge pull request #79326 from tshortli/availability-constraint-reason
AST: Split `AvailabilityConstraint` classifications into separate `Reason` and `Kind` enums
2025-02-12 13:56:48 -08:00
Allan Shortlidge
a6b20b3fe5 AST: Re-introduce AvailabilityConstraint::Kind.
Now the Kind enum classifies availability constraints based on their
satisfiablility.

NFC.
2025-02-12 07:20:14 -08:00
Alejandro Alonso
e4fb1f6761 Rename Slab to InlineArray 2025-02-11 10:26:44 -08:00
Michael Gottesman
7e350bb4ce Revert "[concurrency] Add Concurrent/ConcurrentUnsafe and use it instead of ActorIsolation::Nonisolated."
This reverts commit 0cb64638d0.
2025-02-06 14:05:06 -08:00
Michael Gottesman
f05f08c2c0 Revert "[concurrency] Make ActorIsolation::Nonisolated -> CallerIsolationInheriting and delete CallerIsolationInheriting."
This reverts commit 543b1e6ca3.
2025-02-06 14:04:30 -08:00
Michael Gottesman
543b1e6ca3 [concurrency] Make ActorIsolation::Nonisolated -> CallerIsolationInheriting and delete CallerIsolationInheriting. 2025-02-03 10:56:08 -08:00
Michael Gottesman
0cb64638d0 [concurrency] Add Concurrent/ConcurrentUnsafe and use it instead of ActorIsolation::Nonisolated.
This is just the first part of a larger transition.
2025-02-03 10:56:06 -08:00
Slava Pestov
5b4218c38d Revert "Sema: Remove ConstraintKind::OneWayEqual"
This reverts commit 385d66f24e.
2025-02-02 00:43:15 -05:00
Slava Pestov
99595e615e Revert "Sema: Split up gatherConstraints() into gatherAllConstraints() and gatherNearbyConstraints()"
This reverts commit 2230c3a17e.
2025-02-02 00:43:15 -05:00
Anthony Latsis
a84dfc8387 [Gardening] Fix some set but not used variables 2025-01-30 21:34:38 +00:00
Slava Pestov
2230c3a17e Sema: Split up gatherConstraints() into gatherAllConstraints() and gatherNearbyConstraints()
The two GatherKinds no longer share any implementation, so there's
no point keeping the logic together. Doing this also allows removing
the acceptConstraintFn from gatherAllConstraints(), which further
simplifies depthFirstSearch().
2025-01-27 10:27:00 -05:00
Alejandro Alonso
f76d841540 Rename to Slab 2025-01-09 10:39:45 -08:00
Alejandro Alonso
61702fb813 Implement Vector literals 2025-01-08 10:35:55 -08:00
Pavel Yaskevich
8f7e71aa97 Merge pull request #78487 from xedin/Sendable-to-Any-for-lvalues
[CSApply] Sendable-to-Any: Add support for l-value to l-value and inout unsafe casts
2025-01-08 09:57:02 -08:00
Pavel Yaskevich
79f6b07961 [CSApply] Mark self parameter as inout when base/self match on deep equality
If type equality check fails we need to check whether the types
are the same with deep equality restriction since `any Sendable`
to `Any` conversion is now supported in generic argument positions
of @preconcurrency declarations. i.e. referencing a member on
`[any Sendable]` if member declared in an extension that expects
`Element` to be equal to `Any`.
2025-01-07 10:55:04 -08:00
Slava Pestov
2d17294d73 Merge pull request #78301 from slavapestov/remove-one-way-constraints
Sema: Remove ConstraintKind::OneWayBindParam and ConstraintKind::OneWayEqual
2025-01-05 10:38:14 -05:00
Michael Gottesman
5d4239af57 [concurrency] Add new isolation kind CallerIsolationInheriting.
Right now it is basically a version of nonisolated beyond a few simple cases
like constructors/destructors where we are pretty sure we want to not support
this.

This is part of my bringup strategy for changing nonisolated/unspecified to be
caller isolation inheriting.
2025-01-02 13:18:30 -08:00
Hamish Knight
4cbe481f82 Merge pull request #78377 from hamishknight/no-simplify-result
[CS] Don't simplify `FunctionResult` in `simplifyLocator`
2025-01-02 17:26:22 +00:00
Anthony Latsis
5c24df22a0 Merge pull request #78363 from AnthonyLatsis/dicksonia-arborescens
[NFC] Sema: Tidy up `canOpenExistentialCallArgument`
2025-01-02 15:38:27 +00:00
Hamish Knight
9fb064ad2c [CS] Remove resolveInterfaceType
Use `simplifyType` instead with the new parameter
for getting an interface type. Also avoid using
`resolveInterfaceType` in CSApply since we don't
need the opened generic parameter mapping behavior.
2024-12-31 18:39:20 +00:00
Hamish Knight
9fe4abc6fd [CS] Simplify Solution::resolveInterfaceType
Rather than attempting to re-implement `simplifyType`,
tweak `Solution::simplifyType` such that it can
map the resulting type out of context, and can
turn type variables into their opened generic
parameters.
2024-12-31 18:39:19 +00:00
Hamish Knight
86e8165569 [CS] Don't simplify FunctionResult in simplifyLocator
Simplifying into the function expression is wrong,
like `FunctionArgument` this isn't an element that
can be simplified. This also means we don't need
to handle it in `MissingCallFailure`, since we
shouldn't be recording that fix in this case.
2024-12-29 12:25:18 +00:00
Anthony Latsis
fc1ad79ddd [NFC] ConstraintSystem: Rename openExistentialType to openAnyExistentialType
This method can open an existential metatype too, and we already use
`isAnyExistentialType` to mean "existential type or existential
metatype"
2024-12-24 17:42:54 +00:00
Slava Pestov
385d66f24e Sema: Remove ConstraintKind::OneWayEqual 2024-12-21 00:42:13 -08:00
Slava Pestov
45346c8389 Sema: Remove ConstraintGraph::TypeVariables 2024-12-18 17:30:34 -05:00
Slava Pestov
c4e466dae7 Sema: Remove needless indirection 2024-12-18 17:30:22 -05:00
Hamish Knight
3c662c6276 [CS] Support IUOs for compound function references
This was previously an artificial limitation of the
FunctionRefKind representation, there's no reason
we shouldn't support IUOs for functions referenced
using a compound name.
2024-12-04 11:11:32 +00:00
Hamish Knight
73fb36f371 [AST] Split out "is compound" bit on FunctionRefInfo
FunctionRefKind was originally designed to represent
the handling needed for argument labels on function
references, in which the unapplied and compound cases
are effectively the same. However it has since been
adopted in a bunch of other places where the
spelling of the function reference is entirely
orthogonal to the application level.

Split out the application level from the
"is compound" bit. Should be NFC. I've left some
FIXMEs for non-NFC changes that I'll address in a
follow-up.
2024-12-02 14:11:33 +00:00
Hamish Knight
a4d51419ba [AST] NFC: Rename FunctionRefKind -> FunctionRefInfo 2024-12-02 14:11:32 +00:00
Slava Pestov
25252cd683 Merge pull request #77728 from slavapestov/cg-cleanup
Sema: Small ConstraintGraph cleanup
2024-11-20 19:43:42 -05:00
Slava Pestov
7fef225c9f Sema: Allow turning off expression timer with -solver-expression-time-threshold=0 2024-11-20 13:46:19 -05:00
Slava Pestov
c8415aeac4 Sema: Record the trail step count in solver statistics
Also introduce two new frontend flags:

The -solver-scope-threshold flag sets the maximum number of scopes, which was
previously hardcoded to 1 million.

The -solver-trail-threshold flag sets the maximum number of trail steps,
which defaults to 64 million.
2024-11-20 13:46:19 -05:00
Slava Pestov
24de22a078 Sema: Split off ConstraintGraph::addTypeVariable() from ::operator[]
Also, since we add a vertex immediately after introducing a new type
variable, the code path to handle the case where the type variable
had a parent or fixed type was actually dead.
2024-11-20 13:35:21 -05:00
Slava Pestov
c5de105a2b Sema: Workaround for invalid logic in Solution::simplifyTypeForCodeCompletion() 2024-11-20 13:35:21 -05:00
Slava Pestov
de731b4d5d Sema: Preserve insertion order in Solution::typeBindings 2024-11-20 11:47:07 -05:00
Slava Pestov
b760cfd03d Sema: Fold ConstraintGraph::lookupNode() into ::operator[]
lookupNode() returned a pair but both callers only looked at the
first element of the pair.
2024-11-20 08:23:58 -05:00
Slava Pestov
a7b1e7854c Merge pull request #77174 from slavapestov/fix-undo-order
Sema: Undo changes in chronological order in SolverTrail::undo()
2024-11-20 08:00:53 -05:00
Slava Pestov
1a60685292 Sema: Address the FIXME in ConstraintGraph::mergeNodes() 2024-11-19 21:24:12 -05:00
Slava Pestov
5690addb4e Sema: Fix ordering of constraint graph updates vs fixed type assignment 2024-11-19 21:24:12 -05:00
Slava Pestov
1ecba36e76 Sema: Cache Solution::getTotalMemory()
This is showing up in performance profiles.
2024-11-19 16:04:57 -05:00
nate-chandler
aab880da05 Merge pull request #77429 from nate-chandler/general-coro/20241104/1
[CoroutineAccessors] Synthesize default requirement implementations.
2024-11-10 07:43:11 -08:00
Nate Chandler
da71271d8f [CoroutineAccessors] Synthesize default req impls.
When a protocol which has a read (or modify) requirement is built with
the CoroutineAccessors feature, it gains a read2 (or modify2,
respectively) requirement.  For this to be compatible with binaries
built without the feature, a default implementation for these new
requirements must be provided.  Cause these new accessor requirements to
have default implementations by returning `true` from
`doesAccessorHaveBody` when the context is a `ProtocolDecl` and the
relevant availability check passes.
2024-11-07 16:47:09 -08:00
Doug Gregor
720429daf4 [Constraint solver] Disable fallback diagnostic when error emitted into a transaction
When we are using diagnostic transactions to disable immediate emission
of diagnostics, `DiagnosticEngine::hadAnyError()` no longer accurately
reports whether an error occurred. Thread the DiagnosticTransaction
into the ConstraintSystem so we can also check whether it contains an
error before emitting the fallback diagnostic.

Fixes rdar://128272346.
2024-11-06 17:07:13 -08:00
Allan Shortlidge
161dc2e09e Sema: Rename getUnmetDeclAvailabilityRequirement().
Name it `getUnsatisfiedAvailabilityConstraint()` to match
`AvailabilityConstraint`.
2024-11-04 19:58:28 -08:00
Hamish Knight
7061a20edd [CS] Remove ConstraintSystem::getVarType
The logic here for completion wasn't actually
helping things since it would result in adding the
var overload to the system, which would result
in an ErrorType binding. We could turn the ErrorType
into a placeholder when resolving the overload,
but the simpler solution is to just allow CSGen
to turn the reference into a PlaceholderType. This
matches what we do for regular solving, and fixes
a crash with an IUO completion.

rdar://89369091
2024-11-04 17:08:20 +00:00
Allan Shortlidge
7b5757b29b Sema: Replace TypeChecker::checkDeclarationAvailability().
Adopt `getUnmetDeclAvailabilityRequirement()` instead.
2024-11-03 11:37:01 -08:00
Allan Shortlidge
0377ef4afd Sema: Take a SourceLoc in getUnmetDeclAvailabilityRequirement().
Introduce a convenience overload for the common case where the
AvailabilityContext must first be looked up by source location.
2024-11-03 11:37:01 -08:00
Allan Shortlidge
a95891cbb8 Sema: Rename checkDeclarationAvailability().
Type checker functions with the prefix "check" usually check some requirement
and then diagnose it if it isn't satisfied. `checkDeclarationAvailability()`
doesn't diagnose on its own, so it should be named differently.
2024-11-03 11:37:01 -08:00
Allan Shortlidge
98b34c6ff6 Sema: Correctly treat overloads in unavailable extensions as unavailable.
Instead of checking for unavailability attributes directly in the solver, which
does not correctly handle members of unavailable extensions, query
`checkDeclarationAvailability()` instead. By using the same underlying logic as
the availability checker the constraint solver can be confident in the accuracy
of this result.

Resolves rdar://87403752.
2024-11-02 17:15:11 -07:00
Pavel Yaskevich
6109463cce [ConstraintSystem] NFC: Rename threshold in ExpressionTimer to clarify granularity
The variable was named incorrectly, it's actually expressed in seconds.
2024-10-28 17:29:01 -07:00