Commit Graph

464 Commits

Author SHA1 Message Date
Ellie Shin
951e2abdea Create features mapped to package optimization flags to
allow a more standard way to pass experimental features
from build systems. Also moved other flags relevant to
diagnostics from Frontend options to Lang options.

Ref: rdar://124648653
2024-03-15 14:18:33 -07:00
Sophia Poirier
95abb73e1a Merge pull request #72175 from sophiapoirier/explicitly-nonisolated-closure
[Concurrency] explicit nonisolated specification for closures
2024-03-14 17:17:00 -07:00
Sophia Poirier
5ce7be7e75 [Concurrency] explicit nonisolated specification for closures 2024-03-14 12:24:13 -07:00
Holly Borla
70d998a1bb [Concurrency] Make OptionalIsolatedParameters a conditionally suppressible
language feature, and suppress it for `Clock.measure`.

This allows the _Concurrency swiftinterface file to continue building with
compilers that do not support `OptionalIsolatedParameters`. The feature
suppression drops the `isolated` keyword and replaces `#isolation` with
`nil`.
2024-03-12 22:56:16 -07:00
Holly Borla
49bf81b21b Merge pull request #72241 from hborla/opaque-type-erasure-swiftinterface
[ModuleInterface] Print `-enable-experimental-opaque-type-erasure` in swiftinterface files.
2024-03-11 21:59:42 -07:00
Holly Borla
8292c677be [ModuleInterface] Print -enable-experimental-opaque-type-erasure in
swiftinterface files.
2024-03-11 15:24:55 -07:00
Doug Gregor
5bdd4e5772 Improve @_implements for associated type witnesses
Allow `@_implements` to be expressed in an extension of the protocol in
which the associated type is defined. Use this to uncomment an
intended use of `@_implements` in `Sequence` that could be used to
replace a longstanding hack for associated type inference.

