Commit Graph

28352 Commits

Author SHA1 Message Date
Anthony Latsis
02261dccc7 [NFC] TypeCheckType: Streamline logic in the any syntax checker 2025-02-12 21:20:44 +00:00
Michael Gottesman
1fc836c564 [concurrency] Persist caller isolation inheriting through serialization.
rdar://142790023
2025-02-12 12:36:13 -08:00
Guillaume Lessard
c7af9a701b Merge pull request #79294 from Azoy/bye-bye-slab
[stdlib] Rename Slab to InlineArray
2025-02-12 12:03:25 -08:00
Michael Gottesman
945d36ed97 [concurrency] Allow for nonisolated and execution(concurrent) to be used together.
After some discussions, we decided to allow for this since it doesnt harm anything. execution(caller) just takes primacy over it.
2025-02-12 10:38:06 -08:00
Michael Gottesman
121ed29081 [concurrency] Split out the default inferred actor isolation computation into a helper from ActorIsolationRequest::evaluate.
This recommits commit 5d6131e16b with the
reverting Concurrency rename removed.
2025-02-12 10:38:06 -08:00
Anthony Latsis
f3183be212 [NFC] TypeResolution: Tidy up control flow in resolveExistentialType 2025-02-12 17:11:46 +00:00
Anthony Latsis
251ac929be TypeResolution: Stop resolving unqualified protocol type aliases to DependentMemberType in structural stage
This workaround is no longer needed because `TypeAliasType` is now
modeled using generic arguments (as opposed to a substitution map).
Previously, computing the substitution map in `StructuralTypeRequest` to
construct the resulting `TypeAliasType` could cause a request cycle
around generic signature computation.
2025-02-12 17:10:27 +00: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
Allan Shortlidge
e87f80825d AST: Rename AvailabilityConstraint::Kind to Reason.
NFC.
2025-02-12 07:20:14 -08:00
Allan Shortlidge
3142803d2f AST: Remove runtime version from AvailabilitySpec.
Instead of canonicalizing platform versions during parsing and storing two
versions, just canonicalize the parsed version on-demand when its requested.
2025-02-11 20:10:07 -08:00
Allan Shortlidge
6daea78ccf AST: Remove AvailabilitySpec.h include from Stmt.h.
Include it where it's actually used instead to improve compile times.
2025-02-11 20:03:01 -08:00
Alejandro Alonso
4a8d4d271a Update lib/Sema/CSSimplify.cpp
Co-authored-by: Guillaume Lessard <glessard@tffenterprises.com>
2025-02-11 13:34:05 -08:00
Alejandro Alonso
e4fb1f6761 Rename Slab to InlineArray 2025-02-11 10:26:44 -08:00
Hamish Knight
f828882668 Merge pull request #78738 from calda/cal--fix-nested-weak-self-issue
Fix issue where implicit self was unexpectedly not allowed in nested weak self closure in Swift 6 mode
2025-02-11 11:17:11 +00:00
Doug Gregor
21e7e5dd77 Merge pull request #79284 from DougGregor/unsafe-for-in
[Unsafe] Teach for..in loops to let the sequence's 'unsafe' cover next()
2025-02-10 23:24:54 -08:00
Becca Royal-Gordon
f393962482 Merge pull request #79207 from beccadax/objcquious-indexes
Fix indexing crasher with implicit objcImpl inits
2025-02-10 18:24:28 -08:00
Pavel Yaskevich
81b7b447bc Merge pull request #79253 from xedin/fix-use-dc-for-constructor-calls
[ConstraintSystem] Store declaration context in which application constraint occurs
2025-02-10 15:10:13 -08:00
Doug Gregor
260ade8076 [Unsafe] Teach for..in loops to let the sequence's 'unsafe' cover next()
Warnings about unsafe uses due to an @unsafe IteratorProtocol conformance
(for the implicit call to next()) could not be silenced. Follow the same
path we did for the Sequence conformance (and makeIterator() call) by
associating it with the `unsafe` on the sequence argument.

