Commit Graph

3541 Commits

Author SHA1 Message Date
Alex Hoppen
70757ffe5e Merge pull request #72570 from ahoppen/ahoppen/parameter-pack-pattern-crash
[CodeCompletion] Fix a crash when completing the call pattern of a function that takes a parameter pack
2024-04-15 21:52:23 -07:00
Artem Chikin
01d891ad99 Merge pull request #72834 from artemcm/UpstreamVisionOS
Introduce visionOS Platform
2024-04-15 09:33:49 -07:00
Alex Hoppen
078e1ea0cc [CodeCompletion] Fix a crash when completing the call pattern of a function that takes a parameter pack
The issue here was that we inferred the contextual type of the `Mixer` call to be the following, inferred from the result type of the partial call to the initializer of `Mixer`

```
(bound_generic_struct_type decl="swift_ide_test.(file).Mixer@/Users/alex/src/swift/test/IDE/complete_parameter_pack_as_call_argument.swift:3:8"
  (pack_type num_elements=1
    (pack_expansion_type
      (pattern=unresolved_type)
      (count=unresolved_type))))
```

Technically, the contextual type that we should have here should be `Any` (from `print`) but getting that information out of the constraint system turns out to be quite hard. https://github.com/apple/swift/pull/72568 makes some improvements in this area but in general the constraint system does not contain enough information to figure out the contextual type of an arbitrary expression.

The important thing right now is that the unresolved type in here trips the constraint system over when comparing types of code completion results with the contextual type. To prevent the crash for now, reset the expected call type if the computed type contains an unresolved type.

rdar://124166587

Co-authored-by: Pavel Yaskevich <pyaskevich@apple.com>
2024-04-12 14:03:57 -07:00
Alex Hoppen
9fca2ff0ff Merge pull request #72568 from ahoppen/ahoppen/type-relation-of-call-pattern
[CodeCompletion] Don’t report a call pattern as convertible if its result type doesn’t match
2024-04-12 13:16:51 -07:00
Alex Hoppen
d3c52da689 Merge pull request #72910 from ahoppen/ahoppen/parse-multiple-catch-if-do-has-cc
[CodeCompletion] Parse multiple `catch` clauses if the `do` body contains the code completion token
2024-04-10 23:09:26 -07:00
Alex Hoppen
278ecef284 [CodeCompletion] Don’t report a call pattern as convertible if its result type doesn’t match
To compute the expected type of a call pattern (which is the return type of the function if that call pattern is being used), we called `getTypeForCompletion` for the entire call, in the same way that we do for the code completion token. However, this pattern does not generally work. For the code completion token it worked because the code completion expression doesn’t have an inherent type and it inherits the type solely from its context. Calls, however, have an inherent return type and that type gets assigned as the `typeForCompletion`.

Implement targeted checks for the two most common cases where an expected type exists: If the call that we suggest call patterns for is itself an argument to another function or if it is used in a place that has a contextual type in the constraint system (eg. a variable binding or a `return` statement). This means that we no longer return `Convertible` for call patterns in some more complex scenarios. But given that this information was computed based on incorrect results and that in those cases all call patterns had a `Convertible` type relation, I think that’s acceptable. Fixing this would require recording more information in the constraints system, which is out-of-scope for now.
2024-04-10 16:06:47 -07:00
Artem Chikin
1f14158a1d Introduce VisionOS Platform
This change introduces a new compilation target platform to the Swift compiler - visionOS.

- Changes to the compiler build infrastrucuture to support building compiler-adjacent artifacts and test suites for the new target.
- Addition of the new platform kind definition.
- Support for the new platform in language constructs such as compile-time availability annotations or runtime OS version queries.
- Utilities to read out Darwin platform SDK info containing platform mapping data.
- Utilities to support re-mapping availability annotations from iOS to visionOS (e.g. 'updateIntroducedPlatformForFallback', 'updateDeprecatedPlatformForFallback', 'updateObsoletedPlatformForFallback').
- Additional tests exercising platform-specific availability handling and availability re-mapping fallback code-path.
- Changes to existing test suite to accomodate the new platform.
2024-04-10 09:38:02 -07:00
Kuba (Brecka) Mracek
f9ed12d781 Merge pull request #72716 from kubamracek/embedded-build-macos-as-14
[embedded] Build the macOS Embedded Stdlib with a recent deployment target
2024-04-09 19:11:08 -07:00
Alex Hoppen
0b65641401 [CodeCompletion] Parse multiple catch clauses if the do body contains the code completion token
rdar://125303959
2024-04-08 11:07:48 -07:00
Rintaro Ishizaki
46cc32e9a4 [CodeCompletion] Always print argument ':' in filterName
In annotated results.

