Commit Graph

1007 Commits

Author SHA1 Message Date
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
Pavel Yaskevich
e6a6ecf44b [NameLookup] Lift synthesized protocol check into getDirectlyInheritedNominalTypeDecls
Some places use `getDirectlyInheritedNominalTypeDecls` directly
instead of fetching it through a request, so lift the check there
instead (direct use of `getDirectlyInheritedNominalTypeDecls`
could be refactored separately).
2023-11-16 10:58:34 -08:00
Pavel Yaskevich
e050e35c36 [AST] Teach InheritedProtocolsRequest about synthesized protocol attributes
ClangImporter converts NS_SWIFT_SENDABLE into `SynthesizedProtocolAttr`
which needs to be recognized by the request that collects all of the
protocols that the given protocol inherits.
2023-11-16 10:58:34 -08:00
Allan Shortlidge
b4c5cfd536 AST: Enumerate expanded attributes in TypeCheckAttr.
We need to avoid triggering semantic attribute requests in TypeCheckAttr
because it happens too early in type checking to trigger some semantic
attribute requests, and we only want to diagnose attributes that were written
in source anyways.
2023-11-01 10:44:28 -07:00
Allan Shortlidge
6d985e34a2 AST: Introduce Decl::getSemanticCustomAttrs().
In order to avoid triggering request cycles as `SemanticDeclAttrsRequest` grows
to cover a larger range of implicit attributes, we need a lighter-weight
accessor for just the CustomAttrs that have been expanded from macros.
Introduce `getSemanticCustomAttrs()` and adopt it where `getSemanticAttrs()`
had been previously used to enumerate macro expanded custom attributes.
2023-10-31 17:02:39 -07:00
Varun Dhand
f289c11814 Fix typo in NameLookup.cpp from paramter to parameter 2023-10-25 19:34:41 +05:30
Rintaro Ishizaki
03bf349778 [Macros] Improve visitation of auxiliary decls
Use the same pattern as 'getAllMembers()'. This supports nested macro
expansion:
```
std::function<void(Decl *)> visit;
visit = [&](Decl *d) {
  doIt(d);
  d->visitAuxiliaryDecls(visit);
};
for (auto *d : decls)
  visit(d);
```

Don't visit auxiliary decls in `PrintAST::visit(Decl *)` this function
is only intended for single decl printing. The caller should visit them
separately. For that, add
`ModuleDecl::getTopLevelDeclsWithAuxiliaryDecls()`
2023-10-23 14:51:12 -07:00
Harlan Haskins
4ac34a40ea @retroactive conformance syntax and checking (#36068) 2023-10-20 14:27:03 -07:00
Kavon Farvardin
c01360d02e [Sema] reimplement ~C as an general inverse constraint 2023-09-20 09:34:06 -07:00
Slava Pestov
973a5065e2 Merge pull request #68282 from slavapestov/sema-tuple-conformances
(More) Declaration checker support for tuple conformances
2023-09-07 11:57:05 -04:00
Allan Shortlidge
0dd8f4c492 AST: Introduce abstraction for extension/type decl inheritance clauses.
Wrap the `InheritedEntry` array available on both `ExtensionDecl` and
`TypeDecl` in a new `InheritedTypes` class. This class will provide shared
conveniences for working with inherited type clauses. NFC.
2023-09-06 10:41:57 -07:00
Slava Pestov
d5cdfb2cf2 AST: Clone generic parameter list of tuple extension from extended typealias 2023-09-05 23:21:27 -04:00