Commit Graph

41448 Commits

Author SHA1 Message Date
Slava Pestov
ce62a2e93b AST: Remove AnyFunctionRef::setCaptureInfo() 2024-04-23 22:28:03 -04:00
Michael Gottesman
e85dfbd043 Merge pull request #73202 from gottesmm/move-error
[region-isolation] When RegionIsolation is enabled, delay the preconcurrency import not used diagnostic to the SIL pipeline.
2024-04-23 16:11:48 -05:00
Alexis Laferrière
8785cf5a3d Merge pull request #73183 from xymus/access-level-import-more-notes
Sema: Local duplicate of the note about which import limits access-level
2024-04-23 10:54:32 -07:00
Michael Gottesman
c4f7076baf [region-isolation] When RegionIsolation is enabled, delay the preconcurrency import not used diagnostic to the SIL pipeline.
The reason why I am doing this is that I am going to be adding support for
preconcurrency imports to TransferNonSendable. That implies that we can have
preconcurrency import suppression in the SIL pipeline and thus that emitting the
diagnostic in Sema is too early.

To do this, I introduced a new module pass called
DiagnoseUnnecessaryPreconcurrencyImports that runs after the SILFunction pass
TransferNonSendable. The reason why I use a module pass is to ensure that
TransferNonSendable has run on all functions before we attempt to emit these
diagnostics. Then in that pass, we iterate over all of the modules functions and
construct a uniqued array of SourceFiles for these functions. Then we iterate
over the uniqued SourceFiles and use the already constructed Sema machinery to
emit the diagnostic using the source files.

rdar://126928265
2024-04-23 12:42:43 -05:00
Michael Gottesman
025902fa99 [sil] Add a SILDeclRef field to SILFunction, have SILGen set it, and teach SILFunction how to use the field to get the SourceFile associated with the SILFunction. 2024-04-23 11:45:36 -05:00
Alexis Laferrière
fd59933ff5 Merge pull request #73179 from xymus/deprecated-impl-only
Sema: Warn that resilient uses of `@_implementationOnly` are deprecated
2024-04-23 09:22:12 -07:00
Kavon Farvardin
f0a69a3ef1 prevent uses of Escapable in general
This protocol appears in the stdlib as scaffolding for the
`NonescapableTypes` feature, which is still experimental and not gone
through evolution as an approved addition to the stdlib.

Rather than delete it from the stdlib, because it needs to still remain
to support that feature work, gate references to it behind a feature
flag.

Additionally, prevent documentation from seeing this declaration.

rdar://126705184
2024-04-22 20:40:11 -07:00
Alexis Laferrière
e4ac42b458 Merge pull request #73176 from xymus/silence-ambiguity-warning
Sema: Offer solution to silence inconsistent import access-level warnings
2024-04-22 15:28:05 -07:00
Alexis Laferrière
3d611e2a85 Sema: Simplify warning about @_implementationOnly being deprecated 2024-04-22 14:44:44 -07:00
Kavon Farvardin
04e100dc0d Merge pull request #73131 from kavon/rdar126730410
NCGenerics: omit flag in interfaces
2024-04-22 14:18:50 -07:00
Mike Ash
65da1ed662 Merge pull request #73137 from mikeash/unreachable-improvements
[Runtime] Make swift_unreachable more debuggable by trapping immediately.
2024-04-22 16:22:34 -04:00
Ellie Shin
3f047102c2 Merge pull request #72937 from apple/elsh/pkg-sil-verify
Add a package serialization bit to Module for SIL verifier in Package CMO mode.
2024-04-22 12:44:28 -07:00
Alexis Laferrière
134b34728b Sema: Reference InternalImportsByDefault as being an upcoming feature 2024-04-22 12:14:44 -07:00
Alexis Laferrière
56095cf745 Sema: duplicate the note about which import limits access-level
Access-level on imports limit where decls from the target module can
be referenced. This is reported by the typical error about and a note
on the import. However, when using an IDE and editing a large file,
the note on the import is easy to miss. Address this by duplicating
the information on the error line as well so it's never out of the
current viewport.

