Commit Graph

2604 Commits

Author SHA1 Message Date
Pavel Yaskevich
c17d35dc3e Merge pull request #62146 from xedin/rdar-102085039
[AST] `getParameterAt` should check index before retrieving it
2022-11-28 10:01:51 -08:00
Erik Eckstein
ab1b343dad use new llvm::Optional API
`getValue` -> `value`
`getValueOr` -> `value_or`
`hasValue` -> `has_value`
`map` -> `transform`

The old API will be deprecated in the rebranch.
To avoid merge conflicts, use the new API already in the main branch.

rdar://102362022
2022-11-21 19:44:24 +01:00
Doug Gregor
787af41765 [Macros] Parse generic arguments in macro expansions. 2022-11-17 16:46:43 -08:00
Angela Laar
3b8cfca027 [test] Add more opaque return tests 2022-11-17 11:54:44 -08:00
Angela Laar
bde6a465af [AST] Fix circular reference with implicit some
getPotentiallyOpaqueGenericParams has a redundant call to check if
declarations contain any opaque type representations. We don't need
to check this here. Instead we can simply collect the result type
representaions without the additional checks.
2022-11-17 11:53:50 -08:00
Pavel Yaskevich
7bc1dc59ab [AST] getParameterAt should check index before retrieving it
`getParameterAt` needs to be more defensive about the input
because caller cannot always perform all the checks upfront.

Resolves: rdar://102085039
2022-11-16 15:34:05 -08:00
Doug Gregor
51fcde7b76 Merge pull request #62086 from DougGregor/macro-decl 2022-11-13 20:25:48 -08:00
Doug Gregor
5ab6b72604 [Macros] Turn Macro into a declaration node.
Although the declaration of macros doesn't appear in Swift source code
that uses macros, they still operate as declarations within the
language. Rework `Macro` as `MacroDecl`, a generic value declaration,
which appropriate models its place in the language.

The vast majority of this change is in extending all of the various
switches on declaration kinds to account for macros.
2022-11-13 12:21:29 -08:00
Holly Borla
ee04cea679 [Sema] Fix an issue with existential return types when implicit some is enabled. 2022-11-11 15:16:06 -08:00
Allan Shortlidge
114ee28639 AST: Add a DescriptiveDeclKind for actors. 2022-11-08 19:17:09 -08:00
Pavel Yaskevich
0aa036a495 Merge pull request #61915 from xedin/switch-protocol-checking-to-abi-members
[AST/Sema] Switch protocol requirement inference to use `getABIMembers()`
2022-11-04 16:21:01 -07:00
Pavel Yaskevich
82f34b90c1 [AST] NameLookup: Add a request to gather protocol requirements 2022-11-04 11:11:41 -07:00
Robert Widmann
7944635f2e Merge pull request #61898 from CodaFi/i-write-syns-not-tragedies 2022-11-04 08:20:47 -07:00
Pavel Yaskevich
dd69e11482 [AST/Sema] Switch protocol requirement inference to use getABIMembers()
- `getAssociatedTypeMembers()`;
- inference of defaults for associated types;
- `ConformanceChecker` methods that iterate over type and
   value requirements.
2022-11-03 13:22:53 -07:00
Robert Widmann
2d07f382c5 Delete _InternalSwiftSyntaxParser And Its Build Infrastructure
This is the start of the removal of the C++ implementation of libSyntax
in favor of the new Swift Parser and Swift Syntax libraries. Now that
the Swift Parser has switched the SwiftSyntaxParser library over to
being a thin wrapper around the Swift Parser, there is no longer any
reason we need to retain any libSyntax infrastructure in the swift
compiler.

As a first step, delete the infrastructure that builds
lib_InternalSwiftSyntaxParser and convert any scripts that mention
it to instead mention the static mirror libraries. The --swiftsyntax
build-script flag has been retained and will now just execute the
SwiftSyntax and Swift Parser builds with the just-built tools.
2022-11-02 10:35:29 -07:00
Slava Pestov
36b3f0ee12 AST: Remove AbstractTypeParamDecl 2022-11-01 19:13:46 -04:00
Slava Pestov
0e4ccb21ed AST: Remove various references to AbstractTypeParamDecl 2022-11-01 19:13:46 -04:00
Slava Pestov
ad06d27e88 AST: Remove AbstractTypeParamDecl::getSuperclass()/getConformingProtocols() 2022-11-01 19:13:46 -04:00
Becca Royal-Gordon
75965d0588 Exclude overrides from being member impls
Without this change, an `@_objcImplementation` cannot override parent class methods, because the special access control behavior breaks the access control checks for overrides.
2022-10-27 17:00:43 -07:00
Becca Royal-Gordon
881f1f90a8 Re-allow @objc final
Treating this as forbidden was incorrect; an `@objc final` method is simply one that isn’t a member implementation but does have an ObjC entry point.

