Commit Graph

28352 Commits

Author SHA1 Message Date
Pavel Yaskevich
e0f9e65976 [CSSimplify] NFC: assignFixedType no longer accepts a locator
`assignFixedType` now accepts `bool` as a third parameter but
not all call sites were updated to reflect that, some of them
are still passing `ConstraintLocator *` which implicitly gets
converted to a `bool`.
2025-03-18 00:16:22 -07:00
Anthony Latsis
c49947579a Sema: Implement adoption mode for AsyncCallerExecution 2025-03-18 01:58:31 +00:00
Slava Pestov
145a7c5fe2 Merge pull request #80057 from slavapestov/fix-rdar146780049
Sema: Fix non-determinism with ConstraintSystem::ConstraintRestrictions
2025-03-17 21:28:01 -04:00
Pavel Yaskevich
a8baec6c41 [CSSimplify] Open key path type before assignment to its record requirements
`Root` and `Value` generic parameters now have conformance requirements
which we need to account for post-binding inference.
2025-03-17 17:03:09 -07:00
Allan Shortlidge
dd68e98002 Merge pull request #80051 from tshortli/refactor-semantic-decl-availability-request
AST: Introduce `DeclRuntimeAvailability`
2025-03-17 14:35:48 -07:00
Pavel Yaskevich
6c22036931 [CSSimplify] NFC: Perform assignments to a key path in a separate method
Previously key path type didn't have any requirements on their
root and value types but now that they do, we need a dedicated
place to perform an assignment and open/record all of the requirements.
2025-03-17 14:06:45 -07:00
Anthony Latsis
2c7fb6a463 [NFC] Sema: Move determineClosureIsolation definition to the top level
Also combine the computed isolation and preconcurrency once at the end
rather than at every return.
2025-03-17 19:46:25 +00:00
Anthony Latsis
de36c3ff2c [NFC] Sema: Remove some redundant getASTContext calls in the isolation checker 2025-03-17 19:46:25 +00:00
Slava Pestov
34e7e824e9 Sema: Fix non-determinism with ConstraintSystem::ConstraintRestrictions
We iterate over the DenseMap and simplify both types appearing
in the key. If multiple keys simplify to the same type, later
keys overwrite earlier keys, so the outcome depends on hash
table order.

Fix this by introducing an arbitrary tie break: we prefer the
highest-numbered restriction.

Fixes rdar://146780049.
2025-03-17 14:35:10 -04:00
Pavel Yaskevich
b32a1caf53 Merge pull request #80032 from xedin/expand-scope-of-execution-attr
[AST/Sema] Allow `@execution(...)` attribute to be used on initializers and accessors
2025-03-17 09:01:41 -07:00
Allan Shortlidge
fc2b5bebdc AST: Remove Decl::isSemanticallyUnavailable().
It can be replaced by querying the `AvailabilityContext` for a declaration
directly.
2025-03-16 23:33:56 -07:00
Allan Shortlidge
1945c37af5 Sema: Retire some ExportContext availability conveniences.
Just use the `AvailabilityContext` directly.
2025-03-16 09:38:54 -07:00
Allan Shortlidge
44ab0074ad Sema: Retire TypeChecker::overApproximateAvailabilityAtLocation().
It has been superseded by `AvailabilityContext::forLocation()`.
2025-03-16 09:38:54 -07:00
Allan Shortlidge
2dd544a73c AST/Sema: Sink AvailabilityContext for location queries from Sema to AST. 2025-03-15 23:47:29 -07:00
Allan Shortlidge
151c9dee39 AST: Consolidate abstract/contrete syntax decl lookup functions. 2025-03-15 23:47:29 -07:00
Allan Shortlidge
02dcd5d8cf AST/Sema: Sink AvailabilityScopeBuilder from Sema to AST. 2025-03-15 23:47:29 -07:00
Allan Shortlidge
ff9b541c57 AST/Sema: Sink isExported() queries from Sema to AST. 2025-03-15 23:47:29 -07:00
Doug Gregor
bf387c56e2 Merge pull request #80030 from DougGregor/import-macro-in-cpp-class-and-namespace
[Clang importer] Report auxiliary decls from C++ class and namespace lookup
2025-03-14 19:23:00 -07:00
Pavel Yaskevich
eeabaaee6c [AST/Sema] Allow @execution(...) attribute to be used on initializers and accessors 2025-03-14 17:28:53 -07:00
Doug Gregor
84a4a8bedb [Importer] Ensure that we can see macro-expanded declarations in C++ namespaces
Lookup into C++ namespaces uses a different path from C++ record declarations.
Augment the C++ namespace lookup path to also account for the auxiliary
declarations introduced by peer macro expansions.
2025-03-14 14:10:44 -07:00
Pavel Yaskevich
26eaf7566d Merge pull request #80004 from xedin/se-0463-enablement
[Frontend] SE-0463: Enable `SendableCompletionHandlers` feature by default
2025-03-14 11:24:44 -07:00
Doug Gregor
4cc6411d05 Merge pull request #79983 from DougGregor/isolated-conformances-alignment
Align isolated conformances with the current proposal
2025-03-13 22:40:36 -07:00
Doug Gregor
01b2789dc8 Do not infer conformance isolation to an isolated protocol 2025-03-13 17:47:26 -07:00
Doug Gregor
c7fd48aa67 Rework storage for conformance isolation
Switch over to split caching for the conformance isolation request,
which optimizes for the common case where the conformance is
nonisolated. Also put the explicit global actor TypeExpr* in an
ASTContext side table, so we don't take a pointer's worth of storage
in every conformance.