rdar://119438201
2024-04-22 12:07:31 -07:00
Alexis Laferrière
bd9c385ce5 Sema: Offer solution to silence inconsistent import access-level warnings
Adoption InternalImportsByDefault provides a safe access-level by default
to imports, as such ambiguities are not a risk and showing this warning is
superflous. When this warning is shown, make sure we note this alternative.
2024-04-22 10:52:21 -07:00
Alexis Laferrière
ff797cfd66 Sema: Warn on resilient uses of @_implementationOnly as deprecated
Report uses of `@_implementationOnly` in resilient modules as deprecated.
With a fixit to replace it with `internal` or delete it when imports
are internal by default.

Uses of `@_implementationOnly` in non-resilient modules is already reported
as being unsafe.
2024-04-22 10:32:58 -07:00
nate-chandler
1faeb50fff Merge pull request #73121 from nate-chandler/rdar126715654
[NoncopyablePartialConsumption] Promote to feature.
2024-04-22 07:01:10 -07:00
Holly Borla
a08c24044e Merge pull request #73168 from hborla/isolated-backing-property-wrapper
[Concurrency] Don't error on isolated property wrapper initializers inside `MainActor`-isolated structs.
2024-04-21 19:44:31 -07:00
Joe Groff
81534a6c15 Merge pull request #73148 from jckarter/borrowing-switch-old-behavior-compat
SILGen: Provide compatibility with prior `BorrowingSwitch` behavior.
2024-04-21 11:21:27 -07:00
Holly Borla
a6d9c15fb3 [Concurrency] Don't error on isolated property wrapper initializers inside
MainActor-isolated structs.
2024-04-21 10:01:31 -07:00
Slava Pestov
ae9eeb0993 Merge pull request #72936 from slavapestov/requestify-compute-captures
Request-ify TypeChecker::computeCaptures()
2024-04-21 09:56:23 -04:00
Slava Pestov
e342a38b87 Sema: Convert TypeChecker::computeCaptures() into two requests
We now compute captures of functions and default arguments
lazily, instead of as a side effect of primary file checking.

Captures of closures are computed as part of the enclosing
context, not lazily, because the type checking of a single
closure body is not lazy.

This fixes a specific issue with the `-experimental-skip-*` flags,
where functions declared after a top-level `guard` statement are
considered to have local captures, but nothing was forcing these
captures to be computed.

Fixes rdar://problem/125981663.
2024-04-20 22:16:25 -04:00
Adrian Prantl
2a58d61665 Merge pull request #73152 from adrian-prantl/register-memorybuffer-main
Define the semantics of registerMemoryBuffer() when insterting duplic…
2024-04-20 10:26:17 -07:00
Michael Gottesman
499854bc15 Merge pull request #73143 from gottesmm/pr-0e21c586193683965b808cbc147f588d42de5b27
[region-isolation] Disconnected regions in global actor isolated function are not accessible again after call to nonisolated async function
2024-04-19 18:18:06 -07:00
Adrian Prantl
c95f403f86 Define the semantics of registerMemoryBuffer() when insterting duplicates
to let the first module win. This functionality is tested in LLDB.
2024-04-19 16:30:32 -07:00
Michael Gottesman
1113a61f8d [region-isolation] Stub out getIsolationInfo so the mocking unit tests succeed.
Specifically, the partition unit tests pass in bogus instructions/operands so we
cannot call /any/ methods on them. So I created stubed out helpers on the
evaluator that in the case of mocking just return a default initialized
SILIsolationInfo().
2024-04-19 15:28:48 -07:00
Alexis Laferrière
bed91dc740 Merge pull request #73141 from xymus/no-internal-imports-by-default
Sema: Remove internal imports by default from Swift 6
2024-04-19 15:26:25 -07:00
Joe Groff
cb5f1e20ae SILGen: Provide compatibility with prior BorrowingSwitch behavior.
To avoid breaking early adopters of this feature, accept attempts to `return`
a `let` binding in a noncopyable `switch` when it would be treated as a
borrow normally, with a warning that this behavior will change soon.
rdar://126775241
2024-04-19 15:20:31 -07:00
Slava Pestov
55ff73f205 AST: Stronger assertions around CaptureInfo 2024-04-19 17:59:58 -04:00
Michael Gottesman
0e21c58619 [region-isolation] Disconnected regions in global actor isolated function are not accessible again after call to nonisolated async function
I also fixed the nonisolated(unsafe) issue.