Formalize and centralize the definition of what a member implementation is, tweak it so that it’s basically “non-final and internal or greater”, and permit `@objc final`. Also remove the inference of `final` on `let`s in @_objcImpl extensions.
2022-10-27 16:51:13 -07:00
swift-ci
1ebcd13975 Merge pull request #61662 from rxwei/macro-expansion-expr
[Macros] Parse MacroExpansionExpr and MacroExpansionDecl
2022-10-21 06:13:41 -07:00
Richard Wei
56e7cce809 [Macros] Parse MacroExpansionExpr and MacroExpansionDecl
Introduce `MacroExpansionExpr` and `MacroExpansionDecl` and plumb it through. Parse them in roughly the same way we parse `ObjectLiteralExpr`.

The syntax is gated under `-enable-experimental-feature Macros`.
2022-10-21 01:50:35 -07:00
Pavel Yaskevich
5c8c008c8e Merge pull request #61479 from xedin/type-wrappers-init-values-in-user-defined-inits
[SILGen] TypeWrappers:  Support default values in user-defined initializers
2022-10-21 08:48:35 +01:00
Becca Royal-Gordon
a36b52153f Directly access @_objcImpl stored props sometimes
Accessing a stored property from a normal method should send a selector, but accessing it from an initializer or accessor should use the field offset.
2022-10-18 17:21:56 -07:00
Becca Royal-Gordon
ecf0ee65b8 Cache @_objcImpl pointers and diagnose dupes 2022-10-18 17:21:56 -07:00
Becca Royal-Gordon
3a2f12a099 Allow stored properties in @_objcImpls
Stored properties are only allowed in the extension implementing the class's main interface, not its categories. This also means banning `@objc final`, which is unenforceable anyway when ObjC subclasses are allowed, and therefore allowing `@objc let` and `@objc static` properties to be overridden if they're declared in objcImplementations.
2022-10-18 17:21:56 -07:00
Becca Royal-Gordon
e544c21f99 Make all internal-or-more @_objcImpl members impls 2022-10-18 17:21:56 -07:00
Becca Royal-Gordon
f2a0ab79c7 Add basic Sema support for @_objcImplementation
Does not validate members yet; nor does it emit different metadata.
2022-10-18 17:21:56 -07:00
Slava Pestov
a5453f1649 AST: Add new variant of swift::getParameterAt() which takes pack expansions into account 2022-10-16 21:37:25 -04:00
Hamish Knight
48ea933804 Parse an ellipsis T... for type parameter packs
In a generic parameter list, parse an ellipsis
to produce a type parameter pack. This replaces
the previous `@_typeSequence` attribute.
2022-10-14 15:40:12 +01:00
Hamish Knight
b645e63ce5 [AST] NFC: Refactor GenericTypeParamDecl construction
Add distinct overloads for the parser,
deserialization and code synthesis.
2022-10-14 15:40:12 +01:00
Holly Borla
c4b946195e [AST] Replace the "type sequence" terminology with "parameter pack". 2022-10-10 16:28:13 -07:00
Pavel Yaskevich
cba7a78605 [AST] Make it possible to check if var decl is for _storage 2022-10-07 17:36:10 -07:00
Holly Borla
54f42b5833 Merge pull request #61445 from hborla/pack-shape-requirements
[RequirementMachine] Implement inference and minimization of same-shape requirements.
2022-10-07 14:49:14 -07:00
Slava Pestov
92f1361b82 Merge pull request #61429 from LucianoPAlmeida/opaque-parameters-crash
[AST] Move generic parameter logic for accessor decl from parser to GenericParamListRequest
2022-10-07 16:52:24 -04:00
Luciano Almeida
a95f60e387 [AST] Refactor generic parameter list parse logic for AccessorDecl 2022-10-07 09:43:08 -03:00
Holly Borla
38a2c8218b [Requirement] Rename RequirementKind::SameCount to SameShape. 2022-10-06 20:48:40 -07:00
Pavel Yaskevich
412915eadd [AST] TypeWrappers: A request to synthesize _storage variable for an initializer
User-defined initializer would populate `_storage` incrementally
so it could be passed to `<TypeWrapper>.init(memberwise:)` call
to initialize the type wrapper.
2022-09-29 20:50:36 -07:00
Angela Laar
ae2c6a18d8 [Sema] Resolve ident type to opaque result type
This is just more work to get type resolution to understand
how to derive an opaque type from an IdentTypeRepr during
OpaqueResultTypeRequest
2022-09-20 15:25:09 -07:00
Angela Laar
5f3191c74e [AST] Teach GenericParamList amd OpaqueReturnType Request to use plain protocols
Originally protocols prefixed with 'some' keyword are considered an opaue return
type representation. In order to understand plain protocols, the GenericParamList
Request must understand how to build a generic parameter list using alternative
type representations: identifier and composition.
2022-09-20 15:25:09 -07:00
Allan Shortlidge
6b61e37364 SILGen: Function availability for linkage should use @_backDeploy OS version if present.
When computing the availability of a `SILFunction` for linkage the OS version specified in the `@_backDeploy` attribute should be preferred over the version in the `@available` attribute. This ensures that the corresponding symbol is weakly linked when deploying to older OSes than the back deploy "before" version.

