Commit Graph

3616 Commits

Author SHA1 Message Date
Doug Gregor
fb0f48339a Make @c attribute user-accessible
This makes it available for hasAttribute(c) checks and show up in code
completion.

Fixes rdar://167554912.
2026-01-05 09:39:15 -08:00
Doug Gregor
22ee05e2db Merge pull request #86273 from DougGregor/stdlib-alphabetical-order 2026-01-04 23:28:48 +00:00
Doug Gregor
13b590d99b Make test order-insensitive 2026-01-04 05:12:55 +01:00
Hamish Knight
d104ab53fc [test] Disable editor_placeholder_exec.swift for back deployment 2025-12-16 11:02:24 +00:00
Artem Chikin
8e97cb4d8d Implement support for unified warning group behavior queries per-diagnostic
Unified across module-wide configuration flags (`-Wwarning`, `-Werror`, etc.) and syntactic configuration attribute `@warn`.
2025-12-12 10:14:20 -08:00
Kathy Gray
fde49b8847 Diagnostics : Increase possibility for missed property diagnostic
Impact for an unknown property access was frequently higher than other options
on ambiguous selections, by 3 to 5 points, causing fix selections that were
farther away and frequently noted to be in accurate. This commit lowers the
impact to be in a similar range to other fixes and this causes property accesses
to be selected more proprotionaly.

In the existing test suite, this changed the diagnostic only in the case of
protocol composition, which was also discovered to be a flawed binding lookup.

Tests added for the property lookup, tests updated for protocol composition
(Including correcting a likely error in a test specification)
2025-12-11 16:08:22 +00:00
Hamish Knight
d8a867df86 [Demangler] Handle invertible reqs for extensions in findDeclContext
If we didn't find an extension result, try again disregarding
invertible requirements since `demangleGenericSignature` won't
include them. This is just meant to be a quick low risk fix that we
can cherry-pick, the proper fix here is to delete all this logic and
just return the nominal along with the ABI module name to filter
lookup results.

rdar://165639044
2025-12-08 12:21:29 +00:00
Hamish Knight
ae82b29e35 Rework emission of EditorPlaceholderExprs
Rather than synthesizing a semantic expression to emit, add a compiler
intrinsic to the stdlib that is simple enough to just SILGen the
emission.
2025-11-30 11:12:39 +00:00
Hamish Knight
e7f5ca954b [Sema] Better handle recovery for structurally invalid ReturnStmts
Make sure we preserve the result expression for an out-of-place
`return`, or a non-`nil` result in an initializer. This ensures we
can still provide semantic functionality from them and fixes a crash
where we would fail to type-check a binding.
2025-11-17 13:07:36 +00:00
Hamish Knight
ea79f675ff [test] Convert complete_return to batch-code-completion 2025-11-17 13:07:36 +00:00
Hamish Knight
14608cb059 [Sema] Skip type-checking catch bodies when computing the bound error type
Make sure we only ever type-check the `do` body of a `do-catch`
statement when lazily type-checking the bound error type, which we can
do for completion.

rdar://164481242
2025-11-11 23:04:30 +00:00
Doug Gregor
020b69d4b6 [SE-0497] Implement @export attribute syntax
Implement the @export(implementation) and @export(interface) attributes
to replace @_alwaysEmitIntoClient and @_neverEmitIntoClient. Provide a
warning + Fix-It to start staging out the very-new
@_neverEmitIntoClient. We'll hold off on pushing folks toward
@_alwaysEmitIntoClient for a little longer.
2025-11-07 22:00:40 -08:00
Allan Shortlidge
92227ad1cf AST: Introduce the Swift, anyAppleOS, and DriverKit platform kinds.
This change just stages in a few new platform kinds, without fully adding
support for them yet.

