Commit Graph

1018 Commits

Author SHA1 Message Date
James Brown
2c281208de 56350 - Give Identifier a hasUnderscoredNaming() helper and in the places currently using str().startsWith, change it to use the new helper. 2024-03-04 19:34:11 -05:00
Doug Gregor
cff918428a Implement proper visibility rules for imported extensions
If an extension isn't imported either directly or via a transitive
(`@_exported`) import, its members should not be visible to name
lookup. Implement this behavior behind the experimental flag
ExtensionImportVisibility.
2024-03-04 07:43:54 -08:00
Anthony Latsis
5b7a8b6705 [NFC] AST: Rename MemberTypeReprQualifiedIdentTypeRepr 2024-03-02 14:59:37 +03:00
Anthony Latsis
5d848e784f [NFC] AST: Merge SimpleIdentTypeRepr & GenericIdentTypeRepr into UnqualifiedIdentTypeRepr 2024-03-02 14:59:37 +03:00
Anthony Latsis
a315b22ff7 Remove non-essential uses of SimpleIdentTypeRepr & GenericIdentTypeRepr 2024-03-02 14:59:21 +03:00
Anthony Latsis
7e7f6d8d61 [NFC] AST: Construct SimpleIdentTypeRepr & GenericIdentTypeRepr through IdentTypeRepr 2024-03-02 08:28:47 +03:00
Pavel Yaskevich
85179e022a [AST] Make sure that InheritedProtocols::evaluate is never called on a deserialized protocol
The result should always be pre-cached by the deserialization.
2024-02-29 00:14:15 -08:00
Slava Pestov
b8a6a9ec41 AST: Remove dead code 2024-02-24 07:25:59 -05:00
Slava Pestov
443919a9bf AST: Introduce ProtocolDecl::getAllInheritedProtocols() 2024-02-24 07:25:59 -05:00
Slava Pestov
bd06653ee9 AST: Expand defaults in InheritedProtocolsRequest::evaluate() 2024-02-24 07:25:59 -05:00
Slava Pestov
80b5eca9e8 AST: Reject deserialized ProtocolDecl in getDirectlyInheritedNominalTypeDecls() 2024-02-24 07:25:59 -05:00
Slava Pestov
6460469115 AST: Directly implement InheritedProtocolsRequest for deserialized protocols 2024-02-24 07:25:59 -05:00
Slava Pestov
7909d83229 AST: Refactor directReferencesForTypeRepr() to track inverses 2024-02-24 07:25:59 -05:00
Slava Pestov
1d89f9b8f0 AST: Remove unused variable 2024-02-20 18:26:05 -05:00
Pavel Yaskevich
11ef6e58d8 Merge pull request #71659 from xedin/noncopyable-circularity-fixes
[AST/Sema] NonCopyableGenerics: Address some of the request circularity issues
2024-02-20 12:38:16 -08:00
Konrad `ktoso` Malawski
f03ddf728b [Macros] Reproduce issue with peer+extension macro extension's methods not being checked as witnesses (#71717)
Co-authored-by: Pavel Yaskevich <pyaskevich@apple.com>
2024-02-20 00:50:29 -08:00
Pavel Yaskevich
b51600def2 [AST] Add a way to check whether TypeRepr is an inverse of the given invertible protocol 2024-02-16 17:55:52 -08:00
Slava Pestov
1c24b880ec Merge pull request #70467 from AnthonyLatsis/recursive-member-typerepr
AST: Remodel `MemberTypeRepr` to be recursive
2024-02-16 11:36:31 -05:00
Kavon Farvardin
4fb90d3e2c Merge pull request #71654 from kavon/ncgenerics-test-fixes-kavon-v14
Ncgenerics test fixes kavon v14
2024-02-15 14:04:50 -08:00
Kavon Farvardin
63ed8ec4a6 NCGenerics: handle legacy definition of Sendable
This should be a temporary measure while bootstrapping the feature.
2024-02-15 11:07:49 -08:00
Michael Gottesman
23ab974574 Merge pull request #71567 from gottesmm/transferring-param
[transferring] Implement transferring result and clean up transferring param support by making transferring a bit on param instead of a ParamSpecifier.
2024-02-14 17:54:48 -08:00
Doug Gregor
e008a4f86b Allow a throwing function to shadow a typed-throws one
This addresses a source compatibility issue with the introduction of
typed throws into the standard library.
Fixes https://github.com/apple/swift/issues/70970 / rdar://121149479.
2024-02-14 14:00:47 -08:00
Michael Gottesman
bf2ec7eb85 [transferring] Change transferring to no longer be a ParamSpecifier.
Instead it is a bit on ParamDecl and SILParameterInfo. I preserve the consuming
behavior by making it so that the type checker changes the ParamSpecifier to
ImplicitlyCopyableConsuming if we have a default param specifier and
transferring is set. NOTE: The user can never write ImplicitlyCopyableConsuming.

