Commit Graph

33 Commits

Author SHA1 Message Date
Hamish Knight
d7fea157a1 [IDE] Remove fallback type-checking logic
This should no longer be necessary, rip it out.
2025-08-30 14:08:42 +01:00
Hamish Knight
62f1303bca [IDE] Fix assertion failure in PostfixCompletionCallback::Result::tryMerge
Unfortunately due to pre-checking multiple times the recorded
application level can change. Just OR the bits together.
2025-07-18 11:00:37 +01:00
Hamish Knight
f49b7604ae [IDE] Refactor isUnappliedFunctionRef
Switch to using `hasAppliedSelf` to match the constraint system, and
flip the check to more accurately describe what we're checking which
is really "is application fully applied"?
2025-07-18 10:59:22 +01:00
Hamish Knight
839e20b8ca [Completion] Assert we have a type in getClosureActorIsolation
Previously we could end up in cases where we pick the wrong
DeclContext in `TypeCheckASTNodeAtLocRequest` since we previously
weren't checking source ranges, which could result in skipping the
type-checking of an outer closure. Now that we correctly pick the
DeclContext, we should no longer hit that case, so we should be able
to fall into `getTypeForCompletion` and assert that the solution has
a type. Also while here let's upgrade that assert to a
`CONDITIONAL_ASSERT`.
2025-05-14 11:15:42 +01: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
Hamish Knight
27995eed19 [Completion] Type-check parent closures for local functions
Local functions can capture variables from parent
closures, so we need to make sure we type-check
parent closures when doing completion in a local
function. Ideally we ought to be able to be more
selective about the elements of the parent closure
that we type-check, but that's a more complex change
I'm leaving as future work for now.
2024-11-11 19:34:21 +00:00
Hamish Knight
3c16ecf568 [Sema] Remove preCheckExpression
There are only a couple of clients left using this,
migrate them onto `preCheckTarget`.
2024-08-28 15:09:40 +01:00
Hamish Knight
22b08da0dd [Sema] Remove replaceInvalidRefsWithErrors param
Doesn't seem like anything is relying on setting
this to `false` anymore, remove it.
2024-07-21 15:27:15 +01:00
Tim Kientzle
1098054291 Merge branch 'main' into tbkka-assertions2 2024-06-18 17:52:00 -07:00
Hamish Knight
30af99e47e [Completion] Better handle merging of lookup base types
For unresolved member completion, we were preferring
the more general type, when we ought to be preferring
the more specific type. Additionally, for both
unresolved member and postfix completion we were
opening archetypes, which doesn't work as expected
since we don't compare requirements. Factor out
the logic that deals with merging base types for
lookup, and have it prefer either the subtype, or
the optional type in the case of optional promotion.

rdar://126168123
2024-06-07 10:04:31 +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
Hamish Knight
d7fc22aaca [IDE] Simplify isImplicitSingleExpressionReturn
Use the generalized implied result logic, and
rename to `isImpliedResult` since that's really
what we're querying here, and it needs to handle
implicit-last-exprs if enabled.
2024-02-07 18:14:23 +00:00
Hamish Knight
3d06f0d7c0 [CodeComplete] Improve ExpectsNonVoid computation
If we know we have a Void expected type, don't set
`ExpectsNonVoid` to `true`.
2024-01-29 21:26:08 +00:00
Alex Hoppen
b603a5e9a0 [Sema] Remove LeaveClosureBodiesUnchecked
This shouldn’t be needed anymore since we migrated code completion to be solver-based.

rdar://91403086
2023-11-23 11:41:29 -08:00
Holly Borla
97f1e617fd [Concurrency] Replace ClosureActorIsolation with ActorIsolation throughout
the isolation query APIs.
2023-09-16 12:21:36 -07:00
Alex Hoppen
acc6c10344 Merge pull request #68075 from ahoppen/ahoppen/labeled-trailing-closure-solver-based
[CodeCompletion] Migrate labeled trailing closure completions to solver-based
2023-09-06 13:10:56 -07:00
Alex Hoppen
a1bfb510e1 [CodeCompletion] Migrate labeled trailing closure completions to solver-based
rdar://113472967
2023-08-24 15:41:36 -07:00
Alex Hoppen
72cadecf21 [CodeCompletion] Split result delivery into a result colleciton and consumer phase
This will allow us to run two different completion kinds and deliver results from both of them.

Also: Compute a unified type context for global lookup. Previously, we always used the expected type context of the last lookup. But really, we should be considering all possible types from all constraint system solutions when computing code completion results from the cache.
2023-08-24 15:41:36 -07:00
Alex Hoppen
4702f82914 [CodeCompletion] Check getContextualType in getTypeForCompletion 2023-08-24 08:48:36 -07:00
Alex Hoppen
5d201131c1 [CodeCompletion] Migrate yield completions to solver-based
We didn’t actually have any tests for this. Completions aren’t great here at the moment but since this is an underscored language feature it’s not that important at the moment.
2023-08-23 13:07:56 -07:00
Alex Hoppen
3670b16754 [CodeCompletion] Migrate completion of ReturnStmtExpr to solver-based 2023-08-23 13:07:56 -07:00
Alex Hoppen
f2017b82ac [IDE] Don't fallback type check if the completion expression is inside a closure 2023-07-07 19:51:01 +02:00
Alex Hoppen
71937667f2 [IDE] Don’t return any result if the base expression’s type in postfix completion couldn’t be inferred 2023-07-07 19:51:01 +02:00
Alex Hoppen
d3270c1476 [CodeCompletion] Calling a static function on a type is not unapplied 2023-07-07 19:51:01 +02:00
Alex Hoppen
00eaed3af9 [CodeCompletion] Migrate postfix expr completion to solver-based 2023-07-07 19:51:01 +02:00
Alex Hoppen
6cec68e302 [IDE] Ignore score kinds that represent implicit conversions when solving for code completion
Ignore conversion score increases during code completion to make sure we don't filter solutions that might start receiving the best score based on a choice of the code completion token.
2023-07-07 19:50:46 +02:00
Hamish Knight
54c2fbf6f3 [CS] NFC: Add Solution::getTargetFor 2023-03-07 15:16:34 +00:00
Hamish Knight
2976edbe20 [CS] Rename SolutionApplicationTarget -> SyntacticElementTarget 2023-03-06 20:54:06 +00:00
Alex Hoppen
ff7e11c83f [CodeComplete] Fix crash when completing in a string literal in a result builder 2023-02-14 09:40:56 +01:00
Alex Hoppen
9f4e1926b6 [CodeCompletion] Use type from solution to determine actor isolation 2023-02-14 09:40:56 +01:00
Alex Hoppen
26e237c4ae [CodeCompletion] Disallow void when code completion expr is a solution application target whose result is not unused
This happens if the code completion expression initializes a variable in a multi-statement closure that doesn’t have LeaveClosureBodiesUnchecked set.
2023-02-14 09:40:55 +01:00
Alex Hoppen
803e667024 [CodeCompletion] Rename DotExprCompletion -> PostfixCompletion 2022-07-01 15:57:54 +02:00