Commit Graph

27 Commits

Author SHA1 Message Date
Doug Gregor
6e6dc4b063 Merge pull request #81054 from DataCorrupted/FixTypedThrow
[Sema] @objc functions shall not have typed throw
2025-09-22 18:21:52 -07:00
Michael Gottesman
3ed4059a60 [sema] Change non-sendable -> non-Sendable in diagnostics.
This matches send non sendable but importantly also makes it clear that we are
talking about something that doesn't conform to the Sendable protocol which is
capitalized.

rdar://151802975
2025-05-22 11:37:58 -07:00
Peter Rong
5af6e5e129 Address comments
Signed-off-by: Peter Rong <PeterRong@meta.com>
2025-04-25 23:24:20 -07:00
Peter Rong
ea05881ebb Address comments
Signed-off-by: Peter Rong <PeterRong@meta.com>
2025-04-24 16:45:08 -07:00
Anthony Latsis
2cd90bdd69 AST: Quote attributes more consistently in DiagnosticsSema.def 2025-04-22 18:23:36 +01:00
Pavel Yaskevich
dbf1146963 [Concurrency] NFC: Switch tests to use -strict-concurrency=complete instead of -warn-concurrency 2023-12-08 14:10:51 -08:00
Becca Royal-Gordon
8770c7f826 Rework ASTDumper (#68438)
This PR refactors the ASTDumper to make it more structured, less mistake-prone, and more amenable to future changes. For example:

```cpp
  // Before:
  void visitUnresolvedDotExpr(UnresolvedDotExpr *E) {
    printCommon(E, "unresolved_dot_expr")
      << " field '" << E->getName() << "'";
    PrintWithColorRAII(OS, ExprModifierColor)
      << " function_ref=" << getFunctionRefKindStr(E->getFunctionRefKind());
    if (E->getBase()) {
      OS << '\n';
      printRec(E->getBase());
    }
    PrintWithColorRAII(OS, ParenthesisColor) << ')';
  }

  // After:
  void visitUnresolvedDotExpr(UnresolvedDotExpr *E, StringRef label) {
    printCommon(E, "unresolved_dot_expr", label);

    printFieldQuoted(E->getName(), "field");
    printField(E->getFunctionRefKind(), "function_ref", ExprModifierColor);

    if (E->getBase()) {
      printRec(E->getBase());
    }

    printFoot();
  }
```

* Values are printed through calls to base class methods, rather than direct access to the underlying `raw_ostream`.
    * These methods tend to reduce the chances of bugs like missing/extra spaces or newlines, too much/too little indentation, etc.
    * More values are quoted, and unprintable/non-ASCII characters in quoted values are escaped before printing.
* Infrastructure to label child nodes now exists.
    * Some weird breaks from the normal "style", like `PatternBindingDecl`'s original and processed initializers, have been brought into line.
* Some types that previously used ad-hoc dumping functions, like conformances and substitution maps, are now structured similarly to the dumper classes.
* I've fixed the odd dumping bug along the way. For example, distributed actors were only marked `actor`, not `distributed actor`.

This PR doesn't change the overall style of AST dumps; they're still pseudo-S-expressions. But the logic that implements this style is now isolated into a relatively small base class, making it feasible to introduce e.g. JSON dumping in the future.
2023-09-11 23:56:38 -07:00
Anthony Latsis
7f6d3bcd41 ASTPrinter: Turn on explicit any printing for everything and remove the option to disable it 2023-05-13 02:55:49 +03:00
Doug Gregor
11601c477d Improve Sendable diagnostics for result types of functions. 2021-12-16 15:43:25 -08:00
Doug Gregor
eeeea49764 Remove -enable-experimental-concurrency almost everywhere. 2021-07-26 21:24:43 -07:00
Doug Gregor
1e2012d816 Disable availability checking in tests that use concurrency 2021-07-20 12:46:26 -07:00
Doug Gregor
d18a2b7fda Re-enable actor inheritance from NSObject.
For now, it's the only way to get NSObjectProtocol conformance.
Fixes rdar://80476009.
2021-07-12 16:12:35 -07:00
Doug Gregor
6406f08661 [SE-0306] Disallow actor inheritance from NSObject, but allow @objc actor.
Allow an actor to be exposed to Objective-C via `@objc` without
inheriting from `NSObject`, and remove the loophole that allowed
actors to inherit from `NSObject`.

Fixes rdar://78333614
2021-07-02 23:37:09 -07:00
Pavel Yaskevich
aeddab4dd0 [Parse] Disallow use of actor as a declaration modifier
`actor` is a standalone contextual keyword now and should
be treated as such, `actor class` is no longer allowed
and results in a parse error.

Resolves: rdar://75753598
2021-05-19 16:18:32 -07:00
Doug Gregor
c76dac7155 Banish @asyncHandler to a hidden flag.
We don't want @asyncHandler to be part of the concurrency model, so put
it behind a different flag.
2021-03-25 16:45:21 -07:00
Doug Gregor
508274c90e Update "non-concurrent-value" diagnostics to say "non-sendable" 2021-03-18 23:14:47 -07:00
Doug Gregor
5b2afec56a Only produce ConcurrentValue-related diagnostics under -warn-concurrency. 2021-03-15 12:13:44 -07:00
Doug Gregor
2f2c194272 Adopt 'nonisolated' in many tests, make sure its a modifier 2021-03-07 11:37:57 -08:00
Doug Gregor
ecf36ba6bc Enable ConcurrentValue checking as part of Concurrency mode.
Drop the separate flag guarding this checking.
2021-02-22 00:29:56 -08:00
Kavon Farvardin
9342540661 add fix-it to note for "add 'async' to function"
resolves rdar://72313654
2021-02-11 14:44:49 -08:00
Evan Wilde
8b80331c3d Updating tests to use actor
This patch updates the `actor class` spelling to `actor` in almost all
of the tests. There are places where I verify that we sanely handle
`actor` as an attribute though. These include:

 - test/decl/class/actor/basic.swift
 - test/decl/protocol/special/Actor.swift
 - test/SourceKit/CursorInfo/cursor_info_concurrency.swift
 - test/attr/attr_objc_async.swift
 - test/ModuleInterface/actor_protocol.swift
2021-02-10 08:09:13 -08:00
Kavon Farvardin
e8dcc979a0 fix-it regression coverage for notes suggesting 'async', '@asyncHandler' and '@GlobalActorType'
Currently, we don't have a fix-it to insert 'async', so I've marked those places
as not expecting a fix-it, until someone goes and implements that (rdar://72313654)
2020-12-14 15:21:27 -08:00
Doug Gregor
72bf83653a [Concurrency] Allow actor classes to inherit from NSObject.
NSObject is guaranteed to have no state and no Swift vtable, and is
necessary for Swift classes to implement the NSObject protocol. Allow
it (and only it) as the superclass of an actor class, so that actor
classes can be exposed to Objective-C.
2020-09-30 00:02:17 -07:00
Doug Gregor
e5c1491c6a [Concurrency] Ban actor-isolated operations from being @objc.
Actor-isolated operations must not be directly accessible from anywhere
that is not already guaranteed to be running within the actor context.
Prevent such operations from being `@objc`, because that would allow
Objective-C code to violate actor isolation.
2020-09-30 00:02:17 -07:00
Doug Gregor
8dc8532965 [Concurrency] Ban asynchronous methods returning 'Self' from being @objc 2020-09-08 10:15:24 -07:00
Doug Gregor
0f18948bd5 [Concurrency] Allow @objc async methods.
Allow the declaration of @objc async methods, mapping them to a
completion-handler API in Objective-C. This covers most of the
checking and semantics within the type checker:
* Declaring @objc async methods and checking their parameter/result types
* Determining the default Objective-C selector by adding
completionHandler/WithCompletionHandler as appropriate
* Determining the type of the completion handler parameter
* Inferring @objc from protocol requirements
* Inferring @objc from an overridden method
2020-09-08 10:15:24 -07:00
Doug Gregor
191a4f8029 [Concurrency] Split @objc checking into a separate test file. 2020-09-04 21:13:17 -07:00