NOTE: I had to expand the amount of flags that can be stored in ParamDecl so I
stole bits from TypeRepr and added some logic for packing option bits into
TyRepr and DefaultValue.

rdar://121324715
2024-02-14 13:04:46 -08:00
Kavon Farvardin
74a3839cf3 Merge pull request #71515 from kavon/ncgenerics-test-fixes-kavon-v7
Ncgenerics test fixes kavon v7
2024-02-09 19:39:18 -08:00
Slava Pestov
06b1aee360 Evaluator: Cache circular evaluation to avoid redundant diagnostics
Previously, if a request R evaluated itself N times, we would emit N
"circular reference" diagnostics. These add no value, so instead let's
cache the user-provided default value on the first circular evaluation.

This changes things slightly so that instead of returning an
llvm::Expected<Request::OutputType>, various evaluator methods take
a callback which can produce the default value.

The existing evaluateOrDefault() interface is unchanged, and a new
evaluateOrFatal() entry point replaces
llvm::cantFail(ctx.evaluator(...)).

Direct callers of the evaluator's operator() were updated to pass in
the callback. The benefit of the callback over evaluateOrDefault() is
that if the default value is expensive to constuct, like a dummy
generic signature, we will only construct it in the case where a
cycle actually happened, otherwise we just delete the callback.

