Commit Graph

4105 Commits

Author SHA1 Message Date
Holly Borla
8bfe832c47 [Concurrency] Allow struct members to have isolation annotations. 2024-03-09 14:15:04 -08:00
Meghana Gupta
e96642c219 Merge pull request #72106 from meg-gupta/lifetimedepdiag
Loosen some lifetime dependence diagnostics
2024-03-07 16:32:13 -08:00
nate-chandler
8ddbc8bf0e Merge pull request #72144 from nate-chandler/partial-consumption/20240306/1
[NoncopyablePartialConsumption] Allow consume.
2024-03-07 10:51:55 -08:00
Holly Borla
b06fb7439c Merge pull request #72147 from hborla/global-concurrency-diagnostics 2024-03-07 06:36:34 -08:00
Meghana Gupta
a74a84a125 Remove diagnostic which didnt allow explicitly specifying BitwiseCopyable on a ~Escapable type 2024-03-06 21:57:03 -08:00
Holly Borla
c0486c38a4 [Concurrency] Improve the diagnostics for unsafe immutable global and
static variables.
2024-03-06 21:12:11 -08:00
Slava Pestov
dcea491dbe Sema: Remove inference of conditional Copyable conformance from generic parameters 2024-03-06 22:47:54 -05:00
Nate Chandler
fb0ae6ecbb [NoncopyablePartialConsumption] Allow consume.
Allow a noncopyable value to be partially consumed via the `consume`
keyword.
2024-03-06 18:58:38 -08:00
Kuba Mracek
baacf12426 [embedded] Diagnose usage of weak and unowned variables in embedded Swift 2024-03-06 15:39:26 -08:00
Pavel Yaskevich
279e147ae2 Merge pull request #71701 from li3zhen1/my-branch
[CSDiagnostics] Add diagnostics for holes in generic parameter packs
2024-03-06 11:58:19 -08:00
Nate Chandler
cf77b9f98b [BitwiseCopyable] Allow conformance via swift_attr
If an imported type's conformance cannot be implicitly inferred, allow
it to be explicitly stated via
`__attribute__((__swift_attr__("_BitwiseCopyable")))`.
2024-03-05 16:52:17 -08:00
Nate Chandler
a0ac007343 [BitwiseCopyable] Don't infer on unref storage.
An imported declaration which has storage that can't be represented in
Swift must not be inferred to be BitwiseCopyable: that inference
involves looking at the (visible) fields.
2024-03-05 16:52:17 -08:00
Doug Gregor
cff918428a Implement proper visibility rules for imported extensions
If an extension isn't imported either directly or via a transitive
(`@_exported`) import, its members should not be visible to name
lookup. Implement this behavior behind the experimental flag
ExtensionImportVisibility.
2024-03-04 07:43:54 -08:00
Holly Borla
d83d0461cf Merge pull request #72002 from hborla/adjust-language-mode-warning
[Diagnostics] Clarify the wording of `error_in_future_swift_version`.
2024-03-01 15:53:00 -08:00
Alexis Laferrière
70cf5d4783 Merge pull request #72001 from xymus/restrict-to-channel
Serialization: Restrict swiftmodules to distribution channels
2024-03-01 14:54:50 -08:00
Holly Borla
9ba481ad53 [Diagnostics] Clarify the wording of error_in_future_swift_version. 2024-03-01 12:05:51 -08:00
Alexis Laferrière
1e4fe67f40 Serialization: restrict swiftmodules to distribution channels
There are scenarios where different compilers are distributed with
compatible serialization format versions and the same tag. Distinguish
swiftmodules in such a case by assigning them to different distribution
channels. A compiler expecting a specific channel will only read
swiftmodules from the same channel. The channels should be defined by
downstream code as it is by definition vendor specific.

For development, a no-channel compiler loads or defining the env var
SWIFT_IGNORE_SWIFTMODULE_REVISION skips this new check.