This isn't the only solution here, but it's a reasonable one.
2025-02-10 14:59:15 -08:00
Slava Pestov
14bd0b0f74 Merge pull request #79208 from lkb85/fix/comment-typo
Fix typo in code comment for clarity
2025-02-10 17:00:16 -05:00
Doug Gregor
bda17b087c Merge pull request #79265 from DougGregor/unsafe-fixit-fixes
Fix Fix-It locations for "unsafe" insertion
2025-02-10 13:12:25 -08:00
Doug Gregor
5a3327c829 Merge pull request #79264 from DougGregor/unsafe-yield
Handle unsafe expressions in yield statements
2025-02-10 10:51:38 -08:00
Slava Pestov
17d8c820dc Merge pull request #79220 from slavapestov/fix-rdar143950572
AST: Source range of FuncDecl/ConstructorDecl should include the thrown type
2025-02-10 13:49:37 -05:00
Cal Stephens
14632b7c3e Update tests after pulling fix from master 2025-02-10 08:13:27 -08:00
Doug Gregor
54124193cf Look past autoclosures when determining where to insert "unsafe" in a Fix-It
Otherwise, we'll end up inserting the "unsafe" on the right-hand side of an &&
2025-02-10 06:54:17 -08:00
Doug Gregor
1cbeee6fed Fix Fix-It location for "unsafe" when calling an initializer
The implicit reference to the initializer was tripping up the logic
for finding the appropriate place to insert "unsafe", and it was ending
up in the middle of the expression.
2025-02-10 06:54:15 -08:00
Cal Stephens
64fc43e19b Merge tag 'swift-DEVELOPMENT-SNAPSHOT-2025-02-06-a' of github.com:swiftlang/swift into cal--fix-nested-weak-self-issue
Tag build swift-DEVELOPMENT-SNAPSHOT-2025-02-06-a
2025-02-10 06:31:27 -08:00
Cal Stephens
31528da906 Further simplify conditions 2025-02-10 06:29:27 -08:00
Doug Gregor
4a9e8906fb Handle unsafe expressions in yield statements 2025-02-10 06:22:41 -08:00
Slava Pestov
e9266c25d3 Sema: Fix accepts-invalid with throwing function types
We can't unconditionally skip the conformance check if the type contains type
parameters; instead, we only want to skip it in the structural resolution
stage. In interface resolution stage, we proceed by mapping the type into
the generic environment first.
2025-02-10 09:17:40 -05:00
Slava Pestov
8400b43388 Sema: Don't diagnose thrown error type that contains errors
If we have error types here, type resolution already diagnosed an
error; don't diagnose again.
2025-02-10 09:17:40 -05:00
Slava Pestov
92d8bf715f Sema: Remove unused variable 2025-02-10 09:17:40 -05:00
Pavel Yaskevich
23ace7d770 [ConstraintSystem] Store declaration context in which application occurs in ApplicableFunction constraint
This is required because `ApplicableFunction` constraint can
inject member reference constraints that require a declaration
context.

For example, `_ = { Double(...) }` would now produce a disjunction
for `Double.init` where overload choice declaration contexts point
to the closure instead of the enclosing context.

This addresses a long-standing FIXME in `simplifyApplicableFnConstraint`
and helps with disjunction optimizer because its correctness depends on
correct identification of declaration contexts where applications happen.
2025-02-09 15:46:44 -08:00
Pavel Yaskevich
d24f22ec54 [ConstraintSystem] Refactor spots that create ApplicationFunction directly
This is required to make it easier to add "use dc" to the application.
2025-02-09 14:03:43 -08:00
Doug Gregor
8463e2a606 Merge pull request #79240 from DougGregor/safe-cover-unsafe-arguments
@safe functions, properties, and subscripts "cover" certain unsafe arguments
2025-02-08 14:50:20 -08:00
Doug Gregor
4139430560 @safe functions, properties, and subscripts "cover" certain unsafe arguments
When calling an explicitly-@safe function or subscript, or accessing an
explicitly-@safe property, the direct arguments to that operation can be
considered safe if they are references to local variables or are references
to types.