(cherry picked from commit b8fcf1c709efa6cd28e1217bd0efe876f7c0d2b7)
2024-02-09 16:02:24 -08:00
Anthony Latsis
ef931342ad AST/ASTWalker: Refactor for recursive MemberTypeRepr representation 2024-02-09 17:33:21 +03:00
Anthony Latsis
e5413c9856 [NFC] AST/NameLookup: Refactor for recursive MemberTypeRepr representation 2024-02-09 17:22:56 +03:00
Anthony Latsis
fd4094cf09 [NFC] Introduce TypeRepr::isSimpleUnqualifiedIdentifier to simplify some code 2024-02-09 17:22:56 +03:00
Anthony Latsis
d6fd424560 [NFC] MemberTypeRepr: getBaseComponent()getRoot() 2024-02-09 17:22:05 +03:00
Hamish Knight
e380c66238 Merge pull request #71357 from hamishknight/scoped-down
Remove FindLocalVal
2024-02-09 10:57:23 +00:00
Becca Royal-Gordon
8621508098 Merge pull request #71320 from beccadax/globally-lazy-maximum
[ClangImporter] Support lazy member loading for import-as-member globals in extensions
2024-02-08 12:13:32 -08:00
Hamish Knight
f4b928fd0a Remove FindLocalVal
Replace with an ASTScope lookup. This also lets
us simplify UsableFilteringDeclConsumer, and fixes
a couple of completion bugs.
2024-02-07 23:02:37 +00:00
Hamish Knight
09ab888d89 NFC: Rename DeclVisibilityKind::LocalVariable -> LocalDecl
This includes local types, so make the name a bit
more generic.
2024-02-07 23:02:37 +00:00
Hamish Knight
7b012d825c Merge pull request #70600 from hamishknight/postal-service
[ASTWalker] Continue post-walking with `Action::SkipChildren`
2024-02-06 10:24:38 +00:00
Holly Borla
1707e76ba8 [Macros] Expand nested macros in qualified name lookup. (#71407) 2024-02-06 15:45:24 +09:00
Hamish Knight
16cfca4186 [ASTWalker] NFC: Rename SkipChildren -> SkipNode
This better describes what the action currently
does, and allows us to re-introduce `SkipChildren`
with the correct behavior.
2024-02-05 15:27:25 +00:00
Rintaro Ishizaki
b839718351 [AST] Use scoped enum for attribute kinds
Align with other kind enum e.g. DeclKind.
2024-02-02 09:36:48 -08:00
Rintaro Ishizaki
07bb0380a1 [AST] Use class names for type attribute kind enum
Align with DeclAttrKind.
2024-02-02 09:36:47 -08:00
Becca Royal-Gordon
3835a4b323 [NFC] [ClangImporter] Fully support lazy loading
Previously, the lazily-created extensions used for globals imported as members of a type used the lazy module loader, but `ClangImporter::Implementation::loadNamedMembers()` didn’t actually work for them. Other parts of the compiler instead contrived to avoid loading these members by name by forcing all members to load before any selective loading might occur.

This commit modifies that code path to accommodate extensions with no matching clang node, which is how these are represented. With this change, other parts of the compiler can unconditionally use the `LazyMemberLoader` whenever it is present.

There may be performance improvements from this change, but I don’t expect any functional changes.
2024-02-01 13:25:33 -08:00
Becca Royal-Gordon
a8b3ef4e4c [NFC] Merge extension member lookup code paths
There are two pieces of code that can add an extension’s members to a type’s lookup table: `NominalTypeDecl::prepareLookupTable()`, which initializes the lookup table before its first use, and `NominalTypeDecl::addedExtension()`, which only updates a lookup table that has already been initialized. The two functions ought to do the same things, but it’s difficult to predict which one will be exercised by a given test, and in practice our current unit tests only seem to use `NominalTypeDecl::prepareLookupTable()` in certain important situations.

Factor the common code into a shared helper method, `MemberLookupTable::addExtension()`, to increase our confidence that both code paths will work correctly even if only one is hit by our unit tests.

Fixes rdar://121479725.
2024-02-01 12:41:41 -08:00
Meghana Gupta
28f27c3da1 Merge pull request #71069 from meg-gupta/lifetimedependencelangattr
Initial language support for lifetime dependence
2024-01-25 00:39:13 -08:00
Meghana Gupta
0cb805bccf Add Sema support for LifetimeDependence 2024-01-24 15:01:15 -08:00
Pavel Yaskevich
b4dbd97c34 Merge pull request #71064 from xedin/refactor-intrinsics-lookup-into-request
[SILGen] NFC: Convert intrinsic function lookup into a request
2024-01-23 09:18:04 -08:00
Pavel Yaskevich
9e056a1fa2 [SILGen] NFC: Convert intrinsic function lookup into a request 2024-01-22 11:25:49 -08:00
Anthony Latsis
96ee57b00b Merge pull request #70623 from AnthonyLatsis/init-sema
Move unqualified `init` diagnosis from Parse to Sema
2024-01-18 03:53:33 +03:00
Pavel Yaskevich
e8b7a26eac [AST] Add a flag to indicate that the conformance is @preconcurrency 2024-01-16 11:51:42 -08:00
Anthony Latsis
bd2f48d9d2 [NFC] AST: Introduce and use Identifier::isConstructor 2023-12-25 21:09:17 +03:00
Zhiyu Zhu/朱智语
5767e8f6d1 [Macros] Support module-qualified attached macro lookup (#69457)
Allow attached macro expansion syntax to have a module qualifier, `@Foo.Bar`.

rdar: //108621205
2023-12-08 15:57:51 -08:00
Meghana Gupta
b6326f5f24 Add initial support for _resultDependsOn
These attributes are used to establish lifetime dependence between
argument and the result.

Add them under NonEscapableTypes experimental feature
2023-12-06 16:38:38 -08:00
Doug Gregor
c060a90fe0 Generalize the LCA implementation in ASTScope for arbitrary macro nesting
The prior Least Common Ancestor (LCA) implementation in ASTScope, which
is used to search child scopes to find a particular location, assumed
that the source range it was given was contained within a single
buffer and was specific to the child-scope search task. Generalize
this to a more fundamental "is before" operation on source locations
that respects macro expansions, simplifying the code in the process.
2023-11-30 08:28:44 -08:00