rdar://126667934
rdar://126174959
2024-04-19 13:52:58 -07:00
Nate Chandler
d28a12d356 [MoveOnlyAddressChecker] Handle enum deinits.
Previously, the enum representation was fixed to represent the different
cases payloads separately with the unchecked_take_enum_data_addr
instruction consuming all fields but that whose address is obtained.
In a few places, handling for enum deinits was left undone with an
assertion that the enum not have one.

Here, the deinit bit of the enum is shifted to the end.  And the
assertions are replaced with handling.  Finally, the logic for inserting
destroys after switch_enum_addr instructions is fixed.
2024-04-19 12:37:34 -07:00
Nate Chandler
de8f1c0b69 [NoncopyablePartialConsumption] Promote to feature 2024-04-19 12:37:34 -07:00
Alexis Laferrière
a890d8fded Sema: Remove internal imports by default from Swift 6
The language steering group has decided to revert their previous
decision and remove this feature from Swift 6.

rdar://126318567
2024-04-19 12:19:29 -07:00
Anthony Latsis
4af5140d8b Merge pull request #70579 from AnthonyLatsis/super-sema
Move unsupported `super` use diagnosis from Parse to Sema
2024-04-19 20:07:12 +03:00
Anthony Latsis
223765899d Merge pull request #73103 from AnthonyLatsis/brassica-oleracea
Sema: Fix existential member access type erasure around metatypes
2024-04-19 17:42:06 +03:00
Anthony Latsis
fa6924a34e ParamDecl: Defend against default argument kind overwrites 2024-04-19 16:57:05 +03:00
Anthony Latsis
1d3a5860e2 [NFC] ParamDecl: Extract write of type-checked default expr into its own method 2024-04-19 16:57:05 +03:00
Anthony Latsis
61bdbd2fe3 Move unsupported super use diagnosis form Parse to Sema 2024-04-19 16:57:04 +03:00
Slava Pestov
3e637b0afb Merge pull request #73129 from slavapestov/local-function-isolation-change
Local functions inherit isolation from context instead of captures
2024-04-19 08:32:46 -04:00
Ellie Shin
53e8940674 Merge pull request #73124 from apple/elsh/pkg-frozen
Allow @frozen and @_fixed_layout for package access level.
2024-04-19 00:12:44 -07:00
Kavon Farvardin
b3d548218b NCGenerics: omit flag in interfaces
Also cleans-up legacy code and tests that are no longer needed.
2024-04-18 21:57:44 -07:00
Slava Pestov
d222470a0b AST: Remove unused methods from CaptureInfo 2024-04-18 22:47:23 -04:00
Dave Lee
e57f70bd4d [Debugging] Add DebugDescriptionMacro experimental feature (#73107)
This removes the leading underscore from the macro.
2024-04-18 17:25:44 -07:00
Ellie Shin
728aafab62 Update diagnostics def message 2024-04-18 16:51:24 -07:00
Ellie Shin
573d1b96ca Allow @frozen and @_fixed_layout for package access level.
Package decls were made to be resilient at the definition
site by default. By allowing the attributes to be applied
to package decls, we can enable non-resilient access.

Resolves rdar://125169361
2024-04-18 16:29:34 -07:00
Ellie Shin
0c0d8c0316 Merge branch 'main' into elsh/pkg-sil-verify 2024-04-18 13:34:29 -07:00
Anthony Latsis
7313b2f32c [NFC] Move a diagnostic from DiagnosticsParse.def to DiagnosticsSema.def 2024-04-18 23:07:14 +03:00
Anthony Latsis
9017bf77b1 Sema: Improve error messages for super in illegal context 2024-04-18 23:07:14 +03:00
Anthony Latsis
28de53f913 [NFC] Move a diagnostic from DiagnosticsCommon.def to DiagnosticsSema.def 2024-04-18 23:07:14 +03:00
Anthony Latsis
d18a7fd073 Sema: Require CS to certify conversions associated w/ existential member accesses 2024-04-18 22:54:19 +03:00