Commit Graph

126 Commits

Author SHA1 Message Date
Doug Gregor
1b7707d2cc Remove the now-unused @safe(unchecked) 2025-01-10 10:39:16 -08:00
Michael Gottesman
5d4239af57 [concurrency] Add new isolation kind CallerIsolationInheriting.
Right now it is basically a version of nonisolated beyond a few simple cases
like constructors/destructors where we are pretty sure we want to not support
this.

This is part of my bringup strategy for changing nonisolated/unspecified to be
caller isolation inheriting.
2025-01-02 13:18:30 -08:00
Doug Gregor
5b90b8851a Generalize protocol conformance options spelled via attribute and incorporate @unsafe
Protocol conformances have a handful attributes that can apply to them
directly, including @unchecked (for Sendable), @preconcurrency, and
@retroactive. Generalize this into an option set that we carry around,
so it's a bit easier to add them, as well as reworking the
serialization logic to deal with an arbitrary number of such options.

Use this generality to add support for @unsafe conformances, which are
needed when unsafe witnesses are used to conform to safe requirements.
Implement general support for @unsafe conformances, including
producing a single diagnostic per missing @unsafe that provides a
Fix-It and collects together all of the unsafe witnesses as notes.
2024-12-20 23:16:23 -08:00
Becca Royal-Gordon
01b8bbea89 Tie attributes to language features
The new `DECL_ATTR_FEATURE_REQUIREMENT` macro in DeclAttr.def can be used to declare that an attribute should only be available when a related language feature is enabled.

Effects:

• `#if hasAttribute(someAttr)` will return `false` unless the required feature is enabled.
• Code completion will not include the attribute unless the required feature is enabled.
• `TypeChecker::checkDeclAttributes()` diagnoses non-implicit uses of the attribute.

Add this mechanism and use it to tie @abi to the ABIAttribute feature. Also design tests for it.
2024-12-19 15:49:34 -08: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
Hamish Knight
472ef565c1 Merge pull request #77711 from hamishknight/fix-completion-crash
[Completion] Fix crash in `getTypeOfMember`
2024-11-20 21:45:05 +00:00
Hamish Knight
9f17fc9dd4 [Completion] Fix crash in getTypeOfMember
Make sure we only attempt to query the concrete
type for `Self` for a constrained protocol
extension.

rdar://138774888
2024-11-19 20:02:46 +00:00
Hamish Knight
c19d049493 [Completion] Fix invertible type completion
The previous logic for this was unused, replace
it with new logic that consults
InvertibleProtocols.def for the list of protocols
to suggest.

rdar://139212286
2024-11-19 12:12:21 +00:00
Hamish Knight
d877d05524 [Completion] Fix Sendable KeyPath dynamic member subscripts
Introduce `getKeyPathTypeForDynamicMemberLookup`
which returns the KeyPath type, and can be used
from both `RootAndResultTypeOfKeypathDynamicMemberRequest`
and `isValidKeyPathDynamicMemberLookup`. This ensures
we look to the superclass for e.g protocol compositions
with `Sendable`. This also means we now return an
interface type, which is what the client of
`RootAndResultTypeOfKeypathDynamicMemberRequest`
wanted anyway.

rdar://138418296
2024-11-18 22:22:43 +00: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
0c2f28fd3d AST: Remove GenericSignature parameter from OpenedArchetypeType::get() 2024-08-20 12:15:27 -04:00
Slava Pestov
9a5408c571 IDE: Remove a usage of ArchetypeType::getRoot() 2024-08-19 16:55:11 -04:00
Slava Pestov
b601c294ac AST: Replace remaining uses of Type::transform() with transformRec() 2024-08-12 16:05:43 -04:00
Slava Pestov
375363a473 AST: Move global conformance lookup entry points to ConformanceLookup.h 2024-08-08 23:35:58 -04:00
Alex Hoppen
6f86e24acf [CodeCompletion] Use Self type in extension for generic substitution when doing implicit member lookup on protocol type
This fixes the regression introduced in https://github.com/swiftlang/swift/pull/75068#discussion_r1679449260.
2024-08-02 10:41:37 -07:00
Slava Pestov
86d567f95a AST: ModuleDecl::lookupConformance() is a static method 2024-07-06 12:05:47 -04:00
Slava Pestov
fae01d9776 AST: Remove ModuleDecl parameter from more places 2024-07-06 12:05:46 -04:00
Hamish Knight
ec597c82fa [Completion] Only complete @unchecked et al in inheritance clauses
Add a case for completing type attributes in
inheritance clause position, and limit the
completion of `@unchecked`, `@preconcurrency`, and
`@retroactive` to that case.
2024-07-03 11:41:58 +01:00
Hamish Knight
42f563d6d8 [Completion] Use TypeAttr.def for simple type attributes
Pick up all non-underscored simple type attributes
for code completion, and add support for
`@isolated(any)`.

rdar://130741006
rdar://130288443
2024-07-03 11:41:58 +01:00
Hamish Knight
94ed2418f4 [Completion] Complete .isolation for @isolated(any) functions
This was added in SE-0431.

