Commit Graph

28352 Commits

Author SHA1 Message Date
Pavel Yaskevich
c3b75ee0ef Merge pull request #79580 from xedin/extensible-enums
[Serialization/TypeChecker] Introduce `ExtensibleEnums` feature
2025-02-25 09:53:02 -08:00
Allan Shortlidge
c54825b4c3 AST: Use AvailabilityDomainOrIdentifier to store domains in AvailabilitySpec. 2025-02-25 09:02:47 -08:00
Anthony Latsis
e6639f16e6 Merge pull request #79445 from coffmark/fix/qoi-for-conformance-to-non-copyable
Sema: Add missing space to Copyable conformance suppression fix-it
2025-02-25 09:38:08 +00:00
Pavel Yaskevich
b84bf055f0 [TypeChecker] Implement ExtensibleEnums feature exhaustivily handling
If an enum comes from a different module that has `ExtensibleEnums`
feature enabled, unless it requires either `@unknown default:` or
`@frozen` because it is allowed to introduce new cases in the future
versions of the module.
2025-02-25 00:05:23 -08:00
Pavel Yaskevich
1649b5ec45 [Concurrency] Avoid dowgrading diagnostics multiple times
Unify `warn` + `limitBehavior` into a single call to make sure
that diagnostic doesn't get downgraded multiple times because
that could affect how diagnostics are tracked.
2025-02-24 18:03:38 -08:00
Doug Gregor
29d904f09d [SE-0458] Don't warn about unsafe conformances outside of strict safety mode 2025-02-24 17:20:01 -08:00
coffmark
cc6f1a1548 Sema: Add missing space to Copyable conformance suppression fix-it 2025-02-25 08:48:46 +09:00
Doug Gregor
115abcb637 Merge pull request #79573 from DougGregor/unsafe-for-in-loop
[SE-0458] Implement "unsafe" effect for the for-in loop
2025-02-24 14:49:45 -08:00
Pavel Yaskevich
13e3269d16 [CSFix] Fix a null pointer dereference in getStructuralTypeContext
First problem - the logic used constraint system, which shouldn't
be required, second - it expects the type to be always present in
`ContextualTypeInfo` but that's not the case for some patterns.

Resolves: rdar://131819800
2025-02-24 13:57:28 -08:00
Doug Gregor
50801f9c05 [SE-0458] Implement "unsafe" effect for the for-in loop
Memory unsafety in the iteration part of the for-in loop (i.e., the part
that works on the iterator) can be covered by the "unsafe" effect on
the for..in loop, before the pattern.
2025-02-23 22:50:39 -08:00
Allan Shortlidge
db29a1c6f4 Parse/Sema: Move #available query wildcard diagnostics to Sema.
In order to unblock resolution of availability domains during type-checking
instead of parsing, diagnostics about missing or superfluous wildcards in
availability specification lists need to move to Sema.
2025-02-23 22:09:33 -08:00
Allan Shortlidge
eb6506a1ad AST: Introduce SemanticAvailabilitySpec.
It wraps an type-checked `AvailabilitySpec`, which guarantees that the spec has
a valid `AvailabilityDomain` associated with it. This will unblock moving
AvailabilitySpec domain resolution from parsing to sema.
2025-02-23 10:53:06 -08:00
Allan Shortlidge
5bccbe567d AST: Refactor AvailabilityScope::getAvailabilityConditionVersionSourceRange().
Modify it to take an `AvailabilityDomain` and a `DeclContext` which will be
necessary in order to compare `AvailabilitySpec`s in a later refactor.
2025-02-23 10:53:06 -08:00
stzn
43e60304ad Add sending to subscript getter sending result 2025-02-23 10:52:01 +09:00
Allan Shortlidge
3121743bf4 Sema: Fix unused variable warning in TypeCheckDeclPrimary.cpp.
NFC.
2025-02-22 12:09:23 -08:00
Pavel Yaskevich
d14635bec3 [TypeChecker] Allow @objc @implementation to mismatch on @Sendable in parameter positions
Just like for protocol matching, let's allow `@Sendable` mismatches
in parameter positions to make sure that it's possible for header
authors to add concurrency annotations without breaking clients.

