Commit Graph

783 Commits

Author SHA1 Message Date
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
Hamish Knight
fe7c1f4b9b Refactor callable lookup
Move off `Type` based requests and onto `Decl`
based requests, utilizing name lookup's
`extractDirectlyReferencedNominalTypes` utility.
This allows us to better cache the results, and
avoids the need to guard against type variable
inputs when deciding whether or not to cache.
2022-07-25 22:03:55 +01:00
Becca Royal-Gordon
e90876639c Further loosen selector conflict checks
Some mixed-language projects import Objective-C headers through their umbrella or bridging header that declare things that are actually implemented in Swift. This isn’t something we really supported or had tests for, but it happens in practice and we can’t break them.

Carve out a second exception to method conflict checking for when all of the conflicting methods are imported ObjC methods in either the same module or a bridging header.

Fixes rdar://96470068.
2022-07-19 15:41:49 -07:00
Becca Royal-Gordon
9b5f89963b [NFC] Serialize ObjC selectors for protocols
The ObjCMethodLookupTable for protocols was not being serialized and rebuilt on load, so NominalTypeDecl::lookupDirect() on selectors was not working correctly for deserialized types. Correct this oversight.
2022-06-16 14:07:49 -07:00
Becca Royal-Gordon
dc4162fddb Allow same-selector async/completion requirements
An @objc protocol can now explicitly declare both the `async` and completion handler signatures of a method as long as the completion handler one is marked with `@available(*, renamed:)`.

This is not yet handled correctly in PrintAsClang.
2022-06-16 14:06:47 -07:00
Becca Royal-Gordon
6de808e824 [NFC] Make ObjCMethodConflicts a set
This allows us to stop using `vec.size() == 1` to prevent duplicate conflicts from being diagnosed, which will become untenable in the next commit.
2022-06-16 14:06:47 -07:00
Pavel Yaskevich
b7860ea055 [TypeChecker] Split for-in sequence into parsed and type-checked versions 2022-05-30 23:17:41 -07:00
Richard Wei
11154e5ff6 [Sema] Allow code to shadow definitions in implicit _StringProcessing module.
Treat _StringProcessing decls as if it were declared in the Swift module, just like how _Concurrency is treated (#34642).
2022-05-02 16:31:52 -07:00
Rintaro Ishizaki
eade9b7bc9 [LookupVisibleDecls] Implement shadowing for unqualified lookups
Tweaked usable check:
  * Local type/func decls are usable even before declaration
  * Outer nominal Instance member are not usable
  * Type context cannot close over values in outer type contexts

Added shadowing rule by the base name:
  * Type members don't shadow each other as long as they are in the
    same type context.
  * Local values shadow everything in outer scope
    * Except that 'func' decl doesn't shadow 'var' decl if they are in the
      same scope.

rdar://86285396
2022-04-28 16:36:54 -07:00
Slava Pestov
f4a5f85797 Merge pull request #42293 from hank121314/main
[Sema] SR-15807: Associated Type Inference fails across module boundaries
2022-04-20 17:35:16 -04:00
Rintaro Ishizaki
4e621408aa [CodeCompletion] Ensure synthesized members are available before lookup
In ExprContextAnalyzer, when looking up members, some implicit
members weren't populated. Ensure all implicit members available by
force synthesizing them.

rdar://89773376
2022-04-15 11:47:36 -07:00
hank121314
1dabc67b5f [Sema] TypeCheckProtocolInference: using trailingWhereClause to get self bounds in source file. 2022-04-12 22:57:47 +08:00
John McCall
5519749ade [NFC] Collect protocol decls, not type, in ExistentialLayout
Another thing that will be necessary for correctness with
compositions of parameterized protocols.
2022-04-11 22:15:16 -04:00