Commit Graph

46165 Commits

Author SHA1 Message Date
Konrad 'ktoso' Malawski
6872707574 [embedded][Concurrency] Further refine C-api boundary for isIsolating... 2025-04-29 22:29:26 +09:00
Konrad 'ktoso' Malawski
ea16df04ac [Concurrency] adjust how we fail creating an IsIsolatingCurrentContextDecision 2025-04-29 20:08:56 +09:00
Konrad 'ktoso' Malawski
e1dc854f8f [Concurrency] Change isIsolatingCurrent... to return Bool?
This changes the isIsolatingCurrentContext function to return `Bool?`
and removes all the witness table trickery we did previously to detect
if it was implemented or not. This comes at a cost of trying to invoke
it always, before `checkIsolated`, but it makes for an simpler
implementation and more checkable even by third party Swift code which
may want to ask this question.

Along with the `withSerialExecutor` function, this now enables us to
check the isolation at runtime when we have an `any Actor` e.g. from
`#isolation`.

Updates SE-0471 according to
https://forums.swift.org/t/se-0471-improved-custom-serialexecutor-isolation-checking-for-concurrency-runtime/78834/
review discussions
2025-04-29 20:08:55 +09:00
Karoy Lorentey
f69997e759 Merge pull request #81117 from lorentey/paper-over-a-deserialization-crash
[AST] Temporarily turn off an assert on empty scopeLifetimeParamIndices
2025-04-28 13:11:17 -07:00
Pavel Yaskevich
085078dd8a [Feature] Rename Feature APIs from adoption to migration 2025-04-28 11:52:46 -07:00
Slava Pestov
2fa49b0458 AST: SubstitutionMap overload of substOpaqueTypesWithUnderlyingTypes()
This replaces the oddly-named mapIntoTypeExpansionContext() method
on SubstitutionMap itself in favor of a global function, just like
the ones that take Type and ProtocolConformanceRef.
2025-04-28 13:48:35 -04:00
Slava Pestov
0b961c6139 AST: Clean up InFlightSubstitution::lookupConformance()
The special handling of DynamicSelfType should no longer be necessary
so I'm removing it.
2025-04-28 13:48:24 -04:00
Slava Pestov
b911b80725 AST: Remove unused and incorrect BridgedASTType::subst() 2025-04-28 13:47:53 -04:00
Pavel Yaskevich
2a479acf9e [Feature] NFC: Rename ADOPTABLE_ with MIGRATABLE_ to match the proposal 2025-04-28 10:42:22 -07:00
Slava Pestov
ee9f1dc2a9 AST: Introduce ReplaceExistentialArchetypesWithConcreteTypes 2025-04-28 11:49:50 -04:00
Slava Pestov
cf1572c65b AST: Add ASTContext::TheSelfType for convenience 2025-04-28 11:49:50 -04:00
Doug Gregor
771cb35c23 Merge pull request #81120 from DougGregor/unsafe-call-effects
[Strict memory safety] Provide argument-specific diagnostics for calls
2025-04-26 07:41:38 -07:00
Max Desiatov
bb848821f2 Merge pull request #81104 from Azoy/value-generic-namelookup-warning
[AST] Temporarily downgrade value generic redeclaration to warning
2025-04-26 11:29:15 +01:00
Doug Gregor
02e1d11896 Ungroup "no unsafe operations occur within 'unsafe'" warnings
These should not be escalated to errors when other strict memory safety
warnings are, because they aren't safety issues. They could go into a
separate group along with the corresponding try and await diagnostics.
2025-04-25 21:54:42 -07:00
Doug Gregor
ee9487b86f [Strict memory safety] Provide argument-specific diagnostics for calls
Similar to what we do for 'throws' checking, perform argument-specific
checking for unsafe call arguments. This provides more detailed failures:

```
example.swift:18:3: warning: expression uses unsafe constructs but is not
marked with 'unsafe' [#StrictMemorySafety]
16 |   x.f(a: 0, b: 17, c: nil)
17 |
18 |   x.f(a: 0, b: 17, c: &i)
   |   |                   `- note: argument 'c' in call to instance
method 'f' has unsafe type 'UnsafePointer<Int>?'
   |   `- warning: expression uses unsafe constructs but is not marked
with 'unsafe' [#StrictMemorySafety]
19 |   unsafeF()
20 | }
```

It also means that we won't complain for `nil` or `Optional.none`
arguments passed to unsafe types, which eliminates some false
positives, and won't complain about unsafe result types when there is
a call---because we'd still get complaints later about the
actually-unsafe bit, which is using those results.

