Commit Graph

317 Commits

Author SHA1 Message Date
Doug Gregor
9579390024 [SE-0304] Rename ConcurrentValue to Sendable 2021-03-18 22:48:20 -07:00
Dave Lee
fd2ba3091c Remove .#doc_clang_module.swift 2021-03-15 15:13:58 -07:00
Doug Gregor
06dc593cec Merge pull request #35264 from DougGregor/concurrent-value-protocol
[Concurrency] Introduce "ConcurrentValue" protocol and checking.
2021-02-05 10:28:26 -08:00
Doug Gregor
6fa673db85 Fixup test 2021-02-04 16:05:33 -08:00
Doug Gregor
1a1f79c0de Introduce safety checkin for ConcurrentValue conformance.
Introduce checking of ConcurrentValue conformances:
- For structs, check that each stored property conforms to ConcurrentValue
- For enums, check that each associated value conforms to ConcurrentValue
- For classes, check that each stored property is immutable and conforms
  to ConcurrentValue

Because all of the stored properties / associated values need to be
visible for this check to work, limit ConcurrentValue conformances to
be in the same source file as the type definition.

This checking can be disabled by conforming to a new marker protocol,
UnsafeConcurrentValue, that refines ConcurrentValue.
UnsafeConcurrentValue otherwise his no specific meaning. This allows
both "I know what I'm doing" for types that manage concurrent access
themselves as well as enabling retroactive conformance, both of which
are fundamentally unsafe but also quite necessary.

The bulk of this change ended up being to the standard library, because
all conformances of standard library types to the ConcurrentValue
protocol needed to be sunk down into the standard library so they
would benefit from the checking above. There were numerous little
mistakes in the initial pass through the stsandard library types that
have now been corrected.
2021-02-04 03:45:09 -08:00
Ben Barham
6544ba163e [SourceKit/DocSupport] Add a field to mark functions that are async
Resolves rdar://72444843
2021-02-03 15:56:21 +10:00
Egor Zhdan
bce1f9377b SourceKit: avoid self-imports in generated Swift interfaces
Generated Swift interfaces for modules with overlays, like Foundation or Dispatch, currently contain `import Foundation`/`import Dispatch` statements.

These imports are redundant, and this change removes them.
2021-01-14 16:05:51 +03:00
Anthony Latsis
4ce7a2d060 CodeCompletion: Annotate archetypes, generic parameters and dependent members 2020-10-27 14:39:52 +03:00
Nathan Hawes
e68ab1da8e [SourceKit/DocSupport] Don't synthesize extensions for inherited protocol conformances.
The Base class already includes them, so don't duplicate them in its
subclasses. Also stops us including members from extensions of the base class
itself.

Resolves rdar://problem/50960433
2020-07-21 11:53:06 -07:00
Nathan Hawes
9bcb54910e [AST] Prefer the 'macOS' spelling over 'OSX' when printing the platform kind.
This affects module interfaces, interface generation in sourcekitd, and
diagnostics. Also fixes a fixit that was assuming the 'OSX' spelling when
computing the source range to replace.

Resolves rdar://problem/64667960
2020-07-08 13:51:25 -07:00
Daniel Duan
942893d7a6 ClangImporter: Preserve CChar type (#32692)
Addresses SR-466.
2020-07-08 10:18:58 -07:00
Nathan Hawes
51bace649b [IDE][SourceKit/DocSupport] Add members of underscored protocol extensions in extensions of conforming types.
We would previously hide the protocol, its extensions and members, but the '_'
prefix really just means the protocol itself isn't intended for clients, rather
than its members.

This also adds support for 'fully_annotated_decl' entries in doc-info for
extensions to be consistent with every other decl, and removes the
'fully_annotated_generic_signature' entry we supplied as a fallback.

Also fixes several bugs with the synthesized extensions mechanism:
- The type sustitutions applied to the extension's requirements were computed
  using the extension itself as the decl context rather than the extension's
  nominal. The meant the extension's requirements themselves were assumed to
  hold when determining the substitutions, so equality constraints were always
  met. Because of this extension members were incorrectly merged with the base
  nominal or its extensions despite having additional constraints.
- Types within the requirements weren't being transformed when printed (e.g.
  'Self.Element' was printed rather than 'T') both in the interface output and
  in the requirements list. We were also incorrectly printing requirements
  that were already satisfied once the base type was subsituted in.