For that side table, introduce a new "ASTContext::GlobalCache" that's
there only for side tables, so we don't have to go add get/set
operations to ASTContext and recompile the world every time we want to
add a side table like this.

Thanks, Slava!
2025-03-13 17:38:54 -07:00
Pavel Yaskevich
6966b7f8d7 [TypeChecker] Ignore mismatches on sendability in @objc @implementation witnesses unless in strict concurrency mode
The requirement is `@preconcurrency` in this case and the checking
should abide by the rules.
2025-03-13 15:34:17 -07:00
Pavel Yaskevich
00af0eeb0f Merge pull request #79975 from xedin/execution-attr-on-closures
[Concurrency] Extend `@execution(...)` attribute support to closures
2025-03-13 09:25:19 -07:00
Doug Gregor
836fcbe900 Don't infer isolated conformances when the feature isn't enabled 2025-03-13 08:16:36 -07:00
Doug Gregor
6eb79052f6 [Isolated conformances] Infer main actor isolation under UnspecifiedMeansMainActorIsolated
When code in the current module defaults to main actor (under SE-0466),
also infer main-actor isolation for protocol conformances of main-actor
isolated types.
2025-03-12 23:18:34 -07:00
Doug Gregor
c58e22fccc Simplify APIs for accessing conformance isolation
The NormalProtocolConformance APIs for checking for an explicitly-written
isolation on a conformance were easy to get to, and the real semantic
API was buried in the type checker, leading to some unprincipled
checking. Instead, create a central ProtocolConformance::getIsolation()
to get the (semantic) actor isolation, and let that be the only place
that will access the explicitly-written global actor isolation for a
conformance. Update all call sites appropriately.
2025-03-12 23:18:32 -07:00
Doug Gregor
0cfa048c0a [Isolated conformances] Start parsing 'nonisolated' on conformances
It doesn't mean anything yet, but parse it and make sure it reproduces
in the module interface.
2025-03-12 23:18:31 -07:00
Doug Gregor
3837661b84 [Isolated conformances] Allow conformance isolation to differ from the type's
With the move to explicitly specifying the global actor for an isolated
conformance, we can now have conformances whose isolation differs from
that of the type, including having actors with global-actor-isolated
conformances. Introduce this generalization to match the proposal, and
update/add tests accordingly.
2025-03-12 23:18:28 -07:00
Doug Gregor
4f2476116d Suggest global actor isolation rather than 'isolated' for conformances
Update diagnostic and Fix-It to suggest global actor isolation on a
conformance (e.g, `@MainActor P`) rather than `isolated`.
2025-03-12 23:18:23 -07:00
Doug Gregor
0e873e723c [Isolated conformances] Change syntax to @<global actor type> P
Instead of using the `isolated P` syntax, switch to specifying the
global actor type directly, e.g.,

   class MyClass: @MainActor MyProto { ... }