rdar://124615036
2024-07-01 12:49:52 +01:00
Hamish Knight
1f83e66a3e [Completion] NFC: Factor out addBuiltinMemberRef 2024-07-01 12:49:52 +01:00
Tim Kientzle
1d961ba22d Add #include "swift/Basic/Assertions.h" to a lot of source files
Although I don't plan to bring over new assertions wholesale
into the current qualification branch, it's entirely possible
that various minor changes in main will use the new assertions;
having this basic support in the release branch will simplify that.
(This is why I'm adding the includes as a separate pass from
rewriting the individual assertions)
2024-06-05 19:37:30 -07:00
Rintaro Ishizaki
79a7410206 [CodeCompletion] Remove CrossActorReference diagnostics too
Same for 'async in non-concurrency' context
2024-05-15 15:10:03 -07:00
Rintaro Ishizaki
39d633f5a8 [CodeCompletion] Remove unused 'isAsync' flag from CodeCompletionResult 2024-05-15 13:43:19 -07:00
Rintaro Ishizaki
46cc32e9a4 [CodeCompletion] Always print argument ':' in filterName
In annotated results.

rdar://124667867
2024-04-05 17:21:40 -07:00
Ben Barham
1fdda023b3 Rename StringRef::endswith references to StringRef::ends_with
Missed this when doing the `startswith` renaming. `endswith` has also
been deprecated upstream (and presumably soon to be removed).
2024-04-01 10:59:16 -07:00
Ben Barham
ef8825bfe6 Migrate llvm::Optional to std::optional
LLVM has removed llvm::Optional, move over to std::optional. Also
clang-format to fix up all the renamed #includes.
2024-02-21 11:20:06 -08:00
Doug Gregor
81ffafdc6a Merge pull request #70602 from ApolloZhu/macro/expression-as-default-argument
[Macros] Expression macro as caller-side default argument
2024-02-14 16:10:11 -08:00
Hamish Knight
e380c66238 Merge pull request #71357 from hamishknight/scoped-down
Remove FindLocalVal
2024-02-09 10:57:23 +00: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
John McCall
2f8a33cf0a Experimental type-checking support for @isolated(any) function types. 2024-02-06 22:54:27 -05:00
Apollo Zhu
b09a22a9a0 Somewhat working
Test shadowed variable of same type

Fully type check caller side macro expansion

Skip macro default arg caller side expr at decl primary

Test macro expand more complex expressions

Set synthesized expression as implicit

Add test case for with argument, not compiling currently

Test with swiftinterface

Always use the string representation of the default argument

Now works across module boundary

Check works for multiple files

Make default argument expression work in single file

Use expected-error

Disallow expression macro as default argument

Using as a sub expression in default argument still allowed as expression macros behave the same as built-in magic literals
2024-02-06 15:02:11 -08: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
8fdc4cc225 [AST] Split Attr.def to DeclAttr.def and TypeAttr.def 2024-02-02 09:36:49 -08: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
Slava Pestov
9bf51a9d3f IDE: Use GenericSignature::getUpperBound() 2024-02-01 23:35:33 -05:00
Alex Hoppen
ece521c12b Merge pull request #71046 from ahoppen/ahoppen/copyable-completion
[CodeComplete] Emit `Copyable` declaration instead of keyword
2024-01-22 17:22:51 -08:00
Alex Hoppen
4c4f3c004b Merge pull request #71063 from ahoppen/ahoppen/delete-dot-in-call
[CodeComplete] Delete `.` in completion suggestions of call pattern
2024-01-22 17:21:40 -08:00
Alex Hoppen
7087da9913 [CodeComplete] Emit Copyable declaration instead of keyword
Now that there is an actual declaration for `Copyable` we should be emitting that as a code completion result instead of a keyword, like we currently do.

rdar://109107817
2024-01-22 12:34:38 -08:00
Alex Hoppen
88275d48e6 [CodeComplete] Delete . in completion suggestions of call pattern
Previously, were were suggesting to add `()` after eg. `x.` if `x` has a function type, resulting in `x.()`, which is incorrect. We need to remove the `.` in the completion suggestion.

rdar://121155241
2024-01-22 12:29:05 -08:00
Holly Borla
47afd21d85 [Concurrency] Remove ActorIsolation::GlobalActorUnsafe. 2024-01-21 21:05:33 -08:00
Holly Borla
f581eb7d1b [Concurrency] Remove remaining special cases of ActorIsolation::GlobalActorUnsafe. 2024-01-21 21:05:33 -08:00
Slava Pestov
0f072b4803 IDE: Clean up isMemberDeclAppliedInternal()
In preparation for checkRequirements() asserting upon encountering
type parameters. Should be NFC.
2024-01-17 13:08:46 -05:00
Slava Pestov
a7f484b3a4 AST: Clean up isSendableType() 2024-01-16 22:44:43 -05:00
Rintaro Ishizaki
a8ae8e4b8c [CodeCompletion] Check if stdlib decls exist
In some configurations e.g. 'Embedded', some stdlib types don't exist.
We cannot just assume they are always available.

rdar://119691781
2024-01-03 16:31:10 -08:00
Doug Gregor
36a2dcd927 Implement function body macros
Function body macros allow one to introduce a function body for a
particular function, either providing a body for a function that
doesn't have one, or wholesale replacing the body of a function that
was written with a new one.
2023-11-27 17:04:55 -08:00
Alex Hoppen
adc9cc9c72 [CodeComplete] Prefer function call if both reference and call are possible
The real-world use case here is the `Task` initializer in the added test case. In general, we should only prefer to insert an unapplied function reference if it has a better type relation than calling the function because, in most cases, you want to call functions and not get unapplied references to them.

rdar://90456105
2023-11-23 10:44:17 -08:00
Sophia Poirier
4c9a726183 nonisolated(unsafe) to opt out of strict concurrency static checking for global variables 2023-10-26 16:22:28 -07:00
Alex Hoppen
8550799eba [CodeCompletion] Call hasStorage instead of getImplInfo().hasStorage() to determine if a variable is stored
This uncovered a discrepancy between `getImplInfo().hasStorage()` and `hasStorage()`.
2023-09-27 11:19:21 -07:00