Commit Graph

21693 Commits

Author SHA1 Message Date
Allan Shortlidge
3e50a90c45 AST: Introduce Decl::getUnavailableAttr().
It replaces `DeclAttr::getUnavailable()` and `AvailableAttr::isUnavailable()`
as the designated way to query for the attribute that makes a decl unavailable.
2024-12-02 07:35:58 -08:00
Allan Shortlidge
2358712870 AST/Sema: Remove DeclAttr::isUnavailable().
Update callers to use `Decl::isUnavailable()` instead.
2024-12-02 07:35:58 -08:00
Allan Shortlidge
1dc7aa5b7b AST: Introduce Decl::isUnavailable().
Replace calls to `AvailableAttr::isUnavailable()` with `Decl::isUnavailable()`.
2024-12-02 07:35:58 -08:00
Hamish Knight
73fb36f371 [AST] Split out "is compound" bit on FunctionRefInfo
FunctionRefKind was originally designed to represent
the handling needed for argument labels on function
references, in which the unapplied and compound cases
are effectively the same. However it has since been
adopted in a bunch of other places where the
spelling of the function reference is entirely
orthogonal to the application level.

Split out the application level from the
"is compound" bit. Should be NFC. I've left some
FIXMEs for non-NFC changes that I'll address in a
follow-up.
2024-12-02 14:11:33 +00:00
Hamish Knight
a4d51419ba [AST] NFC: Rename FunctionRefKind -> FunctionRefInfo 2024-12-02 14:11:32 +00:00
Allan Shortlidge
cd13d7d777 AST: Remove AvailableAttr::RenameDecl.
The renamed decl is now stored exclusively in the split request evaluator
storage, which is more efficient since most availability attributes do not
specify a renamed decl.
2024-11-29 10:35:02 -05:00
Allan Shortlidge
b6353b0abd AST: Don't copy cached rename decls when inferring availability. 2024-11-29 10:34:49 -05:00
Allan Shortlidge
e6741d5e9e AST: Adopt ValueDecl::getRenamedDecl().
This unblocks removing `RenameDecl` from `AvailableAttr`.
2024-11-29 10:34:49 -05:00
Allan Shortlidge
9d884bfbcb AST: Adopt split caching for RenamedDeclRequest.
In the common case where there is no renamed decl for the attribute, just set a
few bits in inline storage for `AvailableAttr`.
2024-11-29 10:34:49 -05:00
Egor Zhdan
839f8411b3 [AST] NFC: Fix build warning on Windows
This fixes a warning emitted by MSVC when building Swift.
2024-11-28 13:30:19 +00:00
Jakub Florek
866f1c1c04 Merge branch 'main' into swift-lexical-lookup-validation 2024-11-26 09:37:23 +01:00
Allan Shortlidge
5de7211984 AST: Rename createForAlternative() to createForAsyncAlternative(). 2024-11-22 14:35:47 -08:00
Allan Shortlidge
88c0638f37 AST: Introduce a ValueDecl convenience for looking up the renamed decl.
Wrap `RenamedDeclRequest` instead of evaluating it directly.
2024-11-22 14:35:23 -08:00
Slava Pestov
d11db16f16 Merge pull request #77786 from slavapestov/workaround-rdar139469939
AST: Workaround for rdar://139469939
2024-11-21 19:15:07 -05:00
Pavel Yaskevich
eaef8e7474 Merge pull request #77778 from xedin/remove-substituion-printing-for-opaque-decls
[ASTDumper] Don't try to print opaque type decl substitutions
2024-11-21 15:16:03 -08:00
Allan Shortlidge
ad7383499b Merge pull request #77758 from tshortli/available-attr-conveniences
AST: `AvailableAttr` cleanup
2024-11-21 13:03:07 -08:00
Slava Pestov
b70c76233e AST: Workaround for rdar://139469939
This unconditional assert was added recently so it started failing in
noassert toolchains. I'll have a proper fix soon.
2024-11-21 15:24:35 -05:00
Hamish Knight
23e3f5f5de Merge pull request #77666 from hamishknight/lets-try-this-again
[AST] Remove `ModuleDecl::addFile`
2024-11-21 20:15:58 +00:00
Pavel Yaskevich
0fe4cea7d7 [AST] Introduce a new type that has associated location in source
This type is intended to be used to wrap compiler synthesized nodes
(i.e. variables) to make it easier for diagnostic to diagnose precise
failure locations.

Consider the situation like:

```
protocol P {}

extension Array: P where Element: P {}

func test<T: P>() -> T {
  $_a = ...
  $_b = ...
  return [$_a, $_b]
}
```

This is a common pattern with result builders.