- The `Swift` platform represents availability of the Swift runtime across all
  platforms that support an ABI stable Swift runtime (see the pitch at
  https://forums.swift.org/t/pitch-swift-runtime-availability/82742).
- The `anyAppleOS` platform is an experimental platform that represents all of
  Apple's operating systems. This is intended to simplify writing availability
  for Apple's platforms by taking advantage of the new unified OS versioning
  system announced at WWDC 2025.
- The `DriverKit` platform corresponds to Apple DriverKit which is already
  supported by LLVM.
2025-10-27 19:15:04 -07:00
Guillaume Lessard
dc759fded8 [test] add Android to availability attribute test (#85057)
Following up to https://github.com/swiftlang/swift/pull/84574
2025-10-23 19:31:31 +05:30
Hamish Knight
2ce7f1c3bb [Sema] Add for-in lazy type-checking hack for IDE inspection
Avoid type-checking the `where` clause when computing the interface
type of a variable bound in the pattern of the loop as otherwise that
will trigger cycles and give us an ErrorType result.
2025-10-08 21:16:02 +01:00
Hamish Knight
43970362ca [test] Convert complete_loop to %batch-code-completion 2025-10-08 21:16:02 +01:00
Henrik G. Olsson
d3214de950 Merge pull request #84685 from hnrklssn/verify-all
This adds the -verify-ignore-unrelated flag. When -verify is used without -verify-ignore-unrelated, diagnostics emitted in buffers other than the main file and those passed with -verify-additional-file (except diagnostics emitted at <unknown>:0) will now result in an error. They were previously ignored. The old behaviour is still available as opt-in using -verify-ignore-unrelated, but by being strict by default it should make it harder to accidentally miss diagnostics.

To avoid unnecessary performance overhead, -verify-additional-file is still required to parse the expected-* directives in files other than the main file.
2025-10-06 18:01:47 -07:00
Henrik G. Olsson
cbc0ec3b88 Add -verify-ignore-unrelated where necessary (NFC)
These are tests that fail in the next commit without this flag. This
does not add -verify-ignore-unrelated to all tests with -verify, only
the ones that would fail without it. This is NFC since this flag is
currently a no-op.
2025-10-04 14:19:52 -07:00
Hamish Knight
669a2ce9b0 [CS] Sink placeholder handling logic into Solution::simplifyType
Move the logic from `FailureDiagnostic::resolveType` into
`Solution::simplifyType` to allow completion to use it too. While
here, also handle cases where the placeholder is from a different
member of the equivalence class to the generic parameter.
2025-10-04 12:56:52 +01:00
Henrik G. Olsson
90e3d1c415 Merge pull request #84604 from ramonasuncion/test-ide-frontend-env
[Test][IDE] Add env to frontend commands
2025-10-01 18:55:11 -07:00
Ramon Asuncion
a8433351eb [Test][IDE] Add env to frontend commands 2025-09-30 19:47:47 -07:00
Ramon Asuncion
1ba5cbcbe7 [Test][IDE] Replace process substitution with temp file for internal shell
Replace `diff -u <(tail -n +9 %s) %t.txt` substitution with a temp file
for LLVMs LIT internal shell

Note: Start tail at line 10 to skip `// EXPECTED OUTPUT STARTS BELOW THIS LINE`
so the temp file matches the actual compiler output
2025-09-30 19:45:31 -07:00
Hamish Knight
cb61e89bc1 Merge pull request #84569 from hamishknight/ex-fail
[test] Remove some unnecessary completion XFAILs
2025-09-29 22:25:42 +01:00
Hamish Knight
3b056039de [test] Remove some unnecessary completion XFAILs
All the cases now work correctly and just need a small tweak to the
expectation.
2025-09-29 16:55:34 +01:00
Hamish Knight
a7dd04ed6f Merge pull request #84403 from a7medev/refactor/signature-help-to-ide
[IDE] Move signature help formatting to IDE instead of SourceKit
2025-09-29 14:05:02 +01:00
Ahmed Mahmoud
456a40a7bb [Test] Improve signature help tests 2025-09-26 22:39:46 +03:00
Hamish Knight
0bfbe987b4 [AST] Print ErrorType as _
In preparation for removing UnresolvedType in favor of ErrorType,
start printing ErrorType as `_` unless we've enabled debug printing.
`<<error type>>` should never be presented to the user, instead `_`
now just consistently means "unknown type".
2025-09-21 23:19:06 +01:00
Hamish Knight
14a125c2ca [IDE] Use consistent PrintOptions in swift-ide-test
Use the same set of PrintOptions when printing the results for
different requests.
2025-09-21 23:19:06 +01:00
Ahmed Mahmoud
236fed20aa [Test] Remove redundant signature parameter name="" in swift-ide-test 2025-09-19 21:03:05 +03:00
Ahmed Mahmoud
979ccd1f50 [Test] Use swift-ide-test for signature help tests 2025-09-19 21:03:05 +03:00
Hamish Knight
f1ad703430 [CS] Avoid skipping SingleValueStmtExpr branch with ReturnStmt for completion
We still need to solve a branch with a ReturnStmt to avoid leaving
the contextual result type unbound. This isn't currently legal anyway,
so isn't likely to come up often in practice, but make sure we can
still solve.
2025-09-13 19:15:34 +01:00
Henrik G. Olsson
33a059f689 Merge pull request #84136 from hnrklssn/print-lifetime-arg-backticks
[ASTPrinter] Escape @_lifetime arguments when needed

Printing a LifetimeDescriptor would never wrap it in backticks (even if originally wrapped in backticks). This would result in the output not being able to be parsed

rdar://159992995
2025-09-08 15:29:16 -07:00
Henrik G. Olsson
d7d839e9f3 [ASTPrinter] Escape @_lifetime arguments when needed
rdar://159992995
2025-09-05 23:03:46 -07:00
Henrik G. Olsson
fe14d5d636 [ASTPrinter] Move LifetimeDescriptor::getString and add test (NFC)
This refactor and test case are preparations for the implementation in
the next commit.
2025-09-05 23:03:26 -07:00
Ahmed Elrefaey
1bc96857a8 Merge pull request #82464 from a7medev/feat/full-documentation-in-code-completion
[IDE] Add full documentation to code completion result
2025-09-04 10:06:21 +01:00
Ben Barham
52b28717ce Merge pull request #84036 from hamishknight/pothole
[CS] Avoid increasing score for unbound outer type vars for completion
2025-09-02 09:32:03 -07:00
Hamish Knight
ebad04f133 [CS] Avoid increasing score for unbound outer type vars for completion
When doing code completion it's entirely expected we'll end up with 
ambiguities in the body of a closure if we're completing e.g
`someOverloadedFn(#^CC^#)`. As such we don't want to penalize the
solution for unbound type variables outside of the body since that 
will prevent us from being able to eagerly prune e.g disfavored
overloads in the outer scope. This gives up to a 7% perf win in the
stress tester.
2025-09-01 10:56:45 +01:00
Ahmed Mahmoud
491b3a0fbc [IDE] Erase archetypes with no declaration generic signature
This generalization enables curried functions with generic parameters coming from the initial declaration to be printed with the archetype's upperbound rather than '_' unresolved type.

As an added benefit, T.self and T.Type for generic parameters now get shown as the upperbound of the generic parameter provided
2025-08-29 13:39:58 +03:00
Hamish Knight
44ba366759 Merge pull request #83662 from hamishknight/unqualified-fallback
[Completion] Fall back to unqualified lookup on solver failure
2025-08-28 20:39:11 +01:00
Slava Pestov
75cf2c1df5 Sema: Remove a usage of replaceCovariantResultType() 2025-08-27 15:34:25 -04:00
Hamish Knight
a63ab6d161 [Completion] Fall back to unqualified lookup on solver failure
Even if the solver fails we can still do an unqualified lookup without
a contextual type.
2025-08-25 11:13:40 +01:00
Pavel Yaskevich
a7ecd309d4 [AST] SE-0487: Promote NonexhaustiveAttribute to a language feature
The proposal [has been accepted](https://forums.swift.org/t/accepted-se-0487-nonexhaustive-enums/81508)
which makes the feature experimental no longer.
2025-08-20 00:39:51 -07:00
Hamish Knight
af73ca374d Merge pull request #83704 from hamishknight/fix-stress-tester-regression
[CS] Record `SkipUnhandledConstructInResultBuilder` for completion
2025-08-14 20:39:36 +01:00
Hamish Knight
6b2b28ae81 Merge pull request #83565 from hamishknight/synth
[IDE] Use LookUpConformanceInModule for synthesized extension requirement substitution
2025-08-14 14:23:30 +01:00
Hamish Knight
eb7aa6281c [CS] Record SkipUnhandledConstructInResultBuilder for completion
We still want to record this fix when falling back to type-checking
as a regular function body to ensure that in cases where there is a
disjunction of multiple result builders we favor the one that actually
supports the body.
2025-08-14 11:57:11 +01:00
Hamish Knight
5e27e83456 Merge pull request #83613 from hamishknight/next-step
[IDE] Perform extension binding after AST mutation
2025-08-13 22:37:56 +01:00
Hamish Knight
e1e0f72288 [IDE] Avoid redundant worklist visitor
This is unnecessary since the local conformances for a protocol
can only contain self-conformances, which we don't want to visit
anyway. This can just be a straightforward loop over the local
conformances.
2025-08-13 21:19:07 +01:00
Hamish Knight
02d2b4aa46 [IDE] Use LookUpConformanceInModule for synthesized extension requirement substitution
The extension may have requirements stating new conformance requirements
that aren't present in the underlying substitution map for the
conforming type.

rdar://152164768
2025-08-13 21:19:07 +01:00
Hamish Knight
27e2514eff [CS] Better handle unsupported result builder elements for completion
Instead of failing, fall back to solving as a regular function body.

rdar://144303920
2025-08-11 11:19:14 +01:00
Hamish Knight
1e012fea05 [CS] Avoid bailing on result builder return for completion
Make sure we continue to solve the body normally rather than bailing
early.
2025-08-11 11:19:14 +01:00