Commit Graph

2061 Commits

Author SHA1 Message Date
Sophia Poirier
a9e5075a94 Merge pull request #64039 from sophiapoirier/pack-type-syntax-each
[Variadic Generics] type parameter pack syntax change: T... -> each T
2023-03-02 19:17:19 -08:00
Alex Lorenz
1d3797308d [interop][SwiftToCxx] do not expose functions / properties that throw without the experimental feature 2023-03-02 15:22:36 -08:00
Sophia Poirier
70cffb06f3 [Variadic Generics] type parameter pack syntax change: T... -> each T 2023-03-02 14:42:28 -08:00
Doug Gregor
f88d2c638f Clean up feature flags for macros.
Enable expression macros by default, and add separate feature flags for
attached and freestanding macros.
2023-03-02 14:34:59 -08:00
Joe Groff
cecedd7cb6 Merge pull request #63990 from jckarter/se-0377-method-modifiers
Implement `consuming` and `borrowing` declaration-level modifiers from SE-0377.
2023-03-01 19:59:31 -08:00
Holly Borla
b78b6b9a77 Merge pull request #63991 from hborla/materialize-pack-from-tuple
[ConstraintSystem] Implement type checking for converting a tuple to a pack using the `.element` syntax.
2023-03-01 16:19:33 -08:00
Joe Groff
17c803724f Implement consuming and borrowing declaration-level modifiers from SE-0377.
`borrowing func`/`consuming func` control the ownership convention of `self` for
methods.
2023-03-01 11:58:59 -08:00
Kavon Farvardin
8559d3c6ea fix issue printing the forget statement in the AST
`kw_forget` isn't covered by `operator<<` since it's
not a normal keyword.
2023-02-28 23:31:34 -08:00
Holly Borla
509188630b [ConstraintSystem] Implement type checking for converting a tuple to a
pack using the `.element` syntax.
2023-02-28 22:56:59 -08:00
Kavon Farvardin
f41ed5926b implement the forget statement
Currently, this is staged in as `_forget`,
as part of SE-390. It can only be used on
`self` for a move-only type within a consuming
method or accessor. There are other rules, see
Sema for the details.

A `forget self` really just consumes self and
performs memberwise destruction of its data.
Thus, the current expansion of this statement
just reuses what we inject into the end of a
deinit.

Parsing of `forget` is "contextual".
By contextual I mean that we do lookahead to
the next token and see if it's identifier-like.
If so, then we parse it as the `forget` statement.
Otherwise, we parse it as though "forget" is an
identifier as part of some expression.

This way, we won't introduce a source break for
people who wrote code that calls a forget
function.

This should make it seamless to change it from
`_forget` to `forget` in the future.