rdar://124667867
2024-04-05 17:21:40 -07:00
Michael Gottesman
cf93476d0b [region-isolation] Require T in assumeIsolated<T> to be Sendable.
I had to change the APIs to always be always emit into client instead of back
deployable since silgen_name seems to interfere with @backDeployment. So I
switched the implementation so that it instead uses an always emit into client
thunk with the in source function name and a usableFromInline function that has
the silgen_name. This ensures that we still appropriately export the same symbol
as we did before, so it is ABI stable.

This was approved as part of se-0414.

rdar://122030520
2024-04-02 13:49:13 -07:00
Kuba Mracek
eebb48469a [embedded] Adjust tests for the embedded stdlib deployment target bump 2024-03-29 21:17:29 -07:00
Rintaro Ishizaki
7b3738d1d0 [SourceKit] Adjust newlines between decls
Previously, Clang modules didn't have empty lines between top-level
decls. This was inconsistent with Swift module.
2024-03-25 22:07:50 +09:00
Rintaro Ishizaki
b019fd0c1b Merge pull request #72420 from rintaro/sourcekit-clang-printer-rdar93731287
[SourceKit] Stop printing normal comments in clang generated interface
2024-03-25 17:29:45 +09:00
Hamish Knight
b82271ecd6 [test] Add test for issue 57916 2024-03-22 21:22:11 +00:00
Dario Rexin
49515cc251 [Test] Disable IDE/complete_operators.swift on Linux (#72491) 2024-03-21 11:23:25 -07:00
Rintaro Ishizaki
c9785d955d [SourceKit] Stop printing normal comments in clang generated interface
Generated interfaces for Clang modules used to try printing normal
comments between decls extracted from the header text. That was because
doc-comment was not common in C/ObjC headers. But mainly because of
"import as member feature" Clang decls aren't printed in the order as
they appear in the header file, the logic determinig which comment
belongs to which decl was not working property. We've decided to remove
that feature and only print the proper doc-comments as it has been
getting common.

rdar://93731287
2024-03-21 11:52:32 +09:00
Pavel Yaskevich
56d207ab1a Merge pull request #72277 from xedin/improvements-to-protocol-witness-matching
[Sema/ClangImporter] Improvements to witness matching
2024-03-19 09:36:32 -07:00
Karoy Lorentey
bd97f9d4ff [test][IDE] Update code completion expectation 2024-03-18 11:09:08 -07:00
Karoy Lorentey
4b1477cc2c [test] Update tests for new stdlib 2024-03-18 11:08:32 -07:00
Pavel Yaskevich
a90e5916bd [ClangImporter] Wrap compositions with Sendable protocol into existentials
Resolves: https://github.com/apple/swift/issues/65730
2024-03-18 10:43:42 -07:00
Rintaro Ishizaki
0721e2942a [CodeCompletion] Migrate a completion test to batch-completion 2024-03-14 14:33:43 +09:00
Rintaro Ishizaki
044473f374 [IDE/Tests] Adjust test cases
Some things went off when this test was disabled
2024-03-14 14:24:46 +09:00
Rintaro Ishizaki
59121dcf8b Revert "[wrangler] Disable IDE/complete_from_clang_framework.swift"
This reverts commit 423f0c3dfe.
2024-03-14 14:24:44 +09:00
Becca Royal-Gordon
fd9ae4c8ac Merge pull request #72023 from beccadax/lazy-objc-workaround
Add workaround flag for lazy import-as-member
2024-03-05 16:12:32 -08:00
Becca Royal-Gordon
54fd4b01b6 Add workaround flag for lazy import-as-member
In rdar://123649082, a project failed to build because of the lazy import-as-member loading changes in #71320. That project was configured in a way that broke modularization and the correct solution is to fix it, but out of an abundance of caution, add a `-disable-named-lazy-import-as-member-loading` frontend flag in case a project needs to temporarily restore the old behavior.

As a bonus, this lets us write a test to verify that lazy import-as-member loading has positive performance impact.
2024-03-05 11:09:17 -08:00
Hamish Knight
f7130f2573 [test] Add test case for rdar://123790296 2024-03-04 13:33:40 +00:00
Hamish Knight
08927e90b1 [test] Convert complete_unqualified_lookup.swift to %batch-code-completion 2024-03-04 13:25:36 +00:00
Slava Pestov
064c8c5bf7 Merge pull request #71995 from slavapestov/ncgenerics-fixes-6
Non-copyable generics fixes
2024-03-01 07:34:00 -05:00
Becca Royal-Gordon
1a97803c8c Add flag for dumping ClangImporter lookup tables
ClangImporter’s SwiftLookupTables map Swift names to their corresponding Clang declarations. These tables are built into a module’s clang .pcm file and missing or inaccurate entries can cause name lookup to fail to find an imported declaration.

Swift has always included a helper function that would dump these tables, and swift-ide-test has a command-line switch that would invoke it, but these tools are clumsy to use in many debugging scenarios. Add a frontend flag that dumps the tables at the end of the frontend job, making it a lot easier to get at this information in the context of a specific compilation.
2024-02-29 17:51:00 -08:00
Slava Pestov
5f2c49bd0e RequirementMachine: Canonicalize protocol list in RequirementMachine::getLocalRequirements() 2024-02-29 18:13:28 -05:00
Alex Hoppen
a176c07b8b [CodeCompletion] Suggest static members on protocol extensions with Self bound in unresolved member lookup
rdar://122758029
2024-02-29 13:55:43 -08:00
Alex Hoppen
0b580f7155 Merge pull request #71587 from ahoppen/ahoppen/nested-call-completion
[CodeCompletion] Always suggest call pattern for nested function calls
2024-02-26 09:14:15 -08:00
Alex Hoppen
17520dcf6d [CodeCompletion] Always suggest call pattern for nested function calls
When completing in cases like `bar(arg: foo(|, option: 1)`, we don’t know if `option` belongs to the call to `foo` or `bar`. Be defensive and also suggest the signature.
2024-02-21 18:53:07 -08:00
Alex Hoppen
056c22f7e9 Merge pull request #71766 from ahoppen/ahoppen/fix-generic-type-completion
[CodeCompletion] Fix missing completions in type member access of right-hand side in generic where clause
2024-02-21 10:02:45 -08:00
Kavon Farvardin
f296d8e158 NCGenerics: mass XFAIL tests
It's easier to get a handle on regressions while working through
failures if the tests that are known to not pass are XFAIL'd for
NoncopyableGenerics.
2024-02-20 18:26:05 -05:00
Alex Hoppen
1650052150 [CodeCompletion] Fix missing completions in type member access of right-hand side in generic where clause
Fixes the issue in https://github.com/apple/swift/pull/61064#discussion_r1493108941
2024-02-20 14:39:48 -08:00
Slava Pestov
70c9f8a47e RequirementMachine: Leave behind conflicting requirements in the minimized signature
Requirement lowering only expects that it won't see two requirements
of the same kind (except for conformance requirements). So only mark
those as conflicting.

This addresses a crash-on-invalid and improves diagnostics for
move-only generics, because a conflict won't drop the copyability
of a generic parameter and expose a move-only-naive user to
confusing error messages.

Fixes #61031.
Fixes #63997.
Fixes rdar://problem/111991454.
2024-02-15 14:32:31 -05:00
Kavon Farvardin
75bff92b62 IDE: fix printTypeInterface
The missing module was causing not only a crash in conformance lookup,
but full qualification for a generic parameter, which shouldn't ever be
needed.
2024-02-11 12:54:35 -08:00
Kavon Farvardin
9a6027d21a IDE: sort the output of LookedupTypeNames
Any changes to the order in which lookups happen would require
changing all the regression tests.
2024-02-11 12:54:35 -08:00
Hamish Knight
05612bffe2 Remove special case for stdlib in IsNonUserModuleRequest
It's possible this may be the main module, or a
"local" dependency within the same project, and
should be treated as a user module in such cases.
2024-02-09 11:30:52 +00: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
7b4c9fef02 Allow implicit last expressions for functions and closures
Gated behind the experimental feature
`ImplicitLastExprResults`.
2024-02-07 18:14:23 +00:00
Hamish Knight
d73e394ea7 Allow implicit last expression results for if/switch expressions
Allow implicitly treating the last expression of
the branch as the result, behind the experimental
feature `ImplicitLastExprResults`.
2024-02-07 18:14:22 +00:00
Guillaume Lessard
114f235d17 Merge pull request #71167 from vanvoorden/vanvoorden/inclusive-language
[Inclusive Language][Comments][Documentation] migrate "sanity" checks to "soundness" checks
2024-02-02 10:27:34 -08:00
Hamish Knight
deaf2dd372 [CS] Unify ReturnStmt handling
Unify the implementation between single-expression
and multi-statement closures. Because we're now
storing a contextual type for single expression
closure returns, update a code completion test to
bring its behavior inline with the multi-statement
case.
2024-01-31 20:26:20 +00:00
Alex Hoppen
7b6f45c59a Merge pull request #71228 from ahoppen/ahoppen/complete-in-guard
[CodeCompletion] Fix an issue that caused us to not produce any results for a `guard` condition inside a closure
2024-01-30 12:55:43 -08:00
Alex Hoppen
2016f095a2 [CodeCompletion] Fix an issue that caused us to not produce any results for a guard condition inside a closure
rdar://121406956
2024-01-29 16:34:41 -08:00
Hamish Knight
d022cf806b [CodeComplete] Avoid using an unresolved contextual type
This can occur for e.g multi-statement closure
returns (and soon for singe-expression closures
too), so fall back to evaluating the expression
type if it's not fully resolved.
2024-01-29 21:26:08 +00:00