Commit Graph

464 Commits

Author SHA1 Message Date
Joe Groff
b4f536927a Disable destructuring initializations in struct let stored properties.
This looks like it was never properly implemented, since when we generate the
memberwise initializer for the struct in SILGen, it incorrectly tries to apply
the entire initializer expression to each variable binding in the pattern,
rather than destructuring the result and pattern-matching it to the variables.
Since it never worked it doesn't look like anyone is using this, so let's
put up an error saying it's unsupported until we can implement it properly.
Add `StructLetDestructuring` as an experimental feature flag so that tests around
the feature for things like module interface printing can still work.
2023-10-03 13:24:39 -07:00
Doug Gregor
51eed19d4b [Typed throws] Type system support for typed throws.
Add the thrown type into the AST representation of function types,
mapping from function type representations and declarations into the
appropriate thrown type. Add tests for serialization, printing, and
basic equivalence of function types that have thrown errors.
2023-09-29 10:51:53 -07:00
Kavon Farvardin
68ae729584 _Copyable as a Requirement Against the Machine
An initial implementation of a rework in how
we prevent noncopyable types from being
substituted in places they are not permitted.

Instead of generating a constraint for every
generic parameter in the solver, we produce
real Copyable conformance requirements. This
is much better for our longer-term goal of
supporting `~Copyable` in more places.
2023-09-19 16:35:17 -07:00
zoecarver
52cea4250e [embedded] 🚀 add Embedded expiremental feature.
Optimize all functions in embedded mode. Diagnose any uses of existentials or witness tables.
2023-09-06 10:48:17 -07:00
Hamish Knight
6ee44f09b4 Introduce then statements
These allow multi-statement `if`/`switch` expression
branches that can produce a value at the end by
saying `then <expr>`. This is gated behind
`-enable-experimental-feature ThenStatements`
pending evolution discussion.
2023-09-01 14:32:14 +01:00
Sophia Poirier
aec59f2f9c Merge pull request #67974 from sophiapoirier/global-static-data-race-safety
enforce under strict concurrency that globals and statics be either…
2023-08-19 08:28:02 -07:00
Sophia Poirier
936ab20e5d enforce under strict concurrency that globals and statics be either isolated to a global actor or Sendable plus immutable
rdar://81629027 Global and static variable data-race safety
2023-08-18 15:08:42 -07:00
zachary0kent
25f078adb5 Merge branch 'main' into lazy-immediate 2023-08-16 19:45:27 -07:00
Pavel Yaskevich
ae37df58e5 [Frontend] NFC: Remove experimental flag for runtime discoverable attributes feature 2023-08-15 12:17:31 -07:00
Zak Kent
289b812a14 [Immediate] Add frontend option for lazy compilation 2023-08-14 13:28:22 -07:00
Pavel Yaskevich
bb135181bd Merge pull request #67625 from xedin/enable-init-accessors-feature
[Frontend/NFC] SE-0400: Enable `InitAccessors` feature by default
2023-08-01 15:54:43 -07:00
Holly Borla
4b09d4c513 [Macros] Add back the ExtensionMacro feature identifier as a language feature
that can be used in swiftinterfaces.
2023-07-31 13:39:13 -07:00
Pavel Yaskevich
2a0651e8b0 [Frontend/NFC] SE-0400: Enable InitAccessors feature by default 2023-07-31 13:18:59 -07:00
Joshua Turcotti
2eade1d1b5 Merge pull request #67511 from JTurcotti/tweaks
[SendNonSendable] Assorted Bugfixes and Tweaks
2023-07-28 09:24:36 -07:00
jturcotti
bb2f3c011e rename DeferredSendableChecking pass to SendNonSendable pass, handle more instructions such as try_apply and begin_apply, and fix bugs 2023-07-27 16:45:29 -07:00
Joe Groff
aee071bf4e Introduce an experimental @_rawLayout attribute.
This attribute can be attached to a noncopyable struct to specify that its
storage is raw, meaning the type definition is (with some limitations)
able to do as it pleases with the storage. This provides a basis for
implementing types for things like atomics, locks, and data structures
that use inline storage to store conditionally-initialized values.
The example in `test/Prototypes/UnfairLock.swift` demonstrates the use
of a raw layout type to wrap Darwin's `os_unfair_lock` APIs, allowing
a lock value to be stored inside of classes or other types without
needing a separate allocation, and using the borrow model to enforce
safe access to lock-guarded storage.
2023-07-24 14:28:19 -07:00
Holly Borla
f76783d619 Merge pull request #67405 from hborla/enable-extension-macros
[Macros] Remove the `ExtensionMacros` experimental feature flag.
2023-07-19 17:59:21 -07:00
Zoe Carver
7db5fe11ad Merge pull request #67296 from zoecarver/only-methods-on-self-contained-types-are-unsafe
[cxx-interop] Only mark projections of self-contained types as unsafe.
2023-07-19 14:18:46 -07:00
Holly Borla
178604e8bc [Features] Remove the experimental ExtensionMacros feature identifier. 2023-07-19 08:17:28 -07:00
Doug Gregor
f03ad115a2 [SE-0401] Rename DisableActorInferenceFromPropertyWrapperUsage to DisableOutwardActorInference 2023-07-18 23:49:58 -07:00
zoecarver
782641af68 [cxx-interop] ExpirementalFeature -> LanguageFeature. 2023-07-18 17:42:35 -07:00
zoecarver
2115f7aaf8 [cxx-interop] Add NewCxxMethodSafetyHeuristics feature and guard swift compiler sources changes on it. 2023-07-18 17:42:34 -07:00
Anders Bertelrud
d6e0ca3544 [PlaygroundTransform] Add experimental feature PlaygroundExtendedCallbacks to pass more info in callbacks (#67215)
* Add experimental feature `PlaygroundExtendedCallbacks` which passes more information in `-playground` callbacks

Adds the experimental feature `PlaygroundExtendedCallbacks` which (when `-playground` is also passed) causes the playground transform to use alternate forms of the result-value, scope-entry, and scope-exit callbacks that include the module name and file path of the source file.

The previous callbacks included integers for the module number and file number, but this was cumbersome to use because it required the caller to create source symbols with magical names formed from the module name and file path that the playground transform knew how to look up.

The extended callbacks in the experimental feature instead pass these strings as string literals. This is an experimental feature because of the need to measure the performance impact, and because of the need to provide an option to control which set of callbacks to use so that existing clients of the playground transform can opt into it when ready. It's also likely that we'll want to pass more information in the extended callbacks, such as an indication of the kind of result is being logged (e.g. a loop iteration variable vs a return statement vs a variable assignment). So this should be considered the first of a series of experimental improvements that will then be pitched as an actual, non-experimental v2.0 of the playground transform callback API. Because of the nature of how the playground transform is used, it's much easier to iterate on the functionality in the form of an experimental feature rather than using only desktop debug builds of the Swift compiler.

Changes:
- define a new experimental feature called `PlaygroundExtendedCallbacks`
- modify the playground transform step in sema to pass the module name and file name literals when the experimental feature is set
- add a unit test for the extended callbacks

There is no change in behaviour when `PlaygroundExtendedCallbacks` is not enabled.

rdar://109911742

Co-authored-by: Brent Shank <bshank@apple.com>
2023-07-18 11:55:26 -07:00
Michael Gottesman
c3df53e4ec [reference-bindings] Compile in ReferenceBindings in non-asserts builds.
Just to fix the bots.

rdar://112230433
2023-07-13 16:26:59 -07:00
Holly Borla
ff8e3dfef3 [Features] Allow ExtensionMacros to be enabled in noasserts builds. 2023-07-10 16:37:54 -07:00
jturcotti
aa9f1a3584 add an experimental feature DeferSendableChecking to defer the sendable checking of some sites. For now, only diagnostics corresponding to non-sendable arguments passed to calls with unsatisfied isolation are deferred. A SIL pass SendNonSendable is added to emit the deferred diagnostics, and ApplyExpr is appropriately enriched to make that deferral possible. 2023-07-03 09:52:11 -07:00
Holly Borla
b28cdb030e [Macros] Make code item macros unavailable in noasserts builds. 2023-06-30 23:16:48 -07:00
Holly Borla
7a46466b65 Merge pull request #66967 from hborla/extension-macro
[Macros] Generalize `conformance` macros as `extension` macros
2023-06-29 08:57:04 -07:00
Doug Gregor
e240ec5eb4 Merge pull request #66991 from DougGregor/experimental-feature-strict-concurrency 2023-06-28 15:07:59 -07:00
Holly Borla
81a1f64811 [Macros] Allow @attached(extension) attributes to be suppressed in
module interfaces.
2023-06-28 14:53:16 -07:00
Gwynne Raskind
5ab86d969c Add StrictConcurrency as an always-enabled experimental feature
Upcoming and experimental features are supported via command-line flags
and also in the SwiftPM manifest. Introduce it as an experimental
feature so that it can be enabled via SwiftPM without having to resort
to unsafe flags.

The `StrictConcurrency` experimental feature can also provide a
strictness level in the same manner as `-strict-concurrency`, e.g.,
`StrictConcurrency=targeted`. If the level is not provided, it'll be
`complete`.

Note that we do not introduce this as an "upcoming" feature, because
upcoming features should be in their final "Swift 6" form before
becoming available. We are still tuning the checking for concurrency.
2023-06-28 12:06:17 -07:00
Michael Gottesman
bd90e310e1 Merge pull request #66952 from gottesmm/pr-87fcc78991b465d8a15454dc76b66d6f347ddff0
[move-only] Emit an error if we /ever/ partially consume a noncopyable type.
2023-06-28 01:00:40 -07:00
Holly Borla
725374e0d8 [Macros] Implement attached extension macros. 2023-06-27 21:22:12 -07:00
Doug Gregor
4024b6eee2 Add SE number to upcoming feature for disabling actor inference from property wrappers 2023-06-27 15:16:22 -07:00
Doug Gregor
7bc5e93251 Merge branch 'main' into disable-property-wrapper-based-isolation 2023-06-27 15:15:14 -07:00
Michael Gottesman
3dde9df468 [move-only] Emit an error if we /ever/ partially consume a noncopyable type.
The reason why I am doing this is that this was not part of the original
evolution proposal (it was called an extension) and after some discussion it was
realized that partial consumption would benefit from discussion on the forums.

rdar://111353459
2023-06-27 13:52:49 -07:00
Michael Gottesman
d0938a906f [move-only] Ban resilient noncopyable types.
One can still in resilient frameworks have noncopyable frozen types.

This means that one cannot make a noncopyable:

1. Full resilient public type.
2. @usableFromInline type.

NOTE: One can still use a frozen noncopyable type as a usableFromInline class
field. I validated in the attached tests that we get the correct code
generation.

I also eliminated a small bug in TypeCheckDeclPrimary where we weren't using a
requestified attr check and instead were checking directly.

rdar://111125845
2023-06-21 16:57:44 -07:00
Holly Borla
3dc470f5f4 [Features] Add an experimental feature flag for init accessors. 2023-06-06 18:57:31 -07:00
Slava Pestov
ef466ca9d0 Basic: Remove VariadicGenerics feature 2023-05-31 23:41:23 -04:00
Kuba (Brecka) Mracek
2d5f33e2e3 Add @_used and @_section attributes for global variables and top-level functions (#65901)
* Add @_used and @_section attributes for global variables and top-level functions

This adds:
- @_used attribute that flags as a global variable or a top-level function as
  "do not dead-strip" via llvm.used, roughly the equivalent of
  __attribute__((used)) in C/C++.
- @_section("...") attribute that places a global variable or a top-level
  function into a section with that name, roughly the equivalent of
  __attribute__((section("..."))) in C/C++.
2023-05-26 14:02:32 -07:00
Doug Gregor
22c987e43f Merge pull request #66093 from DougGregor/se-0397-enable-by-default 2023-05-24 18:55:39 -07:00
Doug Gregor
c5ccf1112d Merge pull request #66033 from DougGregor/parse-types-via-astgen
[ASTGen] Add experimental feature to use ASTGen in lieu of parsing types
2023-05-24 13:23:50 -07:00
Doug Gregor
cfda29ccd4 [SE-0397] Enable freestanding declaration macros by default.
This proposal has been accepted. Move the feature flag from "experimental"
to "always enabled". Tracked by rdar://108637367.
2023-05-24 09:16:55 -07:00
Dario Rexin
2bb08e37f6 [ModuleInterface] Add mechanism to exclude experimental flags from th… (#66088)
* [ModuleInterface] Add mechanism to exclude experimental flags from the module interface

rdar://109722548

* Separate filtered flags from the typical/unfiltered case
2023-05-24 09:03:01 -07:00
Doug Gregor
dba94bdbd4 [ASTGen] Add experimental feature to use ASTGen in lieu of parsing types
Introduce a new experimental feature `ASTGenTypes` that uses ASTGen to
translate the Swift syntax tree (produced by the new Swift parser)
into C++ `TypeRepr` nodes instead of having the C++ parser create the
nodes.

The approach here is to intercept the C++ parser's `parseType`
operation to find the Swift syntax node at the given position (where
the lexer currently is) and have ASTGen translate that into the
corresponding C++ AST node. Then, we spin the lexer forward to the
token immediately following the end of the syntax node and continue
parsing.
2023-05-22 21:39:59 -07:00
Nate Chandler
b72395814b [AST] Added language feature for @_eagerMove.
The new LexicalLifetimes suppressible language feature results in
declarations annotated with @_eagerMove, @_noEagerMove, and
@_lexicalLifetimes to be printed with that attribute when it's available
and without it when it's not.
2023-05-10 18:19:49 -07:00
Allan Shortlidge
ffaa1d5dbc Revert "[Macros] Treat FreestandingExpressionMacros as a suppressible feature"
This reverts commit b412c6c884.

Resolves rdar://108591384
2023-05-01 19:44:39 -07:00
BJ Homer
3e2d614c07 Merge branch 'main' into disable-property-wrapper-based-isolation 2023-05-01 08:39:12 -06:00
Joe Groff
8ea5ab84d3 Merge pull request #65173 from jckarter/noncopyable-tuples-not-supported
Diagnose attempts to use tuples with noncopyable elements.
2023-04-17 10:49:53 -07:00
Holly Borla
336da919fe [Features] Add a dedicated experimental feature flag for tuple conformances. 2023-04-15 17:23:25 -07:00