Since this change means that the standard library module interface
won't be accepted by older compilers, introduce a suppressible feature
ssociatedTypeImplements` that covers the use of `@_implements` on type
declarations. This will hide the `@_implements` attribute from older
compilers.
2024-03-11 14:28:20 -07:00
John McCall
02ddc292da Add Builtin.createTask and Builtin.createDiscardingTask. 2024-03-06 23:50:46 -05:00
Michael Gottesman
99e3f7fb13 [region-isolation] Make RegionBasedIsolation an upcoming feature for swift 6.
To make the tests pass, I had to teach sil-opt how to setup upcoming features
since it did not know how to parse them.

rdar://124100266
2024-03-05 15:15:14 -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
Allan Shortlidge
ba9b3023e0 AST: Make $UnavailableFromAsync and $NoAsyncAvailability baseline features.
They have been available since at least Swift 5.8.
2024-03-02 23:15:41 -08:00
Allan Shortlidge
d5e3e9418d AST: Make $UnsafeInheritExecutor a baseline feature.
It has been available since at least Swift 5.8.
2024-03-02 23:15:41 -08:00
Allan Shortlidge
969efc8413 AST: Add several language features to the baseline feature set.
This allows us to remove their explicit `UNINTERESTING_FEATURE` entries for
them FeatureSet.cpp. All of these features have been present in the compiler
since at least Swift 5.8.

NFC.
2024-03-02 23:15:41 -08:00
John McCall
a68adb913e Merge pull request #72008 from rjmccall/isolated-any-feature-suppression
Allow declarations to opt in to suppressing `@isolated(any)` instead of suppressing the entire declaration
2024-03-02 03:07:20 -05:00
John McCall
fc538f32fb Allow declarations to opt in to suppressing @isolated(any). 2024-03-01 22:10:15 -05:00
John McCall
1437acdf22 Implement conditional feature suppression.
Our standard conception of suppressible features assumes we should
always suppress the feature if the compiler doesn't support it.
This presumes that there's no harm in suppressing the feature, and
that's a fine assumption for features that are just adding information
or suppressing new diagnostics.  Features that are semantically
relevant, maybe even ABI-breaking, are not a good fit for this,
and so instead of reprinting the decl with the feature suppressed,
we just have to hide the decl entirely.  The missing middle here
is that it's sometimes useful to be able to adopt a type change
to an existing declaration, and we'd like older compilers to be
able to use the older version of the declaration.  Making a type
change this way is, of course, only really acceptable for
@_alwaysEmitIntoClient declarations; but those represent quite a
few declarations that we'd like to be able to refine the types of.

Rather than trying to come up with heuristics based on
@_alwaysEmitIntoClient or other sources of information, this design
just requires the declaration to opt in with a new attribute,
@_allowFeatureSuppress.  When a declaration opts in to suppression
for a conditionally-suppressible feature, the printer uses the
suppression serially-print-with-downgraded-options approach;
otherwise it uses the print-only-if-feature-is-available approach.
2024-03-01 22:10:14 -05:00
Doug Gregor
11715054e1 Move FullTypedThrows from "upcoming" to "experimental"
This feature is not fully implemented, and cannot be considered to be
"upcoming" until it is.
2024-03-01 12:24:19 -08:00
Doug Gregor
6075de1b62 Add upcoming feature ImplicitOpenExistentials for SE-0352
To maintain source compatibility, SE-0352 does not open existentials
with "self-conforming" type, such as `any Error` or existentials based
on `@objc` protocols. The proposal specified that this behavior would
change in Swift 6. Implement that behavior change, which can be
enabled prior to Swift 6 with the upcoming feature
`ImplicitOpenExistentials` (as documented in SE-0362).

Fixes #70873 / rdar://120902975.
2024-03-01 11:50:39 -08:00
Doug Gregor
c96a89b2f2 Introduce a suppressible feature for async sequences Failure type
Suppressing this feature doesn't disable the use of new syntax in the
normal way. Instead, it introduces `@rethrows` on the
AsyncIteratorProtocol and AsyncSequence protocols, so that older
compilers can still use the async sequences generated by newer
compilers and standard libraries.

Fixes the rest of rdar://123782658
2024-02-29 11:49:26 -08:00
Doug Gregor
d1ac903be4 Introduce a suppressible feature for availability on associated types
This allows us to emit Swift interfaces that can be handled by older
Swift compilers.
2024-02-29 10:09:08 -08:00
Holly Borla
59507ba361 [Concurrency] Add an API for extracting the isolation of a dynamically isolated
function value.
2024-02-26 17:59:27 -08:00
Nate Chandler
1906b28f2b Add missing guard around new builtin.
Avoid a condfail.
2024-02-19 16:04:29 -08:00
Holly Borla
26621b804c [Concurrency] Enable optional isolated parameters. 2024-02-16 16:28:45 -08:00
Doug Gregor
3ecbfcf885 Merge pull request #71637 from apple/ApolloZhu/SE-0422/accepted 2024-02-15 03:57:05 -08:00
Doug Gregor
dba0a4087f Macro-metaprogram "baseline" features that all Swift compilers handle
This is better than a pile of usesXXXFeature() functions that return
`false` with no explanation.
2024-02-14 21:53:53 -08:00
Apollo Zhu
9ccfb574fd Enable SE-0422 Expression macro as caller-side default argument 2024-02-14 19:22:35 -08:00
Doug Gregor
81ffafdc6a Merge pull request #70602 from ApolloZhu/macro/expression-as-default-argument
[Macros] Expression macro as caller-side default argument
2024-02-14 16:10:11 -08:00
Holly Borla
56c2b34071 [Features] Rename the BuiltinBuildTaskExecutor feature guard.
The name of the `TaskExecutor` protocol was recently changed to remove
underscores after the feature was accepted in Swift Evolution. An implication
of that rename is that the `buildOrdinaryTaskExecutorRef` builtin changed
the type that it expected as the argument. However, the original change
landed in the standard library which as since produced swiftinterfaces
that contain the following inlinable code:

```
@inlinable public init<E>(ordinary executor: __shared E) where E : _Concurrency._TaskExecutor {
  #if $BuiltinBuildTaskExecutor
  self.executor = Builtin.buildOrdinaryTaskExecutorRef(executor)
  #else
  fatalError("Swift compiler is incompatible with this SDK version")
  #endif
}
```

When a compiler containing the protocol rename attempts to type check the
above inlinable code, it crashes because the builtin is expecting an argument
conforming to `TaskExecutor`, which doesn't exist in this version of the
standard library. The issue is that the current compiler still supports
the `$BuiltinBuildTaskExecutor` feature guard, but the builtin supported
has since changed.

To resolve this issue, we need to stop supporting the `$BuiltinBuildTaskExecutor`
feature guard and introduce a new one that is only supported by compiler versions
that contain the rename. This approach relies on nothing having adopted the
API, otherwise we would need to stage in the rename as a parallel set of APIs,
and only remove the old APIs once nothing is relying on the old _Concurrency
swiftinterfaces.
2024-02-13 20:16:42 -08:00
Holly Borla
f1cd9cb422 [Test] Remove REQUIRES: asserts from tests that use -swift-version 6. 2024-02-13 07:13:35 -08:00
Hamish Knight
2c77947000 Merge pull request #71006 from hamishknight/implicit-last-expression
Introduce implicit last expression results
2024-02-08 10:15:01 +00:00
Hamish Knight
7b4c9fef02 Allow implicit last expressions for functions and closures
Gated behind the experimental feature
`ImplicitLastExprResults`.
2024-02-07 18:14:23 +00:00
Hamish Knight
d73e394ea7 Allow implicit last expression results for if/switch expressions
Allow implicitly treating the last expression of
the branch as the result, behind the experimental
feature `ImplicitLastExprResults`.
2024-02-07 18:14:22 +00:00
John McCall
2f8a33cf0a Experimental type-checking support for @isolated(any) function types. 2024-02-06 22:54:27 -05:00
Apollo Zhu
b09a22a9a0 Somewhat working
Test shadowed variable of same type

Fully type check caller side macro expansion

Skip macro default arg caller side expr at decl primary

Test macro expand more complex expressions

Set synthesized expression as implicit

Add test case for with argument, not compiling currently

Test with swiftinterface

Always use the string representation of the default argument

Now works across module boundary

Check works for multiple files

Make default argument expression work in single file

Use expected-error

Disallow expression macro as default argument

Using as a sub expression in default argument still allowed as expression macros behave the same as built-in magic literals
2024-02-06 15:02:11 -08:00
Pavel Yaskevich
a77d119c99 Merge pull request #71261 from xedin/introduce-thunks-for-runtime-check-func-refs
[Sema/SILGen] DynamicActorIsolation: Implement dynamic actor isolation checks for unsafe APIs
2024-02-02 13:32:00 -08:00
Pavel Yaskevich
f75d02ab56 Merge pull request #71312 from xedin/promote-flag-for-infersendable-from-capture
[Frontend] NFC: Promote InferSendableFromCaptures to an upcoming feat…
2024-02-02 09:37:28 -08:00
Pavel Yaskevich
db7959668e [Frontend] NFC: Rename PreconcurrencyConformances to DynamicActorIsolation 2024-02-01 13:28:25 -08:00
Pavel Yaskevich
c7c7df3329 [Frontend] NFC: Promote InferSendableFromCaptures to an upcoming feature in Swift 6 2024-02-01 10:56:22 -08:00
Kavon Farvardin
5f977ca763 NCGenerics: force module mismatches 2024-01-31 14:00:08 -08:00
Nate Chandler
03f904af0c [MoveChecker] Separate partial reinit from consume 2024-01-29 18:29:40 -08:00
Joe Groff
960938f87e SILGen: Always match noncopyable values by borrowing.
Even if the final pattern ends up consuming the value, the match itself
must be nondestructive, because any match condition could fail and cause
us to have to go back to the original aggregate. For copyable values,
we can always copy our way out of consuming operations, but we don't
have that luxury for noncopyable types, so the entire match operation
has to be done as a borrow.

For address-only enums, this requires codifying part of our tag layout
algorithm in SIL, namely that an address-only enum will never use
spare bits or other overlapping storage for the enum tag. This allows
us to assume that `unchecked_take_enum_data_addr` is safely non-side-
effecting and match an address-only noncopyable enum as a borrow.
I put TODOs to remove defensive copies from various parts of our
copyable enum codegen, as well as to have the instruction report
its memory behavior as `None` when the projection is nondestructive,
but this disturbs SILGen for existing code in ways SIL passes aren't
yet ready for, so I'll leave those as is for now.

This patch is enough to get simple examples of noncopyable enum switches
to SILGen correctly. Additional work is necessary to stage in the binding
step of the pattern match; for a consuming switch, we'll need to end
the borrow(s) and then reproject the matched components so we can
consume them moving them into the owned bindings. The move-only checker
also needs to be updated because it currently always tries to convert
a switch into a consuming operation.
2024-01-19 13:59:04 -08:00
Pavel Yaskevich
4943e146bd [Frontend] Add experimental flag for @preconcurrency conformances feature 2024-01-16 10:31:01 -08:00
Holly Borla
fcbe5593a3 Merge pull request #70871 from hborla/fix-complete-concurrency-flags
[Concurrency] Promote `StrictConcurrency` to an upcoming feature flag.
2024-01-12 09:41:58 -08:00
Holly Borla
d37b9763b6 [Concurrency] Promote StrictConcurrency to an upcoming feature flag. 2024-01-11 21:23:25 -08:00
Allan Shortlidge
04ca86b0d2 Merge pull request #70852 from tshortli/suppressible-extern-feature
[c-interop] Make Extern a suppressible language feature
2024-01-11 16:38:51 -08:00
Allan Shortlidge
ba1f50fddb [c-interop] Make Extern a suppressible language feature.
Fixes building the standard library's .swiftinterface with older Swift
compilers.
2024-01-11 13:54:24 -08:00
Allan Shortlidge
100e5ee797 [Concurrency] Fix more missing builtin guards for DiscardingTaskGroup.
Follow-up to https://github.com/apple/swift/pull/70837.
2024-01-11 10:22:55 -08:00
Holly Borla
7d2d91a38f Merge pull request #70257 from hborla/isolated-default-values-upcoming-flag
[SE-0411] Promote `IsolatedDefaultValues` from an experimental feature to an upcoming feature.
2024-01-11 06:57:15 -08:00
Konrad `ktoso` Malawski
ef80d778dc [Concurrency] Fix the missing builtin guards for DiscardingTaskGroup (#70837) 2024-01-10 22:55:38 -08:00
Holly Borla
0e71623386 [SE-0411] Promote IsolatedDefaultValues from an experimental feature to an
upcoming feature.
2024-01-10 14:54:24 -08:00