This is especially important for `SendableCompletionHandlers` feature
that makes imported sync completion handler parameters `@Sendable`.
2025-02-21 14:19:21 -08:00
Pavel Yaskevich
520c05b1b8 Merge pull request #79508 from xedin/feature-proof-execution-attrs
[Frontend] Rename `NonIsolatedAsyncInheritsIsolationFromContext` feature and add a feature for `@execution`
2025-02-21 09:07:04 -08:00
Allan Shortlidge
205bfee07a Merge pull request #79537 from tshortli/potentially-unavailable-witness-in-unavailable-conformance
Sema: Skip diagnosing witness availability for unavailable conformances
2025-02-21 07:52:14 -08:00
Hamish Knight
25fa31234f Merge pull request #79529 from hamishknight/small-cleanup
[CS] Clean up pack expansion environment handling a little
2025-02-21 14:16:55 +00:00
Rintaro Ishizaki
6805e155d5 Merge pull request #79503 from rintaro/astgen-paramdecl-typerepr
[AST] Sink ParamDecl flag collection logic from Parse to AST
2025-02-21 02:18:52 -08:00
Allan Shortlidge
54e6900c36 Sema: Skip diagnosing witness availability for unavailable conformances.
If a conformance is unavailable then checking for the potential unavailability
of a witness doesn't make sense so skip it. This is necessary now because
availability scopes no longer constrain the platform introduction version for a
source range in that is annotated in source to be simultaneously unavailable
and also introduced in a later version.

This fixes a regression caused by https://github.com/swiftlang/swift/pull/79249.

Resolves rdar://145255592.
2025-02-20 22:42:00 -08:00
Allan Shortlidge
b20f2c0e4e Merge pull request #79517 from tshortli/availability-scope-decl-context
AST: Store the active `DeclContext` in `AvailabilityScope`
2025-02-20 20:07:57 -08:00
Allan Shortlidge
3db2b97a83 Merge pull request #79520 from tshortli/sink-semantic-available-attr-request
AST/Sema: Sink `SemanticAvailableAttrRequest` from Sema into AST
2025-02-20 20:00:13 -08:00
Pavel Yaskevich
18a9987e16 Merge pull request #79497 from xedin/execution-attr-diagnostics
[Sema] Either variant of `@execution` is incompatible with other isol…
2025-02-20 14:00:57 -08:00
Slava Pestov
3a722210bb Merge pull request #79507 from slavapestov/assert-constraint-types
Sema: Assert that certain type kinds do not appear in constraints
2025-02-20 16:54:28 -05:00
fahadnayyar
9782eae585 Merge pull request #77522 from fahadnayyar/cxx-frt-inheritance-diagnostics
[cxx-interop] Infer SWIFT_SHARED_REFERENCE for types inheriting from a C++ foreign reference type
2025-02-20 13:46:28 -08:00
Hamish Knight
c69590fbdd [CS] Clean up pack expansion environment handling a little
- Track environments for `PackExpansionExpr` directly
instead of using a locator.
- Split up the querying and creation of the environment
such that the mismatch logic can be done directly in
CSSimplify instead of duplicating it.
- Just store the environment directly instead of
the shape and UUID.
2025-02-20 21:31:46 +00:00
Hamish Knight
0b57ca6d56 [CS] Use dumpAnchor in SolverTrail::Change::dump
Resolve a couple of FIXMEs by using `dumpAnchor` to
dump a couple of ASTNodes. This uses the same
compact representation as used in ConstraintLocator
dumping.
2025-02-20 21:31:46 +00:00
Hamish Knight
9c04fd8cd3 [CS] NFC: Factor out matchPackElementType 2025-02-20 21:31:46 +00:00
Hamish Knight
29e9f429e3 [CS] NFC: Rename PackEnvironments -> PackElementExpansions
IMO "environment" is confusable for GenericEnvironment,
make it clearer it's referring to the parent
PackExpansionExpr.
2025-02-20 21:31:46 +00:00
Holly Borla
be035a65fb Merge pull request #78652 from jamieQ/static-actor-safety-hole
[Sema]: Fix data race safety hole with mutable statics within actors
2025-02-20 12:04:16 -08:00
Allan Shortlidge
f4f9d85503 AST/Sema: Sink SemanticAvailableAttrRequest from Sema into AST.
Unblocks some work on the `@abi` attribute.
2025-02-20 10:29:38 -08:00
Rintaro Ishizaki
8833ff58a2 [AST] Sink the flag collection logic from Parse to AST
* Collect flag in `ParamDecl::setTypeRepr()`.

* [ASTGen] Separate `BridgedParamDecl.setTypeRepr(_:)` from
`BridgedParamDecl.createParsed(_:)` aligning with C++ API. The majority
of the creations don't set the typerepr.