rdar://123731777
2024-03-01 10:52:44 -08:00
John McCall
0f076c0702 Fix metadata availability testing for parameterized existentials
and implement it for @isolated(any) function types.

The existing testing was pretty broken: we were diagnosing all sorts
of things that don't require type metadata (like using a tuple with
an extended existential in a value position in an API signature)
and not diagnosing several things that do (like covariant function
conversions that erase types).  There's therefore some risk to this
patch, but I'm not too worried because needing metadata like this is
pretty uncommon, and it's likely that programs won't build correctly
anyway --- it'll just get caught by the linker instead of the compiler.
2024-02-29 22:14:49 -05:00
Zhen Li
9276bb0d2e Merge branch 'apple:main' into my-branch 2024-02-28 19:07:11 -05:00
Alexis Laferrière
eddbf2ef7b Merge pull request #71920 from xymus/typo-accepted-import
Sema: fix typo in diag about accepted access-levels on imports
2024-02-28 14:19:18 -08:00
Zhen Li
e513a7a8e2 Merge branch 'apple:main' into my-branch 2024-02-27 21:56:03 -05:00
Alexis Laferrière
dec3ea2320 Sema: fix typo in diag about accepted access-levels on imports 2024-02-27 10:31:54 -08:00
Holly Borla
44c5f9f459 Merge pull request #71866 from hborla/restate-unchecked-sendable
[Concurrency] Warn if implied `@unchecked Sendable` conformances are not re-stated.
2024-02-24 14:31:52 -08:00
Holly Borla
eba4545536 [Concurrency] Warn if implied @unchecked Sendable conformances are not
re-stated.
2024-02-23 23:59:16 -08:00
Meghana Gupta
afdd141714 Ban lifetime dependence specifiers on tuple result 2024-02-23 15:29:05 -08:00
Meghana Gupta
ca73cba046 Enable lifetime dependence inference when NonescapableTypes is on 2024-02-23 01:49:47 -08:00
li3zhen1
4779ddcb8f [CSDiagnostics] Update test case for callee side notes 2024-02-22 13:14:07 -05:00
li3zhen1
9a6d2b5304 [CSDiagnostics] Add callee side note for holes in generic pack element 2024-02-22 12:39:18 -05:00
Li, Zhen
b44fbf60c6 [CSDiagnostics] Add diags for holes in generic parameter pack 2024-02-21 23:25:25 -05:00
Allan Shortlidge
b46d179d46 Serialization: Skip patterns with invalid types.
Prevents a crash during module emission with `-enable-lazy-typechecking` when
the type of a `Pattern` cannot be resolved.
2024-02-19 20:52:17 -08:00
Allan Shortlidge
65ea9c8313 Serialization: Skip custom attributes with invalid types.
Prevents a crash during module emission with `-enable-lazy-typechecking` when
the type corresponding to a `CustomAttr` cannot be resolved.
2024-02-19 20:52:17 -08:00
Allan Shortlidge
72da8f4e9c Serialization: Skip invalid decls during module serialization.
When `-enable-lazy-typecheck` is specified, serialization may be expected to
run on an AST containing invalid declarations since type checking may happen
on-demand, during serialization, in this mode. If the declarations that are
invalid are not skipped, then the compiler is likely to crash when attempting
to serialize them. Now, invalid declarations are skipped and an error is
emitted at the end of serialization to note that serialization failed.

Additionally, a new `-Rmodule-serialization` flag can be specified to request
more detailed information about module serialization failures. This would be
useful in a situation where lazy typechecking does not produce any diagnostic
for some reason, but module serialization fails and more information is
therefore required to debug.