Fixes rdar://149629670.
2025-04-25 21:54:19 -07:00
Karoy Lorentey
b7bb2d5793 [AST] Temporarily turn off another assert
`scopeLifetimeParamIndices` sometimes ends up non-null but empty, which causes crashes in module deserialization, blocking cross-module work on nonescapable types.

rdar://147765187
2025-04-25 16:37:35 -07:00
Pavel Yaskevich
30a72ab5c9 Merge pull request #81073 from xedin/extensible-enums-flag
[Frontend] Add `ExtensibleAttribute` to guard use of `@extensible` at…
2025-04-25 10:06:55 -07:00
Alejandro Alonso
687b3f5ba2 Downgrade redeclaration with value generic arg to warning right now 2025-04-25 09:24:10 -07:00
Mike Ash
0fac5cb5ab Merge pull request #81074 from mikeash/fix-reflect-task-crash
[RemoteMirror] Only look through Task wait adapters when there's a dependency record.
2025-04-25 09:15:44 -04:00
Anthony Latsis
925b72eaec Merge pull request #76337 from DePasqualeOrg/grammar-compound-modifiers
Grammatical corrections for compound modifiers
2025-04-25 13:50:52 +01:00
Pavel Yaskevich
0ad7d8b590 [AST] Prevent use of @extensible without ExtensibleAttribute feature 2025-04-24 12:10:53 -07:00
Pavel Yaskevich
6d89bca765 [Frontend] Add ExtensibleAttribute to guard use of @extensible attribute
Guard against condfails when older compilers get a swift interface
that uses `@extensible` attribute. The attribute itself doesn't
have any effect in swift interfaces yet since all of the public
enums are already resilient in that mode.
2025-04-24 12:09:17 -07:00
Mike Ash
027cc09c2d [RemoteMirror] Only look through Task wait adapters when there's a dependency record.
When the RunJob pointer is set to adapters, we try to get the "real" run pointer from the context. However, there are cases where the context can be a dangling pointer, when the task has finished with it but hasn't reset the pointer to anything else. For cases where that can happen, the context is legitimate only when there's a dependency record. Check for a dependency record before trying to read the context in those cases.

In most uses this will fail gracefully or return a garbage run pointer, but swift-reflection-test uses an in-process memory reader which can crash when trying to chase this pointer, resulting in test failures.

rdar://149252404
2025-04-24 12:54:35 -04:00
Anthony
c9b17383c8 Grammatical corrections for compound modifiers 2025-04-24 09:21:32 +02:00
Slava Pestov
4555616886 Merge pull request #81045 from slavapestov/fix-rdar149801864
Demangle: Implement missing Node::Kind::DependentProtocolConformanceOpaque
2025-04-23 21:55:28 -04:00
Slava Pestov
5e23a4c2c0 Demangle: Implement missing Node::Kind::DependentProtocolConformanceOpaque
If a retroactive conformance is conditional and the subject type of a
conditional requirement is an opaque archetype, the mangler would
emit a mangling using the "HO" operator which the demangler did not
understand.

Implement de/remangler support for the "HO" operator.