Resolves rdar://99962885
2022-09-16 17:05:35 -07:00
Hamish Knight
4716f61fba [AST] Introduce explicit actions for ASTWalker
Replace the use of bool and pointer returns for
`walkToXXXPre`/`walkToXXXPost`, and instead use
explicit actions such as `Action::Continue(E)`,
`Action::SkipChildren(E)`, and `Action::Stop()`.
There are also conditional variants, e.g
`Action::SkipChildrenIf`, `Action::VisitChildrenIf`,
and `Action::StopIf`.

There is still more work that can be done here, in
particular:

- SourceEntityWalker still needs to be migrated.
- Some uses of `return false` in pre-visitation
methods can likely now be replaced by
`Action::Stop`.
- We still use bool and pointer returns internally
within the ASTWalker traversal, which could likely
be improved.

But I'm leaving those as future work for now as
this patch is already large enough.
2022-09-13 10:35:29 +01:00
Slava Pestov
c1b8690401 AST: Introduce special Builtin.TheTupleType singleton 2022-09-10 00:26:42 -04:00
Doug Gregor
237ff4cc29 Merge pull request #60985 from DougGregor/simplify-getAsyncAlternative
Simplify get async alternative
2022-09-07 17:50:20 -07:00
Doug Gregor
553537d326 Revert "[NFC] Add isKnownObjC param to RenamedDeclRequest"
This reverts commit 102f9a30c2.
2022-09-07 14:09:50 -07:00
Slava Pestov
7bf6803a61 Merge pull request #60923 from slavapestov/pack-expansion-type-repr
Introduce PackExpansionTypeRepr
2022-09-07 16:09:29 -04:00
Slava Pestov
79ed990728 AST: Replace TupleTypeRepr's ellipsis with PackExpansionTypeRepr 2022-09-07 12:35:54 -04:00
Alex Hoppen
442cf9bd4e [Sema] Add custom functions to ActorIsolationChecker to determine expr type and closure actor isolation
When we get rid of `LeaveClosureBodiesUnchecked` we no longer save closure types to the AST and thus also don’t save their actor isolation to the AST. Hence, we need to extract types and actor isolations of parent closures from the constraint system solution instead of the AST. This prepares `ActorIsolationChecker` to take custom functions to determine the type of an expression or the actor isolation of a closure.
2022-09-07 11:12:23 +02:00
Alex Hoppen
ec73a3a721 [AST] Move conversion of ClosureActorIsolation to ActorIsolation to its own function
Just a little bit of cleanup because this logic is really quite general and doesn't need to live in `getActorIsolationOfContext`.
2022-09-07 11:12:09 +02:00
swift-ci
6ce4bea5d1 Merge pull request #60688 from theblixguy/defer-isolation-closures
[Concurrency] Handle actor isolation for defers in closures
2022-08-31 19:21:13 -07:00