Commit Graph

4105 Commits

Author SHA1 Message Date
Pavel Yaskevich
4943e146bd [Frontend] Add experimental flag for @preconcurrency conformances feature 2024-01-16 10:31:01 -08:00
Pavel Yaskevich
574aee0113 [AST] Allow @preconcurrency attribute in inheritance clause 2024-01-16 10:29:47 -08:00
nate-chandler
7dd1d3f7c1 Merge pull request #70872 from nate-chandler/rdar19519745
[BitwiseCopyable] Infer and check constraint.
2024-01-16 07:01:31 -08:00
Nate Chandler
bac9e94a1d [BitwiseCopyable] Infer and check constraint.
When the BitwiseCopyable experimental feature is enabled, infer types to
conform to `_BitwiseCopyable`.  The `_BitwiseCopyable` inference broadly
follows the approach taken to infer `Sendable`.

(1) Special types are conformed:
- function types if trivial
- metatypes
- builtin types if trivial

(2) TheTupleType is conditionally conformed.

(3) Nominal types are conformed if:
- non-public or public+fixed-layout
- enum or struct (non-class)
- every field conforms to _BitwiseCopyable

Additionally, check that nominal types which are explicitly conformed to
`_BitwiseCopyable` satisfy the latter two conditions of (3).

For a public, non-fixed-layout type to conform to `_BitwiseCopyable`,
the user must conform the type explicitly.

Finally, verify that conformances correspond to TypeLowering's notion of
triviality to the appropriate extent:
- if a type isn't trivial, it doesn't conform to `_BitwiseCopyable`
  unless it's an archetype
- if a type is trivial, it conforms to `_BitwiseCopyable` unless some
  field in its layout doesn't conform to `_BitwiseCopyable`, which is
  only permitted under certain circumstances (the type has generic
  parameters, the type is public non-fixed-layout, the type is a
  reference but has ReferenceStorage::Unmanaged, the type is a
  ModuleType, etc.)
2024-01-15 17:08:32 -08:00
Pavel Yaskevich
0cc72fb344 Merge pull request #68889 from Visckmart/throwing_super_init_diagnostics
Fixes throwing super.init() diagnostics
2024-01-13 00:23:12 -08:00
Allan Shortlidge
a3286c59e9 Merge pull request #70784 from tshortli/swift3-no-more
Remove `-enable-swift3-objc-inference`
2024-01-12 17:05:53 -08:00
Pavel Yaskevich
2f9d405dd2 [Sema] NFC: Re-phrase @preconcurrency import warning from "is unused" to "has no effect" 2024-01-12 10:27:54 -08:00
Allan Shortlidge
e5c6bb649c Remove support for Swift 3 @objc inference.
Obsolete the `-enable-swift3-objc-inference` option and related options by
removing support for inferring `@objc` attributes using Swift 3 rules.
Automated migration from Swift 3 has not been supported by the compiler for
many years.
2024-01-11 15:40:04 -08:00
Artem Chikin
aa05a5c0bd Revert "[Dependency Scanning] Use VFS-remapped paths for Clang Module Dependencies' .modulemap files" 2024-01-11 09:43:18 -08:00
Kavon Farvardin
a2defd5367 [NCGenerics] fix AnyObject and inverses
resolves rdar://120512544
2024-01-10 19:37:21 -08:00
Holly Borla
353fb5d242 Merge pull request #70820 from hborla/downgrade-if-switch-effects-errors
[TypeCheckEffects] Stage in new effects checker errors for statement expressions as warnings until Swift 6.
2024-01-10 16:57:58 -08:00
Artem Chikin
e24c9a8182 Merge pull request #70769 from artemcm/RemapClangDepModuleMapPath
[Dependency Scanning] Use VFS-remapped paths for Clang Module Dependencies' `.modulemap` files
2024-01-10 11:40:15 -08:00
Holly Borla
9fc7032be8 [TypeCheckEffects] Redundant effects markers on statement expressions should
be a warning.
2024-01-10 11:27:05 -08:00
Artem Chikin
6c5e884297 [Dependency Scanning] Use VFS-remapped paths for Clang Module Dependencies' .modulemap files
These files are used as an explicit input for the resulting compilation task