- If both the protocol extension and 'enabling' extension of the base nominal
  that added the protocol conformance had conditional requirements, we were
  only printing the protocol extension's requirements in the synthesized
  extension.
- The USR and annotated decl output embedded in the 'key.doc.full_as_xml'
  string for synthesized members were printed to match their original context, rather than
  the synthesized one.

Resolves rdar://problem/57121937
2020-06-02 15:38:34 -07:00
Nathan Hawes
79247b22e2 [SourceKit][InterfaceGen] Don't print clang decls marked with the swift_private attribute.
This attribute is intended to mean there's a replacement declaration that
should be used instead in Swift code. We already filter out decls with this
attribute in code completion, but were still exposing them in generated
interfaces.

Resolves rdar://problem/62464954
2020-05-27 15:23:50 -07:00
Robert Widmann
43d1ba9ed9 [Gardening] Shepherd a Fix To SetAlgebra Docs 2020-05-14 11:50:35 -07:00
Nathan Hawes
709dd35c3f Merge pull request #31589 from nathawes/doc-info-missing-submodule-decls
[IDE][DocSupport] Fix DocInfo missing decls when generated for clang submodules
2020-05-06 12:40:19 -07:00
Nathan Hawes
34098a75f5 [IDE][DocSupport] Fix DocInfo missing decls when generated for clang submodules.
Out handling of clang submodules was handled differently between DocInfo and
InterfaceGen. For InterfaceGen submodules were mapped back to their top-level
clang modules (or their Swift overlay if it had one) before being passed
into printSubmoduleInterface, along with the dot separated name of the submodule.

For DocInfo, they were not, and only the rightmost component of their name was
passed. The call to retrieve the decls from a ModuleDecl doesn't work if the
ModuleDecl wraps a clang submodule, so we were missing these decls.

InterfaceGen for submodules also shouldn't have been mapping the module back to
the overlay of top-level clang module, as that meant we ended up printing
import decls from the Swift overlay in the submodule's interface.

Resolves rdar://problem/57338105
2020-05-06 09:28:00 -07:00
Nathan Hawes
d9b1d8f694 Merge pull request #31466 from nathawes/doc-info-availability-catalyst-fix
[SourceKit] Report macCatalyst availability as macCatalyst rather than iOS
2020-05-04 09:42:39 -07:00
Nathan Hawes
c426b1d6d9 [SourceKit] Report macCatalyst availability as macCatalyst rather than iOS
Resolves rdar://problem/60918688
2020-05-01 16:55:25 -07:00
Nathan Hawes
a9aba54b42 [ASTPrinter][SourceKit] Print 'Any' as a keyword.
It's treated as a keyword by syntactic highlighting, but wasn't annotated as a
keyword by code completion, cursor info, or doc info.

Resolves rdar://problem/61114942
2020-04-28 13:35:06 -07:00
Nathan Hawes
b7ac8f87b1 [IDE][AST] Handle frameworks with traditional overlays where the underlying module declares cross imports in sourcekit.
We weren't handling this case, so their generated interfaces / doc info
wouldn't include symbols from the cross-import overlays, and we wouldn't
map the underscored cross-import overlay name back to the declaring
framework's name in cusor-info, completion results or when indexing.

