Commit Graph

995 Commits

Author SHA1 Message Date
Richard Wei
f17b7c48bf [Macros] Freestanding declaration macros
Add support for freestanding declaration macros.

- Parse `@declaration` attribute.
- Type check and expand `MacroExpansionDecl`.

Known issues:
- Generic macros are not yet handled.
- Expansion does not work when the parent decl context is `BraceStmt`. Need to parse freestanding declaration macro expansions in `BraceStmt` as `MacroExpansionDecl`, and add expanded decls to name lookup.
2023-01-10 19:09:11 -08:00
Holly Borla
74bf2f3e7a [AST] Introduce a syntactic distinction betweek vararg type reprs and
pack expansion type reprs.

Classic variadic parameters still use the postfix ellipsis syntax, and
pack expansion types now use a prefix 'repeat' keyword.
2023-01-07 09:50:11 -08:00
Anthony Latsis
1bb407ac8c [NFC] AST: Rename ComponentIdentTypeReprIdentTypeRepr 2023-01-07 07:15:36 +03:00
Anthony Latsis
ad5d55c36e [NFC] AST: Rename IdentTypeReprDeclRefTypeRepr 2023-01-07 07:14:44 +03:00
Anthony Latsis
746c7aff7d [NFC] AST: Rename CompoundIdentTypeReprMemberTypeRepr 2023-01-07 07:14:41 +03:00
Anthony Latsis
0c3a72d4d7 [NFC] CompoundIdentTypeRepr: Supplant getComponents with getBaseComponent & getMemberComponents
Also store the base component separately as an arbitrary `TypeRepr`.
2023-01-07 07:11:30 +03:00
Anthony Latsis
7be645e2de [NFC] Remove some uses of CompoundIdentTypeRepr::getComponents 2023-01-07 07:11:30 +03:00
Anthony Latsis
2113e175f5 [NFC] AST: Remove IdentTypeRepr::ComponentRange 2023-01-07 07:11:30 +03:00
Anthony Latsis
8935acdd5b [NFC] AST: Remove IdentTypeRepr::create 2023-01-07 07:11:29 +03:00
Rintaro Ishizaki
4e334498e8 [CodeCompletion] Don't suggest opaque generic parameter types
'some' parameter types don't have spelling.

rdar://102958462
2022-12-15 13:26:17 -08:00
Holly Borla
41298c2466 [AST] Introduce PackReferenceTypeRepr for pack references spelled with
a contextual 'each' keyword.
2022-12-10 16:16:04 -08:00
Slava Pestov
2875cac27f AST: Clean up prepareLookupTable() a bit more 2022-11-28 23:57:53 -05:00
Slava Pestov
cc3a53091d AST: Remove MemberLookupTable::updateLookupTable() 2022-11-28 23:57:53 -05:00
Slava Pestov
3113c62a2d AST: Fix performance regression in lookupDirect()
Every call to lookupDirect() was calling prepareLookupTable() followed
by addLoadedExtensions(). While prepareLookupTable() only did its work
once, addLoadedExtensions() would walk all currently-loaded members of
all extensions every time.

However, just merging it with prepareLookupTable() was not enough,
because other places call prepareLookupTable(), which ends up loading
extensions too early after this change.

Instead, separate out the lazy allocation of the lookup table from
initialization. getLookupTable() returns a potentially-uninitialized
lookup table, and prepareLookupTable() now does what it did before
as well as what was formerly in addLoadedExtensions().

With this new split, getLookupTable() can be used instead of
prepareLookupTable() to avoid request cycles in a couple of places.
2022-11-28 23:57:53 -05: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
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
0e4ccb21ed AST: Remove various references to AbstractTypeParamDecl 2022-11-01 19:13:46 -04:00
Becca Royal-Gordon
3e4ea43adf Don’t diagnose @_objcImpl conflicts with inherited inits
Previously, Swift would reject an `override public init(…)` in an `@_objcImplementation` because ClangImporter would have already synthesized inherited initializers that conflicted with the overrides. Ignore these spurious conflicts, and also move a check out of IsObjCRequest and into the conflict-handling code.

