Commit Graph

2062 Commits

Author SHA1 Message Date
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
Kavon Farvardin
f0b4f4a865 NCGenerics: omit inverses on invertible protocols
The interface files were still printing inverses on the invertible
protocols, when that's not required. Doing so yielded warnings during
the build because `~Escapable` isn't yet ready for appearing in the
stdlib.
2024-02-06 08:15:26 -08:00
Slava Pestov
366f741438 AST: Print substitution signature without applying inverse transform 2024-02-05 18:43:06 -05:00
Hamish Knight
658be5b40f Merge pull request #64667 from Rajveer100/branch-for-issue-61601
Added unimplemented expression cases in the ASTPrinter
2024-02-05 11:42:09 +00:00
John McCall
dd90ae7416 Rename SIL's @isolated attribute to @sil_isolated.
We want to use @isolated in ordinary Swift, and while we could probably
make it coexist with this SIL use, doing so would be really inconvenient.
2024-02-03 01:51:36 -05: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
Rintaro Ishizaki
8fdc4cc225 [AST] Split Attr.def to DeclAttr.def and TypeAttr.def 2024-02-02 09:36:49 -08:00
Rintaro Ishizaki
b839718351 [AST] Use scoped enum for attribute kinds
Align with other kind enum e.g. DeclKind.
2024-02-02 09:36:48 -08:00
Rintaro Ishizaki
07bb0380a1 [AST] Use class names for type attribute kind enum
Align with DeclAttrKind.
2024-02-02 09:36:47 -08:00
Rajveer
48847da5e6 Added the expression cases of the form 'visit...Expr()'
Part of Issue #61601
2024-02-02 13:51:37 +05:30
Pavel Yaskevich
db7959668e [Frontend] NFC: Rename PreconcurrencyConformances to DynamicActorIsolation 2024-02-01 13:28:25 -08:00
Pavel Yaskevich
4debaf2c5d [AST] Introduce a new conversion expression - ActorIsolationErasure
To be used in situations when a global actor isolation is stripped
from a function type in argument positions and could be extended in
the future to cover more if needed.
2024-02-01 13:28:25 -08:00
Slava Pestov
80205ecf9c Merge pull request #71241 from slavapestov/ncgenerics-fixes
Non-copyable generics fixes
2024-02-01 07:18:29 -05:00
Slava Pestov
23b1690f6b ASTPrinter: Refactor printing of RequirementSignatures 2024-01-31 21:55:52 -05:00
Slava Pestov
2355cb4090 Sema: Move -debug-generic-signatures behavior to TypeCheckDeclPrimary.cpp 2024-01-31 18:41:43 -05:00
Slava Pestov
45f31b4516 AST: Refactor ASTPrinter to use getRequirementsWithInverses() 2024-01-31 18:40:35 -05:00
Joe Groff
a52e96e358 Merge pull request #71263 from jckarter/borrowing-switch-3
Parse `_borrowing x` in patterns as a borrow binding.
2024-01-31 07:08:32 -08:00
Hamish Knight
27c08b130a Merge pull request #71123 from hamishknight/sema-expr-return
Move the single-expr return transform from Parse to Sema
2024-01-31 10:13:24 +00:00
Joe Groff
6706feaf5e Parse _borrowing x in patterns as a borrow binding.
Treat it as a contextual keyword when followed by an identifier, like our
other ownership-related declarations and operators.
2024-01-30 17:33:42 -08:00
nate-chandler
52989d19d8 Merge pull request #71234 from nate-chandler/partial-consumption/20240129/1/reinit-feature
[MoveChecker] Separate partial reinit feature from partial consume feature.
2024-01-30 07:04:56 -08:00
Hamish Knight
0a4c029cfc [AST] Introduce UnreachableExpr
This models the conversion from an uninhabited
value to any type, and allows us to get rid of
a couple of places where we'd attempt to drop
the return statement instead.
2024-01-30 14:08:54 +00:00
Nate Chandler
03f904af0c [MoveChecker] Separate partial reinit from consume 2024-01-29 18:29:40 -08:00
Meghana Gupta
24d6a2953b Lower lifetime dependence info into SIL types 2024-01-29 11:41:41 -08:00
Michael Gottesman
6f3d45219a [ast] Represent a parameter's isolation at the SIL level.
I did this by adding flag on SILParamInfo.