resolves rdar://105795731
2023-02-28 21:15:17 -08:00
Joe Groff
833c25c7d0 Parser: Generalize : lookahead to disambiguate all parameter specifiers as argument labels 2023-02-28 09:16:45 -08:00
Alexis Laferrière
1afc6af739 Merge pull request #63912 from xymus/access-level-import-parsing
[Parser|Sema] Accept access level on imports with experimental flag
2023-02-27 09:27:26 -08:00
Alexis Laferrière
08895657cb [Parser] Intro parser support and flag for access level on imports 2023-02-25 09:47:19 -08:00
Dario Rexin
a8d4d57f11 [IRGen] Generate compressed representation of value witnesses (#63813)
rdar://105837040

* WIP: Store layout string in type metadata

* WIP: More cases working

* WIP: Layout strings almost working

* Add layout string pointer to struct metadata

* Fetch bytecode layout strings from metadata in runtime

* More efficient bytecode layout

* Add support for interpreted generics in layout strings

* Layout string instantiation, take and more

* Remove duplicate information from layout strings

* Include size of previous object in next objects offset to reduce number of increments at runtime

* Add support for existentials

* Build type layout strings with StructBuilder to support target sizes and metadata pointers

* Add support for resilient types

* Properly cache layout strings in compiler

* Generic resilient types working

* Non-generic resilient types working

* Instantiate resilient type in layout when possible

* Fix a few issues around alignment and signing

* Disable generics, fix static alignment

* Fix MultiPayloadEnum size when no extra tag is necessary

* Fixes after rebase

* Cleanup

* Fix most tests

* Fix objcImplementattion and non-Darwin builds

* Fix BytecodeLayouts on non-Darwin

* Fix Linux build

* Fix sizes in linux tests

* Sign layout string pointers

* Use nullptr instead of debug value
2023-02-24 15:40:28 -08:00
BJ Homer
738c89b8de Merge branch 'main' into disable-property-wrapper-based-isolation 2023-02-24 09:23:18 -07:00
BJ Homer
f876f26aaf Add a feature flag for DisableActorInferenceFromPropertyWrapperUsage.
This will be enabled by default in Swift 6, but can now also be enabled by passing `-enable-upcoming-feature DisableActorInferenceFromPropertyWrapperUsage` to the compiler.
2023-02-22 08:45:44 -07:00
Erik Eckstein
748264c45f Add a unprotectedStackAlloc builtin
It's like `Builtin.stackAlloc`, but doesn't set the `[stack_protection]` flag on its containing function.
2023-02-15 08:09:38 +01:00
Alex Hoppen
fd039f4344 Merge pull request #62478 from ahoppen/ahoppen/solver-based-cursor-info
[CursorInfo] Implement a few expression references as solver-based
2023-02-10 16:49:37 +01:00
Alex Hoppen
3e460630b7 [CursorInfo] Fix bug when performing solver-based cursor info on Self 2023-02-09 23:29:07 +01:00
Pavel Yaskevich
8eebb5bec1 Merge pull request #63522 from xedin/revert-type-wrappers
[AST/Sema/SIL] Revert TypeWrappers feature functionality
2023-02-09 09:27:18 -08:00
Doug Gregor
85ba74b812 Introduce a separate feature to cover @freestanding(expression) 2023-02-08 11:26:14 -08:00
Pavel Yaskevich
e2b22d9f62 [AST/Sema] Remove TypeWrapper feature functionality 2023-02-08 00:16:00 -08:00
Alex Lorenz
1a763c0cbc Merge pull request #63336 from hyp/eng/emit-symbolic-interfaces
[interop] Emit symbolic interfaces while indexing
2023-02-07 20:24:36 -08:00
QuietMisdreavus
36ab59629d Merge pull request #63391 from apple/QuietMisdreavus/factory-init-sgf
don't print the "not inherited" mark in SGF declarations
2023-02-07 15:12:37 -07:00
Richard Wei
81943b2b11 [Macros] Clean up MacroExpansionDecl (#63486)
- Remove the `Rewritten` field and `setRewritten()`. Make `getRewritten()` invoke the request.
- Rename fields `Macro` and `MacroLoc` to `MacroName` and `MacroNameLoc` respectively as well as their getters to match those in `MacroExpansionExpr`.
2023-02-07 14:57:02 +08:00
Hamish Knight
c87b1b8bef Merge pull request #63022 from hamishknight/express-yourself 2023-02-03 16:40:09 +00:00
Victoria Mitchell
d208dd9993 don't print the "not inherited" mark in SGF declarations
rdar://104917487
2023-02-02 14:53:03 -07:00
Alex Hoppen
acca597cd0 Merge pull request #59984 from ahoppen/pr/typecheck-multistamtent-closures-in-result-builders
[Sema] Type check multi-statement closures inside result builders
2023-02-02 08:08:22 +01:00
John McCall
ea107ae025 Merge pull request #63324 from rjmccall/element-archetype-printing
Fix printing and implement parsing of opened element archetypes in SIL
2023-02-01 18:59:54 -05:00
Pavel Yaskevich
7a81eb3810 Merge pull request #63274 from xedin/runtime-metadata-impl-alignment
[AST/Sema] RuntimeMetadata: Align implementation with proposal
2023-02-01 12:37:24 -08:00
Hamish Knight
a40f1abaff Introduce if/switch expressions
Introduce SingleValueStmtExpr, which allows the
embedding of a statement in an expression context.
This then allows us to parse and type-check `if`
and `switch` statements as expressions, gated
behind the `IfSwitchExpression` experimental
feature for now. In the future,
SingleValueStmtExpr could also be used for e.g
`do` expressions.

For now, only single expression branches are
supported for producing a value from an
`if`/`switch` expression, and each branch is
type-checked independently. A multi-statement
branch may only appear if it ends with a `throw`,
and it may not `break`, `continue`, or `return`.

The placement of `if`/`switch` expressions is also
currently limited by a syntactic use diagnostic.
Currently they're only allowed in bindings,
assignments, throws, and returns. But this could
be lifted in the future if desired.
2023-02-01 15:30:18 +00:00
Alex Hoppen
4169f937d0 [AST] Fail an assertion when printing a TypeVariableType with an unknown originator 2023-02-01 10:29:06 +01:00
John McCall
c491d25d06 Fix printing and implement parsing of opened element archetypes in SIL
Also, fix a couple places that were checking for opened existentials
to check for any local archetype.
2023-01-31 19:54:31 -05:00
Alex Lorenz
f36e5cf641 [interop] add 'ImportSymbolicCXXDecls' experimental import mode for importing class templates syntactically but not semantically 2023-01-31 14:58:13 -08:00
Alex Lorenz
e6e7bd0629 Merge pull request #63296 from hyp/eng/print-ns-interface-quick
[interop] AST printer should only visit one original namespace decl t…
2023-01-31 14:56:30 -08:00
Pavel Yaskevich
67b74a0633 [Sema] RuntimeMetadata: Diagnose missing explicit reflection metadata attributes
Diagnose situations where a sub-class or a protocol do not have all
of the reflection metadata attributes required by a superclass.

Resolves: rdar://103990788
2023-01-30 14:14:47 -08:00
Pavel Yaskevich
af639e5bf4 [AST] RuntimeMetadata: Move getRuntimeDiscoverableAttrs to Decl
Reflection metadata attributes could be attached to a `ValueDecl`
and `ExtensionDecl`.
2023-01-30 14:03:40 -08:00
Alex Lorenz
1c2ba454f6 [interop] namespace printing should only print redecls from one module interface
This ensures that when we're printing multiple module interfaces, we separate out
the namespaces and their members correctly between the produced module interfaces.
2023-01-29 17:31:20 -08:00
Alex Lorenz
88c8893e80 [interop] AST printer should only visit one original namespace decl to avoid printing redecls over and over again
Also, lookup namespace members directly without doing a lookup. This helps us print the libc++ module interface in < 1s on M1
2023-01-29 12:01:07 -08:00
John McCall
d25a8aec8b Add explicit lowering for value packs and pack expansions.
- SILPackType carries whether the elements are stored directly
  in the pack, which we're not currently using in the lowering,
  but it's probably something we'll want in the final ABI.
  Having this also makes it clear that we're doing the right
  thing with substitution and element lowering.  I also toyed
  with making this a scalar type, which made it necessary in
  various places, although eventually I pulled back to the
  design where we always use packs as addresses.

- Pack boundaries are a core ABI concept, so the lowering has
  to wrap parameter pack expansions up as packs.  There are huge
  unimplemented holes here where the abstraction pattern will
  need to tell us how many elements to gather into the pack,
  but a naive approach is good enough to get things off the
  ground.

- Pack conventions are related to the existing parameter and
  result conventions, but they're different on enough grounds
  that they deserve to be separated.
2023-01-29 03:29:06 -05:00
Artem Chikin
959216c0f6 Merge pull request #63175 from artemcm/DeSugarArraysAndDictionariesWhenPrinting
[Compile Time Constant Extraction] Print desugared array, dictionary, optional types
2023-01-24 09:32:08 -08:00
Kavon Farvardin
1978553c75 fill in the MoveOnly* feature guards 2023-01-23 22:59:58 -08:00
Kavon Farvardin
1356694043 experimentally allow move-only classes
A lot of existing regression tests rely on there
being some form of move-only classes, despite
them being something that will not be available
to users (and not complete).

This change introduces a `MoveOnlyClasses`
experimental feature so that those tests don't
need to be fully rewritten just yet. You need to
include `-enable-experimental-feature MoveOnlyClasses` along with
`-enable-experimental-move-only` to get move-only classes.
2023-01-23 22:33:27 -08:00
Artem Chikin
544dae4713 [Compile Time Constant Extraction] Print desugared arrays, dictionaries, optionals
Resolves rdar://103187206
2023-01-23 17:12:31 -08:00
Artem Chikin
f85deb0008 [AST Printer] Add ability to print desugared arrays, dictionaries, optionals 2023-01-23 17:09:25 -08:00
Ellie Shin
91f785441f Merge pull request #62652 from apple/es-pkg-acl
[NFC] Add 'package' access modifier to AccessLevel
2023-01-20 13:58:15 -08:00
John McCall
0e3a9adc32 Add Builtin.PackIndex 2023-01-19 23:57:13 -05:00
Ellie Shin
37af51dc4c Merge branch 'main' into es-pkg-acl 2023-01-19 16:18:17 -08:00
Ellie Shin
1c66d02f92 Add package access level to enum AccessLevel
Resolves rdar://104198440
2023-01-19 15:54:18 -08:00
Holly Borla
3f462f0f43 [Decl] Add MissingDecl to use for parser recovery. 2023-01-15 09:55:15 -08:00