Additional work towards rdar://70730077.
2022-10-27 17:00:43 -07: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
Luciano Almeida
a95f60e387 [AST] Refactor generic parameter list parse logic for AccessorDecl 2022-10-07 09:43:08 -03:00
Luciano Almeida
14c01144b2 [AST] Consider storage signature when computing opaque params implicit generic params 2022-10-03 22:48:22 -03:00
Pavel Yaskevich
1a79d93121 Merge pull request #40702 from calda/cal--implicit-weak-self
[SE-0365] Allow implicit self for `weak self` captures
2022-09-30 10:30:57 -07:00
Cal Stephens
5946c66962 Style updates 2022-09-23 07:09:52 -07:00
Cal Stephens
9dd56f9daf Move remaining logic in LookupResultEntry::getBaseDecl() to ASTScope::lookupUnqualified impl, add more extensive tests, fix failing tests 2022-09-22 11:04:08 -07:00
Angela Laar
dffafdb96b [test] fix tests 2022-09-21 12:02:48 -07:00
Angela Laar
4f3dff43f2 [Sema] Create Opaque Decls from Composition Types 2022-09-20 15:25:09 -07:00
Angela Laar
a7171c00f0 [AST] Add new ASTWalker actions to opaque type repr walker 2022-09-20 15:25:09 -07:00
Angela Laar
410fa12248 [AST] Create opaque type from tuple type repr 2022-09-20 15:25:09 -07:00
Angela Laar
4240b005b2 [Sema] Support GenericIdentTypeReprs as opaque parameters and return type 2022-09-20 15:25:09 -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
b12ecdb7ce [AST] Ignore existential types when building opaque parameter list 2022-09-20 15:25:09 -07:00
Angela Laar
22bbb012f4 [AST] Preserve type constraint for identifier type
Type contraints need to be passed when creating
generic parameters from identifier types.
2022-09-20 15:25:09 -07:00
Angela Laar
3b3e5a2c94 Avoid walking the nested type reprs for types reprs marked with 'some' keyword 2022-09-20 15:25:09 -07:00
Angela Laar
9458072467 [AST] Verify identifier type representations are protocols
Now that GenericParamListRequest and OpaqueResultTypeRequest know
to check for IdentTypeReprs when scanning for opaque parameters,
the requests need to know it should only create Generic Paramters
and Opaque Type Decls for IdentTypeReprs that are protocols.
We should add a function to the swift namespace to check.
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
Cal Stephens
03322bf716 Move implicit self lookup from resolveDeclRefExpr into ASTScope::unqualifiedLookup implementation 2022-09-20 07:06:54 -07:00
Slava Pestov
de0fd63f75 AST: Teach qualified lookup to find members of tuples 2022-09-10 00:26:42 -04:00
Slava Pestov
c1b8690401 AST: Introduce special Builtin.TheTupleType singleton 2022-09-10 00:26:42 -04:00
Doug Gregor
d2f6107946 Merge pull request #60982 from DougGregor/objc-async-alternative-cycle
Break dependency cycle between `@objc` checking and and "renamed" availability
2022-09-07 16:58:32 -07:00
Doug Gregor
97bd500f5b Break dependency cycle between @objc checking and and "renamed" availability.
The filtering used to allow `@objc` protocols to have both an `async` and a
completion-handler version of the same method was dependent on the
resolution of the "renamed" declaration (for `@available(..., renamed: "")`),
which in tern was dependent on whether the declaration is `@objc`... causing
a cycle. Break the cycle by moving the filtering later.

Fixes rdar://99618060.
2022-09-07 12:55:31 -07:00
Slava Pestov
79ed990728 AST: Replace TupleTypeRepr's ellipsis with PackExpansionTypeRepr 2022-09-07 12:35:54 -04:00
Slava Pestov
db4b4c9fa2 AST: Introduce PackExpansionTypeRepr 2022-09-07 12:35:53 -04:00
Robert Widmann
a8b5e14d9d [NFC] Remove An Unused Vector of Protocols 2022-08-26 17:46:58 -07:00
Slava Pestov
d9a3f2e5ce AST: Stop calling getAllConformances() on protocols 2022-08-23 00:03:36 -04:00
Becca Royal-Gordon
68c52937c5 Merge pull request #60394 from beccadax/private-defective
Allow extensions to define private module methods
2022-08-05 13:31:39 -07:00
Becca Royal-Gordon
600ced19e3 Allow extensions to define private module methods
Expands the unofficial “feature” that allows extensions to define @objc methods declared in headers for the same module to also allow this for methods in the private clang module.

Fixes rdar://97810819.
2022-08-04 11:01:17 -07:00
Slava Pestov
2338c43fc9 AST: Fix extension binding for @_specializedExtension hack 2022-08-02 23:12:24 -04:00