Resolves rdar://123260476
2024-02-19 20:52:17 -08:00
Holly Borla
26621b804c [Concurrency] Enable optional isolated parameters. 2024-02-16 16:28:45 -08:00
Kavon Farvardin
08b71e0136 NCGenerics: rebuild stdlib from its interface
When a NoncopyableGenericsMismatch happens between the compiler and
stdlib, allow the compiler to rebuild the stdlib from its interface
instead of exiting with an error.
2024-02-15 18:08:54 -08:00
Holly Borla
35187d2e56 Merge pull request #71643 from hborla/preconcurrency-isolated-derived-conformance
[Concurrency] Don't skip conformance derivation for types with isolated stored properties.
2024-02-15 13:51:04 -08:00
Doug Gregor
3ecbfcf885 Merge pull request #71637 from apple/ApolloZhu/SE-0422/accepted 2024-02-15 03:57:05 -08:00
Holly Borla
fcc7d0fee0 [Concurrency] Don't skip conformance derivation for types with isolated stored
properties.

Otherwise, types that rely on derived conformances to Equatable and friends will
fail to compile if a library adds a `@preconcurrency @MainActor` annotation. There
is no need to prevent conformance derivation, because the actor isolation checker
still runs on derived witnesses and will diagnose any concurrecy violations (with
appropriate downgrading behavior for `@preconcurrency`).
2024-02-14 22:56:42 -08:00
Meghana Gupta
a9325762b5 Ban explicit lifetime dependence on bitwise copyable type 2024-02-14 21:11:59 -08:00
Meghana Gupta
7ec4ed490f Add Sema diagnostic to ban _copy/_consume lifetime dependence on Escapable types 2024-02-14 19:50:03 -08:00
Meghana Gupta
5bf0a0948d NFC: Remove white spaces in DiagnosticsSema.def 2024-02-14 19:50:03 -08:00
Apollo Zhu
9ccfb574fd Enable SE-0422 Expression macro as caller-side default argument 2024-02-14 19:22:35 -08:00
Michael Gottesman
f3edb5730a [transferring] Add support for transferring results.
rdar://121324697
2024-02-14 14:39:02 -08:00
Michael Gottesman
bf2ec7eb85 [transferring] Change transferring to no longer be a ParamSpecifier.
Instead it is a bit on ParamDecl and SILParameterInfo. I preserve the consuming
behavior by making it so that the type checker changes the ParamSpecifier to
ImplicitlyCopyableConsuming if we have a default param specifier and
transferring is set. NOTE: The user can never write ImplicitlyCopyableConsuming.

NOTE: I had to expand the amount of flags that can be stored in ParamDecl so I
stole bits from TypeRepr and added some logic for packing option bits into
TyRepr and DefaultValue.

rdar://121324715
2024-02-14 13:04:46 -08:00
John McCall
d5142668f4 SIL and IRGen support for @isolated(any). SILGen to come. 2024-02-13 03:04:13 -05:00
Holly Borla
5b0d9c4798 Merge pull request #71536 from hborla/isolated-closure-capture
[Concurrency] Don't allow non-`Sendable`, isolated closures to capture non-`Sendable` values that may be isolated to a different actor.
2024-02-10 10:31:54 -08:00
Holly Borla
b88e74b532 [Concurrency] Don't allow non-Sendable, isolated closures to capture
non-Sendable values that may be isolated to a different actor.
2024-02-09 21:58:50 -08:00
Holly Borla
ef265399bd Merge pull request #71503 from hborla/invalid-isolated-param
[Concurrency] Always diagnose invalid isolated parameter types in type resolution.
2024-02-09 08:59:41 -08:00
Holly Borla
aa99cbc80e [Concurrency] Always diagnose invalid isolated parameter types in type resolution. 2024-02-08 23:15:50 -08:00
Kavon Farvardin
6ca57e332c Merge pull request #71488 from kavon/ncgenerics-test-fixes-kavon-v5
Ncgenerics test fixes kavon v5
2024-02-08 22:32:54 -08:00
nate-chandler
c13422d498 Merge pull request #71479 from nate-chandler/bitwise-copyable/ban-nontrivial-cxx
[BitwiseCopyable] Ban non-trivial C++ types.
2024-02-08 17:52:51 -08:00