* Update `ParamSpecifierRequest::evaluate` to handle non-implicit
`ParamDecl` without `TypeRepr` (i.e. untyped closure parameter), instead
of `setSpecifier(::Default)` manually in Parse.
2025-02-20 10:04:49 -08:00
Slava Pestov
cd77027675 Sema: Banish GenericTypeParamType from the constraint system 2025-02-20 12:06:21 -05:00
Slava Pestov
209e266b47 Sema: Banish UnboundGenericType from the constraint system
These should have been opened already, and the logic in
simplifyConstraint(), matchTypes(), etc is just going to do
undefined things if they end up there, so let's guard
against it happening.
2025-02-20 12:06:21 -05:00
Allan Shortlidge
1ff1a8d7bc AST: Store the active DeclContext in AvailabilityScope.
In the future, the `DeclContext` for a given scope will be needed as an input
in order to query for the `AvailabilityDomain` associated with an
`AvailabilitySpec`.
2025-02-20 08:57:45 -08:00
fahadnayyar
d8f919778d [cxx-interop] [cxx-interop] Infer SWIFT_SHARED_REFERENCE for types inheriting from a C++ foreign reference type
rdar://97914474
2025-02-20 08:46:57 -08:00
Doug Gregor
c308cfd26a Fix declaration context for unsafe storage checking
Fix a compiler crash involving checking of generic types for unsafe
storage.
2025-02-19 21:31:20 -10:00
Slava Pestov
668928e591 Merge pull request #79475 from slavapestov/issue-a-retraction
Sema: Clean up odd bit of dead code in binding inference
2025-02-19 23:55:36 -05:00
Slava Pestov
a7b50c0b62 Merge pull request #79489 from slavapestov/fix-rdar145092838
Sema: Don't record constraints containing UnboundGenericType from shrink()
2025-02-19 23:42:09 -05:00
Pavel Yaskevich
613fbaf76e [Sema] Either variant of @execution is incompatible with other isolation
According to the proposal both variants cannot be used together
with other forms of isolation i.e. isolated parameters, global
actors, `@isolated(any)` attributes.
2025-02-19 20:06:15 -08:00
Konrad `ktoso` Malawski
e8668684a1 Merge pull request #79411 from amartini51/typo_144059094
Remove double word ("a a" and "the the")
2025-02-20 13:05:06 +09:00
Pavel Yaskevich
e2ff3308be [Frontend] NFC: Rename NonIsolatedAsyncInheritsIsolationFromContext feature
New name is `AsyncCallerExecution` as stated by the proposal.
2025-02-19 20:00:56 -08:00
Michael Gottesman
3ef18eaf1d Merge pull request #79300 from gottesmm/pr-12bede947a34719b34b1aa8ea6c126a6126d6dd6
[concurrency] Implement serialization for execution(caller)/execution(concurrent).
2025-02-19 18:29:02 -08:00
Allan Shortlidge
ff17263e56 Merge pull request #79480 from tshortli/exclude-parser-diags
Parse: Avoid including `DiagnosticsParse.h` in `Parser.h`
2025-02-19 18:19:29 -08:00
Allan Shortlidge
7492e961dc Merge pull request #79494 from tshortli/type-check-availability-spec
Parse/Sema: Move some `AvailabilitySpec` diagnostics from Parse to Sema
2025-02-19 17:07:24 -08:00
Rintaro Ishizaki
e5d5026992 Merge pull request #79456 from rintaro/astgen-paramdecl
[ASTGen] ParamDecl generation improvements
2025-02-19 14:05:55 -08:00
Allan Shortlidge
e90530990a Parse/Sema: Move some AvailabilitySpec diagnostics from Parse to Sema.
Eventually, querying the `AvailabilityDomain` associated with an
`AvailabilitySpec` will require invoking a request that takes a `DeclContext`.
This means that any diagnostics related to the domain identified by an
`AvailabilitySpec` need to be emitted during type-checking rather than parsing.
This change migrates several `AvailabilitySpec` diagnostics from Parse to Sema
to unblock further work.
2025-02-19 11:40:56 -08:00
Slava Pestov
521ea46d15 Sema: Don't record constraints containing UnboundGenericType from shrink()
Something changed here between the removal of shrink() and it's
re-introduction, and we now record constraints that contain
UnboundGenericType, which crashes in matchTypes().

As a narrow workaround, let's just ignore the contextual type if
contains an UnboundGenericType.

Fixes rdar://145092838.
2025-02-19 13:27:33 -05:00
Allan Shortlidge
e8329d292b Parse: Avoid including DiagnosticsParse.h in Parser.h.
This prevents the include of DiagnosticsParse.h from leaking into `.cpp` files
in libraries besides Parse.
2025-02-19 07:56:38 -08:00