Commit Graph

2092 Commits

Author SHA1 Message Date
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
Doug Gregor
9e76023546 Add BuiltinCreateTaskGroupWithFlags feature and use it to guard the builtin 2023-01-11 13:47:28 -08:00
John McCall
55b72d4eb7 Fix the pretty-printing of pack expansion types to match the current design 2023-01-11 03:11:30 -05:00
Pavel Yaskevich
020db2350b [AST] TypeWrappers: Always allow attributes that come from swiftinterfaces
Since type wrapper attributes could be applied to protocols and
the protocol types could be used as existential values, it's not
always possible to wrap all uses of feature into `#if $TypeWrappers`
block so let's allow use of attributes if they come from a Swift
interface file.
2023-01-04 16:04:28 -08:00
Michael Gottesman
b95fe48a90 Merge pull request #62742 from gottesmm/pr-947919228bebf49e02eae5aedb1efee8038c2b4b
[borrow-expr] Add simple support for borrow-expr and wire it up to SILGenApply
2023-01-03 08:04:33 -08:00
Doug Gregor
0c5436211c Merge pull request #62768 from DougGregor/macro-omnibus 2023-01-03 07:13:16 -08:00
swift-ci
72146501a1 Merge pull request #62745 from tshortli/has-symbol-clang-decls
Sema/IRGen: Add clang decl support to `#_hasSymbol`
2023-01-03 01:25:34 -08:00
Doug Gregor
7000969f14 Introduce and use #externalMacro for externally-defined macros.
Align the grammar of macro declarations with SE-0382, so that macro
definitions are parsed as an expression. External macro definitions
are referenced via a referenced to the macro `#externalMacro`. Define
that macro in the standard library, and recognize uses of it as the
definition of other macros to use externally-defined macros. For
example, this means that the "stringify" macro used in a lot of
examples is now defined as something like this:

    @expression macro stringify<T>(_ value: T) -> (T, String) =
        #externalMacro(module: "MyMacros", type: "StringifyMacro")

We still parse the old "A.B" syntax for two reasons. First, it's
helpful to anyone who has existing code using the prior syntax, so they
get a warning + Fix-It to rewrite to the new syntax. Second, we use it
to define builtin macros like `externalMacro` itself, which looks like this:

    @expression
    public macro externalMacro<T>(module: String, type: String) -> T =
        Builtin.ExternalMacro

This uses the same virtual `Builtin` module as other library builtins,
and we can expand it to handle other builtin macro implementations
(such as #line) over time.
2023-01-02 21:22:05 -08:00
Allan Shortlidge
e8f1d9f59f AST: Fix a warning in ASTPrinter.cpp. 2022-12-22 10:55:29 -05:00
Michael Gottesman
947919228b [borrow-expr] Add simple support for borrow-expr but don't wire it up to anything. 2022-12-21 14:36:43 -08:00
Pavel Yaskevich
529269946d [AST] Drop ResultBuilderASTTransform feature flag 2022-12-21 12:18:02 -08:00
Pavel Yaskevich
43904e5a89 [ASTPrinter] Mark declarations with runtime attributes as using the feature 2022-12-20 09:45:01 -08:00
Holly Borla
d3bc4f52bc Merge pull request #62582 from hborla/pack-element-expr 2022-12-16 11:42:53 -05:00
Doug Gregor
33589de62f Experimentally emit diagnostics from the new Swift parser
Introduce the experimental feature `ParserDiagnostics`, which emits
diagnostics from the new Swift parser *first* for a source file. If
that produces any errors, we suppress any diagnostics emitted from the
C++ parser.
2022-12-15 21:24:44 -08:00
Pavel Yaskevich
7b08b30e84 Merge pull request #62586 from xedin/rdar-103270262
[AST/Sema] TypeWrappers: Fix a couple of issues with attribute inference from protocols
2022-12-15 17:49:19 -08:00
Holly Borla
f1fd9acb23 [AST] Add 'PackElementExpr' for explicit pack elements spelled with the 'each'
keyword.
2022-12-14 20:45:51 -08:00
Pavel Yaskevich
5c11a4b894 [ASTPrinter] TypeWrappers: print inferred attributes 2022-12-14 17:50:28 -08:00
Pavel Yaskevich
fa62cf3827 [ASTPrinter] Expand type wrapper feature coverage
`usesFeatureTypeWrappers` should return `true` for all of
the declarations that use the feature directly or indirectly
e.g. type wrapper types, type wrapped types, and types with
conformance to a type wrapped protocol (with or without wrapper
attribute inference).
2022-12-14 12:17:24 -08:00
Zoe Carver
9850906570 Merge pull request #62330 from zoecarver/conforms-to-attr
[cxx-interop] Add ability to specify protocol conformance on C++ side.
2022-12-13 16:28:31 -08:00
Alexis Laferrière
276281ded8 Merge pull request #62476 from xymus/module-interface-export-as
[ModuleInterface] Ignore export_as in private swiftinterface
2022-12-13 09:12:44 -08:00