In this case if one of the elements don't conform to `P` the best
user experience would be to attach diagnostic to the element otherwise
the developers would have to figure out where in result expression
the error occured before attempting to fix it.
2024-11-21 11:01:13 -08:00
Pavel Yaskevich
7151a9751a [ASTDumper] Don't try to print opaque type decl substitutions
Attempting to dump opaque decl while type-checking a body of
the declaration it's associated with results in a request
cycle because underlying substitutions request would trigger
type-checking if the body isn't type-checked yet.
2024-11-21 09:37:59 -08:00
Allan Shortlidge
afad02e393 AST: Adopt AvailableAttr::isLanguageVersionSpecific(). 2024-11-21 09:10:36 -08:00
Allan Shortlidge
2e03ba27e7 AST: Store Platform and PlatformAgnostic in AvailableAttr's bits. 2024-11-21 09:10:36 -08:00
Allan Shortlidge
36230cd9c6 AST: Use an accessor to get the PlatformKind from an AvailableAttr. 2024-11-21 09:10:36 -08:00
Allan Shortlidge
48f10f7dcf AST: Centralize definition of future availability triple. 2024-11-20 10:08:45 -08:00
Allan Shortlidge
e881a443b7 AST: Upstream missing future availability range for visionOS. 2024-11-20 10:08:45 -08:00
Allan Shortlidge
b3f6421091 AST: Remove DeclAttributes::getPotentiallyUnavailable().
This utility duplicated logic that is now meant to be encapsulated by
`getUnsatisfiedAvailabilityConstraint()`.
2024-11-19 17:19:51 -08:00
Allan Shortlidge
c3f8352d5c AST: Introduce AvailabilityContext::forDeploymentTarget(). 2024-11-19 17:19:51 -08:00
Allan Shortlidge
6bf0e628be AST: Rename AvailabilityContext::getDefault() to forInliningTarget().
Mirrors the factory methods on `AvailabilityRange`.
2024-11-19 17:19:51 -08:00
Nate Chandler
563f932a00 [NFC] Extracted predicate. 2024-11-19 15:52:24 -08:00
Nate Chandler
8eaae59c3b [NFC] AST: Moved impl from Sema.
Now that the function is declared in AST, it should be implemented
there.
2024-11-19 15:52:24 -08:00
Andrew Trick
e4e07603b1 Merge pull request #77695 from atrick/handle_markdep
[NFC] mark_dependence handling for coroutines and accessors.
2024-11-19 10:22:25 -08:00
Andrew Trick
a0b21d5e5b LifetimeDependence: broaden assert: allow trivial borrows.
During SIL parsing, allow `@``lifetime(borrow <argNum>)` on trivial arguments.
2024-11-18 22:02:44 -08:00
Meghana Gupta
5b5acc64e0 Promote Nonescapable types to a language feature 2024-11-18 18:09:17 -08:00
Meghana Gupta
ae28d667ff Introduce LifetimeDependence experimental feature 2024-11-18 18:08:32 -08:00
Hamish Knight
4946c799af [AST] Remove ModuleDecl::addFile
Rather than exposing an `addFile` member on
ModuleDecl, have the `create` members take a
lambda that populates the files for the module.
Once module construction has finished, the files
are immutable.
2024-11-17 14:17:20 +00:00
Slava Pestov
47156e006b AST: Introduce ProtocolConformanceRef::forAbstract() 2024-11-16 16:16:06 -05:00
Slava Pestov
8d05362f89 AST: Simplify some lookupConformance() callers 2024-11-16 16:16:06 -05:00
Doug Gregor
c5de02f60e Merge pull request #77628 from DougGregor/clang-importer-parse-request
[Clang importer] Use ParseSourceFileRequest for parsing swift_attr attributes
2024-11-16 01:12:27 -08:00
Slava Pestov
e3d2f75c52 Merge pull request #77632 from slavapestov/subst-map-verify
Flush out incorrectly-constructed substitution maps
2024-11-15 23:36:54 -05:00
Meghana Gupta
6248a2ab58 Merge pull request #77645 from meg-gupta/deleteinference
Delete lifetime dependence inference on mutating self
2024-11-15 14:37:51 -08:00
Slava Pestov
080f3d2950 AST: Fix up SubstitutionMap::verify() 2024-11-15 17:27:25 -05:00
Slava Pestov
a8bca07e54 AST: Fix handling of pack conformance requirements in RequirementEnvironment
If a generic signature states a requirement `each T: P`, we must wrap the
abstract conformance in a pack conformance first.

We let this slide before, but it's now flagged by SubstitutionMap::verify().
2024-11-15 17:26:35 -05:00
Slava Pestov
9d09f93a7f AST: Correctly use inherited conformances in RequirementEnvironment
When the conforming type is a class-constrained type parameter or
archetype, we must wrap the concrete superclass conformance in an
inherited conformance. This is now flagged by SubstitutionMap::verify().
2024-11-15 17:26:35 -05:00
Slava Pestov
2f28b9bcda AST: Don't forget to substitute opaque types in ProtocolConformance::subst()
We checked the wrong condition when deciding if a conformance should
be substituted or not, so we would leave behind opaque return types
in builtin and inherited conformances. This is now flagged by
SubstitutionMap::verify().
2024-11-15 17:26:35 -05:00
Jakub Florek
5b39ba66b8 Merge branch 'main' into swift-lexical-lookup-validation 2024-11-15 22:05:43 +01:00
Doug Gregor
24a12ebc34 Renable GeneratedSourceInfo::Attribute to GeneratedSourceInfo::AttributeFromClang 2024-11-15 09:02:49 -08:00
Doug Gregor
901ffb7978 Add static checking to ensure every DeclAttribute subclass has a properly-typed clone()
Code review identified some incorrect UNIMPLEMENTED_CLONEs in DeclAttribute (thank you
Hamish and Rintaro). Fix those, and make sure this can't happen again by checking the type
signatures of clone() in every DeclAttribute subclass.
2024-11-15 09:02:47 -08:00
Doug Gregor
7872fc6c4b Introduce DeclAttribute::clone() to clone declaration attributes (obviously) 2024-11-15 09:02:45 -08:00
Slava Pestov
da5ce1289c Merge pull request #77599 from slavapestov/fix-rdar139745699
IRGen: Adjust hacks for keypaths to protocol extension members
2024-11-15 12:02:25 -05:00
Meghana Gupta
daba1cb7bb Delete lifetime dependence inference on mutating self
We don't need this anymore since we have @lifetime(target: sources) syntax
2024-11-15 06:45:15 -08:00