No functionality change at this point
2025-03-12 23:18:10 -07:00
Pavel Yaskevich
570eedbdc7 [ConstraintSystem] Update closure inference to support @execution(...) attribute
- Update `ClosureEffectsRequest` to make sure that closure is
marked as `async` when `@execution(...)` attribute is present.

- Update `inferClosureType` to set isolation based on an explicit
`@execution(...)` attribute attached to a closure.
2025-03-12 18:08:53 -07:00
Pavel Yaskevich
e9fd369824 [Sema] Allow use of @execution(...) attribute on closures 2025-03-12 17:29:40 -07:00
Becca Royal-Gordon
7c867ca1da [NFC] Split DeclAttrOptions into two types
We’re running out of bits in DeclAttrOptions, so split it in two: DeclAttrRequirements contains all the `On*` options that describe the declarations allowed to have the attribute, while the other options are now DeclAttrBehaviors.

This commit also sorts the entries in DeclAttr.def by serialization code and improves the formatting of the file.
2025-03-12 14:14:16 -07:00
Tony Allevato
68876a6d4a Merge pull request #76636 from allevato/rich-identifiers
Support raw identifiers (backtick-delimited identifiers containing non-identifier characters).
2025-03-12 14:56:14 -04:00
Anthony Latsis
ae0936f178 Merge pull request #79934 from AnthonyLatsis/no-карри
TypeCheckType: Do not fail after emitting a warning
2025-03-12 18:35:16 +00:00
Pavel Yaskevich
1bd0cd7b94 Merge pull request #79928 from xedin/support-debug-constraints-on-line-for-result-builders
[ResultBuilders] NFC: Support `-debug-constraints{-on-line=}` for dec…
2025-03-12 00:29:41 -07:00
eeckstein
47b449372e Merge pull request #79917 from eeckstein/rename-opened-archetype-type
AST: rename OpenArchetypeType -> ExistentialArchetypeType
2025-03-12 06:01:10 +01:00
Slava Pestov
9e721a35f2 Merge pull request #79914 from slavapestov/retry-removing-one-way-equal
Sema: Mostly remove one-way constraints
2025-03-11 21:24:57 -04:00
Anthony Latsis
89f5066fb4 TypeCheckType: Do not fail after emitting a warning
Also remove the redundant diagnosis altogether. This case is already
handled by the existential syntax checker just fine.
2025-03-12 00:33:18 +00:00
Pavel Yaskevich
6197aab467 [ResultBuilders] NFC: Support -debug-constraints{-on-line=} for declaration transforms 2025-03-11 15:13:58 -07:00
Tony Allevato
a68347f299 [Sema] Validate names of @objc declarations with raw identifiers.
If a decl is exported to Objective-C (explicitly or implicitly), it
must be given an explicit name that is a valid Objective-C identifier.
2025-03-11 17:18:44 -04:00
Erik Eckstein
d225c47d25 AST: rename OpenArchetypeType -> ExistentialArchetypeType
NFC
2025-03-11 20:21:46 +01:00
Slava Pestov
4c60e036ac Merge pull request #79882 from slavapestov/sizeof-constraint
Sema: Optimize Constraint layout to save 24 bytes
2025-03-11 14:30:44 -04:00
Doug Gregor
fed1a74848 Merge pull request #79904 from DougGregor/unsafe-concurrency-cycle
[Strict memory safety] Eliminate false cycle when checking nonisolated(unsafe)
2025-03-11 11:01:09 -07:00
Slava Pestov
6d8b55a9f6 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-03-11 13:55:40 -04:00
Slava Pestov
2500c83332 Sema: Simplify depthFirstSearch() a bit now that it only has one caller 2025-03-11 13:55:39 -04:00
Slava Pestov
94eff70b1d Sema: Remove DependentComponentSplitterStep 2025-03-11 13:55:39 -04:00