Resolves rdar://120554985
2024-01-09 12:46:38 -08:00
Pavel Yaskevich
859106eed1 [Diagnostics] Expand trailing closure failure to handle all closure arguments 2024-01-08 14:09:18 -08:00
Pavel Yaskevich
92577723fb [Diagnostics] Add a tailored note when passing a closure to a non-closure accepting parameter 2024-01-08 14:09:18 -08:00
Sophia Poirier
4abb567fb0 [Concurrency] correct some strict concurrency warnings to be errors in Swift 6 2024-01-05 16:23:48 -08:00
Doug Gregor
26cc99dbc7 Merge pull request #70735 from DougGregor/associated-type-availability
Enable availability attributes for associated types
2024-01-05 16:03:23 -08:00
Doug Gregor
b90177150f Enable availability attributes for associated types
Allow `@available` on associated types, which can be introduced after
the protocol was introduced. These work precisely how on expects,
because all of the infrastructure for introducing associated types
later on has been available for a while, with two small restrictions:

1. If one uses the primary associated type syntax (e.g., `P<A, B>`),
then the primary associated types must also be available in the
current context.
2. Adding a new associated type to a resilient protocol requires that
associated type to have a default.
2024-01-05 10:56:08 -08:00
Allan Shortlidge
c165a2cb78 Sema: Error for potentially unavailable conformances in Swift 6.
Diagnostics about use of potentially unavailable conformances had to be
downgraded to warnings in Swift 5 in order to preserve source compatibility.
These diagnostics should be errors by default in Swift 6.

Resolves rdar://88210812
2024-01-04 17:47:29 -08:00
Doug Gregor
baaa8f3e5b Merge pull request #70677 from DougGregor/se-0413-typed-throws
Enable SE-0413 "Typed Throws" by default
2024-01-04 16:11:26 -08:00
Alexis Laferrière
8efd30ec56 Merge pull request #70675 from xymus/access-level-import-same-file 2024-01-03 12:12:03 -08:00
Alexis Laferrière
73904ec12f Sema: report inconsistent access levels on imports of one module from one file
Warn on imports of the same target module from the same source file when
they have different access-levels. This situation can lead to unexpected
behavior as the compiler will only take into account the most permissive
import.

In the following example, the module Foundation in functionally imported
as public. The `internal` modifier will be ignored. The new diagnostic
reports it as such.

```
public import Foundation
internal import Foundation // warning: module 'Foundation' is imported
as 'public' from the same file; this 'internal' access level will be
ignored
```

This could be an easy mistake to do when using scoped imports where this
diagnostic will also help.

rdar://117855481
2024-01-03 09:04:49 -08:00
Doug Gregor
b9c5aca15f Enable SE-0413 "Typed Throws" by default 2024-01-02 15:34:07 -08:00
Alexis Laferrière
4e8c1ef6fe Merge pull request #70565 from xymus/is-now-a-candidate
Sema: Fix a typo in the error message on broken modularization
2024-01-02 15:02:19 -08:00
Anthony Latsis
d7b52e96c4 Move unqualified init diagnosis from Parse to Sema 2023-12-25 21:17:20 +03:00
Alexis Laferrière
80ea57fd94 Sema: fix typo in error message about broken modularization
rdar://117207904
2023-12-20 10:58:06 -08:00
Holly Borla
85cced7a14 [Concurrency] Diagnose concurrency violations in derived conformances at valid
source locations.
2023-12-20 06:55:10 -08:00
Angela Laar
c1af52c2f2 Merge pull request #70419 from angela-laar/group-actor-isolation-errors
Group actor isolation errors
2023-12-18 08:42:26 -08:00
Andrew Trick
ace9937e95 Rename NonesapableTypes feature
Follow the feature flag convention for capitalization and be
consistent with the related NoncopyableGenerics feature.

This is a new feature that no wild Swift code has used it yet:

commit e99ce1cc5d
Author: Kavon Farvardin <kfarvardin@apple.com>
Date:   Tue Dec 5 23:25:09 2023

    [NCGenerics] add `~Escapable`

    Basic implementation of `~Escapable` in the type system.