Resolves rdar://problem/62138551
2020-04-23 13:03:59 -07:00
Rintaro Ishizaki
aee280ad65 [SourceKit/Testing] Add %diff as an alias for 'diff --strip-trailing-cr' 2020-04-08 11:23:48 -07:00
Nathan Hawes
3ebb81e38f Merge pull request #30841 from nathawes/fix-cross-import-doc-support-test
[test] Fix DocSupport test that should have passed -enable-cross-import-overlays
2020-04-06 16:28:29 -07:00
Nathan Hawes
b2fe997e7b Merge pull request #30836 from nathawes/doc-info-where-from-context
[SourceKit/DocSupport] List generic requirements from contextual where clauses in doc info request
2020-04-06 14:04:51 -07:00
Nathan Hawes
6e3f512fd1 [test] Fix DocSupport test that should have passed -enable-cross-import-overlays
Resolves rdar://problem/61346236
2020-04-06 13:57:36 -07:00
Nathan Hawes
af0509e106 [SourceKit/DocSupport] List generic requirements from contextual where clauses in doc info request
We previously didn't report the requirements in the where clause of 'boxes'
below because it didn't have generic parameters of its own:

public struct Box<Wrapped> {
    public func boxes() -> [Box<Wrapped.Element>] where Wrapped: Sequence { fatalError() }
}

Resolves rdar://problem/60658263
2020-04-06 11:43:14 -07:00
Xi Ge
70d119199c test: disable SourceKit/DocSupport/doc_swift_module_cross_import.swift
rdar://61346236
2020-04-06 09:53:11 -07:00
Nathan Hawes
9f6f76308e Add method to ModuleDecl to lazily compute the underlying module for cross-import overlays
Also update code completion, indexing, interface generation and doc info to use it.
2020-04-03 16:04:32 -07:00
Nathan Hawes
fe12ab2067 [SourceKit/DocSupport][test] Test that the synthesized comments generated for cross-import overlay decls are ignored.
Unlike doc comments, they shouldn't be reported in the 'fully_annotated_decl' field.
2020-03-24 10:31:08 -07:00
Nathan Hawes
9aafadd090 [SourceKit/DocSupport] Report the required bystander modules on symbols from cross-import overlays.
Resolves rdar://problem/59446044
2020-03-24 10:31:08 -07:00
Ben Langmuir
0b93a247c6 [test] Remove now-redundant %mcp_opt from sourcekit tests
Remove `%mcp_opt` from commands that use `%sourcekitd-test` and
`%complete-test`, as they are now redundant with the lit substitution.
2020-01-22 11:12:25 -08:00
Rintaro Ishizaki
5e0226fec4 Merge pull request #29194 from rintaro/test-requiresor-rdar57245073
[Testing] Eliminate REQUIRES-ANY usage
2020-01-14 16:55:40 -08:00
Rintaro Ishizaki
0aa3125b62 [Testing] Eliminate REQUIRES-ANY usage
REQUIRES-ANY is deprecated and being removed. Use boolean expressions.

rdar://problem/58549266
2020-01-14 10:21:49 -08:00
Saleem Abdulrasool
2265d6e891 tests: adjust the SourceKit tests for line endings (NFCI)
This adjusts the tests for the difference between line endings on
different platforms.  Windows uses CRLF while most Unicies use LF.  This
was exposed during the update to the new LLVM snapshot.
2020-01-14 08:05:34 -08:00
Argyrios Kyrtzidis
6219e4e8f5 [PrintOptions] Enable EnumRawValueMode::PrintObjCOnly for when generating interfaces for user consumption and for doc-support
rdar://17934156
2019-10-25 17:49:25 -07:00
Xi Ge
1ca8e83aa3 Sourcekit/DocSupport: fix an assertion when generating documentation for extensions with attributes
When sanitizing the documentation comments for synthesized extensions,
we expect some text like "<declaration>extension". This isn't the case
when use-facing attributes are present.

rdar://50913510
2019-05-20 17:43:29 -07:00
Jordan Rose
42522ca4ae [ParseableInterface] Module-qualify protocol types too
Otherwise we can get in trouble when a local type is named, say,
'Sequence'.