rdar://121387872
2024-01-23 15:20:22 -08:00
Joe Groff
47ee847ceb Merge pull request #71025 from jckarter/borrowing-switch-1
SILGen: Always match noncopyable values by borrowing.
2024-01-22 15:02:26 -08:00
Pavel Yaskevich
57bf9d52b1 Merge pull request #71014 from xedin/inheritedentry-bitfields
[AST] NFC: Convert `InheritedEntry` flags to bitfields
2024-01-19 16:19:47 -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
7f6a8f865c [AST] NFC: Convert InheritedEntry flags to bitfields 2024-01-19 10:22:39 -08:00
Michael Gottesman
9513d298ec [region-isolation] Add parsing/serialization/type system support for a transferring OwnershipSpecifier. 2024-01-18 13:20:28 -08:00
Pavel Yaskevich
6cdab78028 Merge pull request #70867 from xedin/dynamic-enforcement-of-witness-isolation-with-preconcurrency
[TypeChecker/SILGen] Dynamic enforcement of witness/objc isolation with @preconcurrency attribute
2024-01-17 10:01:37 -08:00
Doug Gregor
255009dddb Implement #isolation macro to produce the isolation of the current context
Introduce a new expression macro that produces an value of type
`(any AnyActor)?` that describes the current actor isolation. This
isolation will be `nil` in non-isolated code, and refer to either the
actor instance of shared global actor in other cases.

This is currently behind the experimental feature flag
OptionalIsolatedParameters.
2024-01-16 14:25:51 -08:00
Pavel Yaskevich
4943e146bd [Frontend] Add experimental flag for @preconcurrency conformances feature 2024-01-16 10:31:01 -08:00
Pavel Yaskevich
233d279a5c [AST] Support @preconcurrency attribute on test/extension inheritance entries 2024-01-16 10:30:58 -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
Kavon Farvardin
ac465ea8a1 Merge pull request #70548 from kavon/ncgenerics-stdlib-building-v3
[NCGenerics] Even more fixes for building the stdlib (Part 3)
2024-01-11 08:14:43 -08:00
Konrad `ktoso` Malawski
ef80d778dc [Concurrency] Fix the missing builtin guards for DiscardingTaskGroup (#70837) 2024-01-10 22:55:38 -08:00
Kavon Farvardin
a2defd5367 [NCGenerics] fix AnyObject and inverses
resolves rdar://120512544
2024-01-10 19:37:21 -08:00
Kavon Farvardin
af7ff43d0d [NCGenerics] printing class-constrained generics
In cases where the generic parameter is class-constrained,
`GenericSignature::requiresProtocol` will not contain `Copyable` or
`Escapable` because GenericSignature minimization will recognize that
the class already requires them.

Thus, because classes always require those protocols, we can
simply ask if the generic parameter is required to be a class to
determine if it had any inverses.
2024-01-10 19:37:21 -08:00
Holly Borla
22d9e85953 Merge pull request #70758 from hborla/generalize-isolated-param
[Concurrency] Allow isolated parameters to have optional type.
2024-01-10 19:07:04 -08:00
Holly Borla
f15ef1a055 [Concurrency] Allow isolated parameters to have optional type. 2024-01-09 21:37:24 -08:00
Michael Gottesman
213c9e8fdd Remove a clang optimize off that snuck into tree. 2024-01-09 20:38:51 -08:00
Ben Barham
d51c58a6f9 [Basic] hasFeature should succeed for promoted language features
Merge `$<Feature>` and `hasFeature` implementations.
  - `$<Feature>` did not support upcoming language features.
  - `hasFeature` did not support promoted language features and also
    didn't take into account `Options` in `Features.def`.

Remove `Options` entirely, it was always one of three cases:
  - `true`
  - `langOpts.hasFeature`
  - `hasSwiftSwiftParser`

Since `LangOptions::hasFeature` should always be used anyway, it's no
longer necessary. `hasSwiftSwiftParser` can be special cased when adding
the default promoted language features (by removing those features).

Resolves rdar://117917456.
2024-01-05 10:26:13 -08:00
Michael Gottesman
6d00750ad0 Merge pull request #70653 from gottesmm/transferring
[region-isolation] Initial refactoring work for supporting Transferring Args and Results
2024-01-02 18:51:44 -08:00
Slava Pestov
8e2aa52f7a Merge pull request #70667 from slavapestov/assorted-small-cleanups
Assorted small cleanups
2024-01-02 19:00:59 -05:00