This brings the implementation in line with the recent adjustments to the
proposal within the review.
2025-02-08 10:18:12 -08:00
Becca Royal-Gordon
6e9d386d9e Fix indexing crasher with implicit objcImpl inits
Implicit initializers are given a source location within the type they belong to. This works poorly for @objc @implementation classes, because the class they belong to is imported and so those SourceLocs are in a different source buffer from the extension they’re inside, breaking an invariant enforced by index-while-building features.

Fix these SourceLocs to come from the implementation context, so they’ll come from the extension for an objcImpl class and the type itself otherwise.
2025-02-07 13:22:43 -08:00
Hamish Knight
5af928216e [CS] Avoid penalizing holes for placeholder vars for completion
When doing completion in a result builder, we avoid
solving unrelated expressions by replacing them with
unbound placeholder variables. Avoid penalizing
assigning holes to these placeholders, since
otherwise we end up unnecessarily exploring the
entire solution space, and bailing due to too
complex.

rdar://144382123
2025-02-07 17:37:35 +00:00
Hamish Knight
b03e989280 [CS] NFC: Factor out shouldIgnoreHoleForCodeCompletion 2025-02-07 17:37:35 +00:00
Michael Gottesman
8c5b49e65a Merge pull request #79204 from gottesmm/undo-concurrent-for-now
[concurrency] For now undo ActorIsolation::Concurrent refactoring.
2025-02-06 23:06:15 -08:00
kibeom lee
2311794184 Fix typo in comments 2025-02-07 15:12:11 +09:00
Allan Shortlidge
3ce2449b8d Merge pull request #79190 from tshortli/availability-context-unit-tests
AST: Introduce `AvailabilityContext::containsUnavailableDomain()`
2025-02-06 20:58:35 -08:00
Doug Gregor
3637e69ca1 Merge pull request #79195 from DougGregor/expand-conformances-member-ordering
[Macros] Eliminate ordering dependency that suppressed conformingTo protocols
2025-02-06 19:32:48 -08:00
Michael Gottesman
d33371a51a Merge pull request #79178 from xedin/execution-attr-in-type-context
[AST/Parse] Initial implementation of `@execution(concurrent | caller)` in type context
2025-02-06 18:44:00 -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
c12a1410bf Revert "[concurrency] Split out the default inferred actor isolation computation into a helper from ActorIsolationRequest::evaluate."
This reverts commit 5d6131e16b.
2025-02-06 14:04:25 -08:00
Doug Gregor
d276006648 [Macros] Eliminate ordering dependency that suppressed conformingTo protocols
When a macro that has both 'member' and 'extension' roles is on a type,
and both list conforming protocols, the order in which those roles were
evaluated in the compiler could change the set of protocols passed to
the macro expansion function (via `conformingTo:`). Specifically, if
the extension macro was expanded first, the member macro would see the
extension providing the conformance to one of its protocols, and not
pass down that protocol to the member macro's `conformingTo:`.

Ensure that we account for already-expanded extension macros that
define conformances.

Fixes rdar://137080876.
2025-02-06 11:07:20 -08:00
Allan Shortlidge
ddb5f23306 AST: Add AvailabilityContext::containsUnavailableDomain().
Replaces AvailabilityContext::getUnavailableDomain().
2025-02-06 09:50:07 -08:00
Cal Stephens
041c68519c Simplify diagnostics 2025-02-06 08:38:13 -08:00
Anton Korobeynikov
1e7a1d91fc Emit reabstraction thunks for implicit conversions between T.TangentType and Optional<T>.TangentType (#78076) 2025-02-05 20:57:52 -08:00