Commit Graph

4105 Commits

Author SHA1 Message Date
Nate Chandler
ba467d2bd2 [Sema] Enable suppression of inferred conformances.
Add the machinery to support suppression of inference of conformance to
protocols that would otherwise be derived automatically.

This commit does not enable any conformances to be suppressed.
2024-04-15 16:46:22 -07:00
Pavel Yaskevich
3a0acf8043 [AST/Sema] Decouple @preconcurrency conformances from DynamicActorIsolation feature flag 2024-04-14 21:28:13 -07:00
Konrad `ktoso` Malawski
54229549b3 [Distributed] Offer fixit for import Distributed when it is required (#72948) 2024-04-12 18:05:32 -07:00
Kavon Farvardin
179bc4b605 Merge pull request #72820 from kavon/conditional-copyable-restriction
NCGenerics: restrict conditional Copyable reqs
2024-04-09 17:56:34 -07:00
Kavon Farvardin
0ce97b8503 Diagnostics: noformat modifier for Type
Sometimes, quotes or an "aka" for a type are not desirable in a
diagnostic, such as one describing a Requirement. This modifier
suppresses such additional formatting a Type in a diagnostic.
2024-04-09 13:51:57 -07:00
Meghana Gupta
4b440a1d80 Merge pull request #72916 from meg-gupta/lifetimedepreq
Requestify LifetimeDependenceInfo
2024-04-09 11:28:18 -07:00
eeckstein
648705e524 Merge pull request #72850 from eeckstein/sensitive
Add the experimental attribute `@sensitive` for struct declarations
2024-04-09 15:46:22 +02:00
Erik Eckstein
a980452e59 Add the experimental attribute @sensitive for struct declarations
The attribute declares that a struct contains "sensitive" data.
It enforces that the contents of such a struct value is zeroed out at the end of its lifetime.
In other words: the content of such a value is not observable in memory after the value's lifetime.

Also add an experimental feature `Sensitive` with which the attribute can be enabled.
2024-04-09 12:01:10 +02:00
Konrad `ktoso` Malawski
7cd9063ba5 [Distributed] Diagnose missing import also for funcs in extensions
Resolves rdar://125813581
2024-04-09 17:08:27 +09:00
Meghana Gupta
c8c1f17821 Update lifetime dependence diagnostic message 2024-04-08 22:33:32 -07:00
Kuba (Brecka) Mracek
70afeef480 Merge pull request #70944 from kubamracek/volatile
Add experimental _Volatile module providing low-level primitives for MMIO
2024-04-05 23:42:27 -07:00
Steven Wu
109c85e00b Merge pull request #72291 from cachemeifyoucan/eng/PR-123711823
[ScanDependency] Move binary module validation into scanner
2024-04-05 15:53:53 -07:00
Kuba Mracek
7d44c2be48 [Volatile] Add a -enable-experimental-feature Volatile 2024-04-05 15:13:30 -07:00
nate-chandler
d0ba8fdf46 Merge pull request #72856 from nate-chandler/rdar125934050
[BitwiseCopyable] Remove bespoke diagnostic.
2024-04-05 09:23:12 -07:00
Steven Wu
d4c90d6eeb [DependencyScanning] Handle testable dependencies correctly
Teach scanner to pick and choose binary modules correctly based on if it
is testable import or not. Some situations that scanner need to be
careful when testable is involved:

* When it is a regular import, it should not import binary modules that
  are built with -enable-testing, it should prefer interfaces if that is
  available.
* When testable import, it should only load binary module and it should
  make sure the internal imports from binary modules are actually
  required for testable import to work.

If a testable import only find a regular binary module, dependency
scanner currently will just preceed with such module and leave the
diagnostics to swift-frontend, because the alternative (failed to find
module) can be confusing to users.

rdar://125914165
2024-04-05 07:52:16 -07:00
Nate Chandler
6d57eab931 [BitwiseCopyable] Remove bespoke diagnostic.
Remove a diagnostic about conforming to Copyable now that a standard one
is emitted.

Also reenable the Sema/bitwise_copyable.swift test.

rdar://125934050
2024-04-04 15:24:07 -07:00
Kavon Farvardin
215c4e1c25 NCGenerics: restrict conditional Copyable reqs
It doesn't really make sense for a conditional conformance requirement
for `Copyable` to depend on any other requirement other than other
`Copyable` conformance requirements.

resolves rdar://124967739
2024-04-04 14:20:28 -07:00
Doug Gregor
61b19c8fbf Merge branch 'main' into import-extension-visibility 2024-04-03 21:43:21 -07:00
Kavon Farvardin
30983530b6 NCGenerics: introduce SuppressedAssociatedTypes
The model for associated types hasn't been fully worked-out for
noncopyable generics, but there is some support already that is being
used by the stdlib for an internal-only (and rather cursed) protocol
`_Pointer` to support `UnsafePointer`, etc.

This patch gates the existing experimental support for associated types
behind a feature flag. This flag doesn't emit feature-guards in
interfaces, since support for it is tied closely to NoncopyableGenerics
and has been there from its early days.
2024-04-02 16:53:36 -07:00
Doug Gregor
bd696f9c05 Enable failable initializers for noncopyable types
Noncopyable types were prevented from having failable initializers
because `Optional` itself didn't support noncopyable types. Now
`Optional` does, so lift this restriction and add a test.
2024-04-01 17:29:41 -07:00
Doug Gregor
533a744623 Parse suppressed-conformance constraints in expressions and validate them
Ensure that we're properly parsing suppressed-conformance constraints
in expression contents and in metatypes. This allows types like `any
~Copyable` in expression context as well as types like `any
~Copyable.Type`.

While we're here, ensure that existentials that involve
suppressed-conformance constraints are spelled with `any`.

Fixes rdar://123728228.
2024-04-01 14:32:40 -07:00
Becca Royal-Gordon
576a4bac36 Merge pull request #72596 from beccadax/objcimpl-real-name
Add @implementation and feature flags for objcImpl
2024-03-28 23:48:24 -07:00
Meghana Gupta
4a0f3809af Merge pull request #72684 from meg-gupta/fixlifetimedemangling
Fix lifetime dependence demangling and add a new Sema diagnostic
2024-03-28 22:43:49 -07:00
Rintaro Ishizaki
8c67d15a32 Merge pull request #72550 from fummicc1/diagnostics-init-msg-improvement
[AST] Improve diagnostic message about `constructor` expression
2024-03-28 15:51:46 -07:00
Meghana Gupta
5356dc9a53 Add Sema diagnostic when we cant infer lifetime dependence on a method because self is BitwiseCopyable & Escapable 2024-03-28 15:15:25 -07:00
Becca Royal-Gordon
858b557762 Tweak @_objcImpl deprecation warning behavior
• Simpler wording
• Now emitted only if there are no other @objcImpl diagnostics (so @implementation would not emit any new errors)
2024-03-27 17:47:22 -07:00
Becca Royal-Gordon
29b5a92335 Warn that @objcImpl extension is deprecated
…only when the ObjCImplementation experimental language feature is enabled. (`@implementation extension` is the preferred form.)
2024-03-27 14:29:57 -07:00
Becca Royal-Gordon
d8f440ee80 Add @implementation as alias for @_objcImpl
They will eventually have slightly different deprecation status and error behavior, but not yet.

Fixes rdar://110728033.
2024-03-27 14:29:23 -07:00
Pavel Yaskevich
ede7df67fc Merge pull request #72558 from xedin/improve-diag-for-same-type-req-in-opaque
[CSDiagnostics] Add a diagnostic for same-type/supertype requirement failures in…
2024-03-27 09:58:25 -07:00
Meghana Gupta
11d5179587 Allow lifetime dependence inference on implicit initializers 2024-03-26 21:51:50 -07:00
fummicc1
4dda7efc0f [AST] Improve diagnostics message for swift users.
Use `initializer` instead of `constructor` because it is more official word to express its meaning.
2024-03-27 12:32:25 +09:00
Meghana Gupta
a77b1e0b23 Update some lifetime dependence diagnostic messages 2024-03-26 14:56:56 -07:00
Pavel Yaskevich
25ce6604cd [CSDiagnostics] Add a diagnostic for superclass requirement failure in opaque return type 2024-03-26 12:07:14 -07:00
Pavel Yaskevich
08e93825d2 [CSDiagnostics] Add a diagnostic for same-type requirement failure in opaque return type
Follow-up to https://github.com/apple/swift/pull/72493
2024-03-26 11:11:30 -07:00
Meghana Gupta
b5ca933002 Update lifetime dependence syntax and inference as per changes in the pitch
Pitch - https://github.com/apple/swift-evolution/pull/2305

Changes highlights:

dependsOn(paramName) and dependsOn(scoped argName) syntax

dependsOn(paramName) -> copy lifetime dependence for all parameters/self except
                         when we have Escapable parameters/self, we assign scope
                         lifetime dependence.

Allow lifetime dependence on parameters without ownership modifier.

Always infer copy lifetime dependence except when we have
Escapable parameters/self, we infer scope lifetime dependence.

Allow lifetime dependence inference on parameters without ownership modifier.
2024-03-23 18:19:47 -07:00
Alexis Laferrière
42991a5232 Merge pull request #72460 from xymus/deser-space-fix
Serialization: fix extra space in diagnostic
2024-03-21 13:16:48 -07:00
Alexis Laferrière
ba25c4c57f Serialization: fix extra space in diagnostic 2024-03-20 10:20:52 -07:00
Alexis Laferrière
23628fda41 Merge pull request #72439 from xymus/diag-type-mismatch
Serialization: note mismatching types when it causes a deserialization failure
2024-03-20 09:39:49 -07:00
Alexis Laferrière
cef635619a Serialization: report type mismatch when it causes a deserialization failure
Deserialization may fail if a decl in a dependency changed type between the
time a swiftmodule was built and when it was imported. This can happen because
of changes to the SDK or use of C preprocessor macros. To help understand these
problems, note the specific types causing the mismatch when it leads to a
deserialization failure.

```
.../LibWithXRef.swiftmodule:1:1: error: reference to top-level
declaration 'foo' broken by a context change; the declaration kind of
'foo' from 'A' changed since building 'LibWithXRef'
1 │ A.foo
│ │ ├─ ...
│ ├─ note: a candidate was filtered out because of a type mismatch;
expected: '() -> ()', found: '(Int) -> Float'
```
2024-03-19 18:31:11 -07:00
Holly Borla
ee197aea4a Merge pull request #72078 from simanerush/redundant-nonisolated-unsafe
[Concurrency] Diagnose a redundant `nonisolated(unsafe)`
2024-03-16 15:34:31 -07:00
Kavon Farvardin
149c052ec5 use new noncopyable types infrastructure
The infrastructure underpinning the new feature NoncopyableGenerics is
mature enough to be used.
2024-03-14 23:10:44 -07:00
Sima Nerush
a5eff6b69e [Concurrency] Diagnose redundant nonisolated(unsafe) for an actor-isolated Sendable immutable storage. 2024-03-12 22:19:53 -07:00
Sima Nerush
e2f9267012 [Concurrency] Diagnose redundant (unsafe) for a public actor-isolated Sendable immutable storage. 2024-03-12 22:19:53 -07:00
Sima Nerush
9fc5b7ecb1 [Concurrency] Diagnose redundant nonisolated(unsafe) for a Sendable immutable storage. 2024-03-12 22:19:48 -07:00
Kavon Farvardin
8dba0f6a01 Merge pull request #72240 from kavon/ncgenerics-xfails-1
Sema: replace legacy Copyable containment check (NCGenerics XFAILs)
2024-03-12 14:23:36 -07:00
Kavon Farvardin
01864d9af4 Sema: replace legacy Copyable containment check
We can use part of the new infrastructure if we simply handle abstract
conformances to Copyable, which is what we'd get upon lookup for a
nominal in the old world. This means that we can merge diagnostics for
the containment test together, and fix differences with deinit
diagnostics.
2024-03-12 11:05:25 -07:00
Kuba (Brecka) Mracek
bc18637a69 Merge pull request #72135 from kubamracek/embedded-weak-unowned
[embedded] Diagnose usage of weak and unowned variables in embedded Swift
2024-03-12 09:50:11 -07:00
Slava Pestov
7cee7e9e43 Merge pull request #72164 from slavapestov/ncgenerics-fixes-10
Non-copyable generics fixes, part 10
2024-03-12 10:04:13 -04:00
Slava Pestov
3a4d831e52 AST: Fix crash-on-invalid when writing ~ followed by a non-protocol
Also reword some diagnostics. We don't want to talk about 'invert' or
'inverse'.
2024-03-11 14:36:21 -04:00
Holly Borla
d3ed4a40e8 Merge pull request #72214 from hborla/isolated-struct-properties
[Concurrency] Allow struct members to have isolation annotations.
2024-03-09 17:30:19 -08:00