Also contains test updates and a fix for Harlan's previous commit,
which actually affects all typealiases, not just those in the Builtin
module.
2019-03-29 08:52:22 -07:00
Xi Ge
b8c4400267 IDE/sourcekitd: avoid printing underscored keywords in module interface view. 2019-03-14 15:33:31 -07:00
Xi Ge
1625bcfbba ASTPrinter: skip underscored keyword when printing for quick helps.
rdar://47777848
2019-03-13 17:53:51 -07:00
Devin Coughlin
b3ff2d8816 [ClangImporter] Update diagnostic to refer to "macOS" instead of "OS X" 2019-03-03 16:42:17 -08:00
Xi Ge
c0598b9888 ASTPrinter: add an option to skip keywords with a prefix of underscore.
DocSupport will use set this flag to avoid printing __consuming, __owned, and
__shared.

rdar://47777848
2019-02-06 14:51:39 -08:00
Brent Royal-Gordon
f7eea0facd Disable swift_evolve for SourceKit tests
A lot of these are source-order-dependent and there’s no particular reason to think they’re relevant to resilience testing.
2018-12-18 16:26:35 -08:00
Brent Royal-Gordon
7a3ed15846 Exclude/fix certain tests for swift-evolve (#21276)
* Add swift_evolve feature and disable several tests

This change adds a swift_evolve feature to our lit configuration and uses it to mark several tests as unsupported by swift_evolve.

One of these—test/api-digester/stability-stdlib-abi.swift—is actually pretty bad; we would really like to have it. But the digester has known issues exposed by swift-evolve.

* Remove order dependency in another test

* Tweaks from Jordan’s review

* Distinguish between tests which are intentionally unsupported and temporarily disabled.
* Add an explanation for one unsupproted test.
* Code nitpick.
2018-12-13 14:26:47 -08:00
Xi Ge
93ec9901bb Sourcekit/DocSupport: avoid substituting generic types when printing where clauses. rdar://43820510
This makes the printed requirements agree with separately reported generic parameters and requirement.
2018-12-05 14:03:56 -08:00
Xi Ge
d620dfae5e Sourcekit/DocSupport: include fully annotated generic signatures for extension decls. rdar://40906297 2018-12-04 14:29:28 -08:00
Karoy Lorentey
811d3d710e [test] Update for RawRepresentable hashing changes 2018-11-22 17:16:07 +00:00
Ben Cohen
1c4ca23b7f Update SourceKit tests 2018-09-25 15:25:13 -07:00
Karoy Lorentey
1aaf56d6a3 [test] FooRuncingOptions.init<S>(_:) has grown an __owned modifier 2018-09-24 16:29:42 +01:00
Davide Italiano
ef46ec08fc [AST] Update tests now that we preserve sugar. 2018-09-18 09:23:02 -07:00
Harlan
665db876ea [InterfaceGen] Print bodies of inlinable functions in textual interfaces (#19224)
* Introduce stored inlinable function bodies

* Remove serialization changes

* [InterfaceGen] Print inlinable function bodies

* Clean up a little bit and add test

* Undo changes to InlinableText

* Add serialization and deserialization for inlinable body text

* Allow parser to parse accessor bodies in interfaces

* Fix some tests

* Fix remaining tests

* Add tests for usableFromInline decls

* Add comments

* Clean up function body printing throughout

* Add tests for subscripts

* Remove comment about subscript inlinable text

* Address some comments

* Handle lack of @objc on Linux
2018-09-14 10:23:15 -07:00
Jordan Rose
859b31f9c6 [AST] Fix printing of *un*constrained generic extensions
We were redundantly printing constraints that were implied by the base
type (the type being extended). Rather than special-casing constraints
on a protocol's 'Self' type, omit any requirements that are already
satisfied by the extended type instead.

https://bugs.swift.org/browse/SR-7413
2018-08-17 19:26:47 -07:00