2023-12-14 11:32:03 -08:00
Becca Royal-Gordon
e9672194b4 Merge pull request #69468 from beccadax/c-implementation
Make @objcImpl work with @_cdecl
2023-12-14 00:36:12 -08:00
Alexis Laferrière
dda7e96503 Merge pull request #70424 from xymus/ambiguity
AST: Specify the module name in errors on ambiguities across modules
2023-12-13 16:07:41 -08:00
Alexis Laferrière
72083bf7e3 Diagnostics: Specify the module name on ambiguities across modules
When a file defining an API is included in two modules, clients calling
that API may get an error about the ambiguity on the duplicated API.
That error is not very helpful when it takes into account the
swiftsourceinfo data and points to the source file instead of the
module. In such a case the notes point twice to the same file and line
of code.

Improve this diagnostic by appending the module name to the notes when a
candidate is found outside of the module.

rdar://116255141
2023-12-13 11:12:39 -08:00
Becca Royal-Gordon
426e5beb8d Begin checking cdecl implementations
This commit diagnoses cdecl implementations with no matching imported declaration, and also runs them through the ObjCImplementationChecker. Actually testing that the ObjCImplementationChecker diagnoses various failure conditions correctly will be added in a subsequent commit.
2023-12-13 11:09:50 -08:00
Becca Royal-Gordon
8651af4325 Make @objcImpl work with @_cdecl
No real diagnostics yet, but we’re emitting mostly correct code.
2023-12-13 11:09:49 -08:00
Angela Laar
4d2b01b0be Group Actor Isolation errors
The number of errors in a function scope can scale exponentially,
making it hard to root cause and resolve unless we group them into
a single error. Grouping the error diagnostics will considerably
improve the concurrency user experience.
2023-12-12 16:23:10 -08:00
Kavon Farvardin
e99ce1cc5d [NCGenerics] add ~Escapable
Basic implementation of `~Escapable` in the type system.

rdar://119216918
2023-12-10 01:25:43 -08:00
Pavel Yaskevich
b0d4ba01bd Merge pull request #70285 from xedin/keypath-with-global-actors
[Concurrency] Key paths and global actors
2023-12-08 09:56:36 -08:00
Kavon Farvardin
338d426b3d Merge pull request #70278 from kavon/refactor-InverseType
[NCGenerics] fold InverseType into PCT
2023-12-08 02:44:45 -08:00
Kavon Farvardin
63b3e7624d [NCGenerics] fold InverseType into PCT
We already need to track the inverses separate from the members in a
ProtocolCompositionType, since inverses aren't real types. Thus, the
only purpose being served by InverseType is to be eliminated by
RequirementLowering when it appears in a conformance requirement.

Instead, we introduce separate type InverseRequirement just to keep
track of which inverses we encounter to facilitate cancelling-out
defaults and ensuring that the inverses are respected after running
the RequirementMachine.
2023-12-07 22:14:23 -08:00
Sima Nerush
b6d0afba1f Merge pull request #67594 from simanerush/simanerush/pack-iteration-impl
[SE-0408] Enable Pack Iteration
2023-12-07 17:09:48 -08:00
Pavel Yaskevich
e561ac4966 [Concurrency] Print full isolation information when diagnosing key path components 2023-12-07 15:41:37 -08:00
Sima Nerush
23485990e5 Diagnose that where clause is not supported 2023-12-03 21:51:41 -08:00
Sima Nerush
b0af0f762d Update diagnostics 2023-12-03 21:51:40 -08:00
Zhiyu Zhu/朱智语
9d1a92eb72 [Compile Time Constant Extraction] Add @extractConstantsFromMembers (#69944)
Add @extractConstantsFromMembers attribute under ExtractConstantsFromMembers experimental feature flag
2023-11-29 08:49:57 -08:00
Konrad `ktoso` Malawski
1aa12bb25f remove not used anymore custom diagnostic 2023-11-29 14:48:11 +09:00
Konrad `ktoso` Malawski
29982fcc51 Add fixits for distributed system adhoc requirements; make easier to adopt
rdar://114185115
2023-11-29 14:48:10 +09:00
Pavel Yaskevich
bd4ee4681b Merge pull request #70007 from xedin/keypath-application-improvements
[ConstraintSystem] Modernization of key path application handling
2023-11-28 12:44:42 -08:00
Slava Pestov
f89b9817e7 Merge pull request #69950 from slavapestov/clean-up-open-existentials
Cleanups and fixes for opened existentials
2023-11-28 10:45:19 -05:00
Alejandro Alonso
e214ba5092 Merge pull request #69735 from Azoy/static-exclusive-only
Introduce @_staticExclusiveOnly
2023-11-27 21:24:56 -08:00