Fixes rdar://149801864.
2025-04-23 16:39:16 -04:00
nate-chandler
3e35fa423d Merge pull request #81015 from nate-chandler/rdar141279635
[MoveOnly] Fix consumption of opened existentials.
2025-04-23 13:26:47 -07:00
Anthony Latsis
9a98784a96 Merge pull request #80593 from AnthonyLatsis/collybia-nuda
AST: Quote attributes more consistently in diagnostics
2025-04-23 16:50:26 +01:00
Max Desiatov
adfab01f4e Embedded: fix arguments mismatch in ResultTypeInfo (#80862)
Mismatched number of arguments traps on Wasm. Second argument of `destroy` in VW seems unused, so let's pass `nullptr` as a workaround.
2025-04-23 11:31:13 +01:00
Allan Shortlidge
fe79c409ba Merge pull request #80972 from tshortli/member-import-visibility-cross-import-overlay
Sema: Improve MemberImportVisibility diagnostics for cross import overlays
2025-04-22 18:29:33 -07:00
Nate Chandler
ea61814c08 [SIL] Add open_existential_addr.accessKind setter. 2025-04-22 17:59:37 -07:00
nate-chandler
f424639fee Merge pull request #80990 from nate-chandler/rdar147586673
[OSSACanOwned] Don't dead-end extend if consumed.
2025-04-22 17:56:24 -07:00
Anthony Latsis
17032b6eaf AST: Quote attributes more consistently in DiagnosticsSIL.def 2025-04-22 18:23:40 +01:00
Anthony Latsis
1d6ed11e46 AST: Quote attributes more consistently in DiagnosticsModuleDiffer.def 2025-04-22 18:23:40 +01:00
Anthony Latsis
2b9123906c AST: Quote attributes more consistently in DiagnosticsIRGen.def 2025-04-22 18:23:40 +01:00
Anthony Latsis
a70fdde3fc AST: Quote attributes more consistently in DiagnosticsCommon.def 2025-04-22 18:23:40 +01:00
Anthony Latsis
9a414c4de4 AST: Quote attributes more consistently in DiagnosticsParse.def 2025-04-22 18:23:40 +01:00
Anthony Latsis
2cd90bdd69 AST: Quote attributes more consistently in DiagnosticsSema.def 2025-04-22 18:23:36 +01:00
Nate Chandler
40bcc74b47 [OSSACanOwned] Don't dead-end extend if consumed.
When the utility is used by the ConsumeOperatorCopyableValuesChecker,
the checker guarantees that the lifetime can end at the consumes, that
there are no uses after those consumes.  In that circumstance, the
utility maintains liveness to those consumes and as far as possible
without introducing a copy everywhere else.

The lack of complete lifetimes has forced the utility to extend liveness
of values to dead-ends.  That extension, however, is in tension with the
use that the checker is putting the utility to.  If there is a dead-end
after a consume, liveness must not be maintained to that dead-end.

rdar://147586673
2025-04-21 18:09:30 -07:00
Nate Chandler
6ff0c07fe6 [NFC] OSSACanOwned: Extracted predicate. 2025-04-21 18:09:30 -07:00
Nate Chandler
02618f562d [NFC] OSSACanOwned: Renamed field. 2025-04-21 18:09:30 -07:00
Allan Shortlidge
9e67cf00cf Sema: Improve MemberImportVisibility diagnostics for cross import overlays.
When `MemberImportVisibility` is enabled and a declaration from a cross import
overlay is diagnosed because it has not been imported, suggest imports of the
declaring and bystanding modules instead of the cross import overlay module
(which is an implementation detail).

Resolves rdar://149307959.
2025-04-21 16:51:39 -07:00
Pavel Yaskevich
c110941c27 [Frontend] Rename AsyncCallerExecution upcoming feature to NonisolatedNonsendingBeDefault 2025-04-21 13:59:29 -07:00
Pavel Yaskevich
a3d35d54e5 [Frontend] Mark AsyncCallerExecution as an upcoming feature in Swift 7 2025-04-21 11:45:48 -07:00
Michael Gottesman
c72e57e6a3 Merge pull request #80911 from gottesmm/pr-52ba504b4ba7185b4e3f34ed03b36721f4ad3d82
[rbi] Simplify some logic that got confused so that passing an actor isolated value to a callee that is isolated ot the same actor is not considered a send.
2025-04-21 10:09:39 -07:00
Doug Gregor
54e4400e92 Merge pull request #80933 from DougGregor/safe-nested-in-unsafe-fixes
[Strict memory safety] Improve handling of safe types nested within unsafe ones
2025-04-20 02:31:48 -07:00
Doug Gregor
53ca902267 [Strict memory safety] Type alias types are only unsafe if their underlying type is 2025-04-19 10:38:07 -07:00
Doug Gregor
5bd782e178 Merge pull request #80874 from DougGregor/new-diagnostics-formatter-without-sourceloc
[Diagnostics] Use the swift-syntax formatting for invalid source locations, too
2025-04-18 20:04:53 -07:00
Doug Gregor
235242e8b3 [Diagnostics] Use the swift-syntax formatting for invalid source locations, too
The diagnostics formatter from swift-syntax previously only handled
fully-formed diagnostics anchored at a particular syntax node.
Therefore, the compiler would fall back to the existing LLVM-based
diagnostic formatter for diagnostics that had no source location.

Adopt new API in the swift-syntax diagnostics formatter that renders a
diagnostic message without requiring source location information, so
that we consistently use the swift-syntax formatter when it is
selected (which is the default).
2025-04-18 15:36:43 -07:00
Becca Royal-Gordon
8f75878455 Forbid @_borrowed in @abi
It has indirect effects on the accessors, so it shouldn’t matter, but we can defensively redirect the query to the API counterpart anyway.

This was the last `InferredInABIAttr` attribute, so we can now remove all of the infrastructure involved in supporting attribute inference.
2025-04-18 14:50:01 -07:00