Commit Graph

189 Commits

Author SHA1 Message Date
Doug Gregor
5004a5447b [Concurrency] Make "self" parameter of actor-isolated functions 'isolated'.
The notion of "actor-isolated" currently exists at the declaration level.
For functions, it is going to be captured in the function type itself,
where 'self' is declared to be 'isolated'. Model isolation both
ways: the 'self' of a method that is isolated to an actor instance
will be 'isolated' as well.

We are still using declaration-based checking of actor isolation.
However, by mirroring this information we can move more incrementally
over to doing checking based on 'isolated' parameters.
2021-06-07 23:59:38 -07:00
Doug Gregor
3fe712dfda [SE-0313] Enable nonisolated by default. 2021-05-21 15:17:43 -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
2b9ca315fe [Concurrency] Remove asyncHandler attribute.
The `asyncHandler` attribute turned out to be the wrong solution
to the problem of creating a sync->async bridge. Remove it.
2021-05-13 17:01:39 -07:00
Kavon Farvardin
e17e09c294 Enable effectful properties (SE-310) by default.
1. Removes gating on -enable-experimental-concurrency.
2. Updates eff. prop tests to remove experimental flag,
   and also adjusts some tests slightly to avoid things
   that are still behind that flag.
2021-05-03 14:10:44 -07:00
Doug Gregor
a2cdef73a6 [SE-0306] Enable actors by default.
With the acceptance of SE-0306, enable actors by default and add a
ChangeLog entry.

Tracked by rdar://77223763.
2021-04-27 12:25:41 -07:00
Evan Wilde
d0d9bef703 Merge pull request #37056 from etcwilde/ewilde/fix-await-fixits
[Concurrency] Fix await fix-it placement
2021-04-26 08:12:50 -07:00
Evan Wilde
3da0a540eb Update tests
This patch updates all the tests to accept the new error messages.
*Gack* so many things needed cleaning up.
2021-04-24 07:51:18 -07:00
Doug Gregor
b88e678694 [SE-0306] Disable actor inheritance.
Actor inheritance was removed in the second revision of SE-0306. Remove
the ability to inherit actors.

Note that this doesn't fully eliminate all vestigates of inheritance
from actors. There are simplifications that need to be performed
still, e.g., there's no need to distinguish
designated/convenience/required initializers. That will follow.
2021-04-23 15:08:57 -07:00
Kavon Farvardin
be9890815a update existing regression tests after small diagnostics refactor
new phrasing in the error messages to match up with
other phrasing used in messages.
2021-04-15 10:08:58 -07:00
Kavon Farvardin
e418403fc6 [test] eff. prop + class inheritance & overrides 2021-03-26 07:58:28 -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
Evan Wilde
d572c75d21 NFC: Remove 'actor class' from diagnostics 2021-03-23 15:06:41 -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
f56ba59605 Add 'nonisolated' modifier as the preferred spelling for @actorIndependent 2021-03-07 10:57:35 -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
Slava Pestov
4337899ded Merge pull request #35334 from slavapestov/remove-evaluator-type-erasers
Remove request evaluator's AnyRequest and AnyValue type erasers
2021-01-11 14:44:54 -05:00
Doug Gregor
af948715d9 Fix test case 2021-01-11 09:00:27 -08:00
Slava Pestov
28e7ed03d0 AST: Remove the 'legacy' request dependency graph implementation 2021-01-08 23:17:12 -05:00
Evan Wilde
1d53d748d3 Cleanup actor protocol conformance error
This patch cleans up how we emit the errors for disallowing the
properties and methods of an actor to be applied to the protocol
conformance. Rather than having multiple error messages for each case,
we keep one error message saying that the actor-isolated
method/variable/what-have-you cannot be used to satisfy a protocol
requirement, then allow multiple notes with fix-its to allow the
programmer to choose what they want to do. The notes have a better
description of what each option does.
2020-12-17 16:12:41 -08:00
John McCall
a8464dcaf1 Implicitly import _Concurrency under -enable-experimental-concurrency 2020-10-22 00:53:15 -04:00
Doug Gregor
3a651a61b7 [Concurrency] Fix circular reference on isolation propagation. 2020-10-13 22:57:06 -07:00
Doug Gregor
f089ba9464 [Concurrency] Propagation of actor constraints.
Implement propagation rules for global actor constraints, which can come from:

* Enclosing extension or type
* Superclass of a class
* Overridden declaration
* Requirement witnessed by a declaration
* Storage declaration for an accessor
2020-10-13 15:17:13 -07:00
Doug Gregor
2d8f073334 [Concurrency] Implement global actor isolation checking for conformances.
Witnesses and requirements need to agree on their global actor
annotations. However, this is not true for 'async' or '@asyncHandler'
witnesses, for which it does not matter what the actor annotation is
because part of the contract is that the function will execute on the
appropriate actor.
2020-10-12 16:38:20 -07:00
Doug Gregor
bb066b6fa6 [Concurrency] Make actor-isolated protocol witnesses an error.
With actor isolation checking for protocol witnesses moved out of the
witness-matching phase, move the corresponding diagnostics from notes
(that would have been on the "type does not conform" error) to
freestanding errors.
2020-10-02 23:41:44 -07:00
Doug Gregor
75b18ad90b Merge pull request #34111 from DougGregor/concurrency-actor-protocol
[Concurrency] Introduce Actor protocol to which actor classes all conform
2020-09-30 13:05:06 -07:00
Doug Gregor
1e040ac323 [Concurrency] Note that 'actor' is a decl modifier, not an attribute. 2020-09-30 00:02:17 -07:00
Doug Gregor
6af690aaba Eliminate HasCircularInheritanceRequest.
This is now reliably detected by SuperclassDeclRequest.
2020-09-29 17:42:17 -07:00
Doug Gregor
4ddf6e565a Teach SuperclassDeclRequest to always diagnose circularity.
Rather than relying on clients to cope with the potential for circular
inheritance of superclass declarations, teach SuperclassDeclRequest to
establish whether circular inheritance has occurred and produce "null"
in such cases. This allows other clients to avoid having to think about

To benefit from this, have SuperclassTypeRequest evaluate
SuperclassDeclRequest first and, if null, produce a Type(). This
ensures that we don't get into an inconsistent situation where there
is a superclass type but no superclass declaration.
2020-09-29 17:42:17 -07:00
Doug Gregor
2762405390 [Concurrency] Introduce @actorIndependent attribute.
Introduce a new attribute `@actorIndependent` that specifies that a
given declaration is considered to be independent of any actor.
Actor-independent declarations do not have access to actor-isolated
state, even when they are declared as instance members of the actor.

On the other hand, actor-independent declarations can be used to
conform to (synchronous) requirements in protocols.
2020-09-18 22:56:17 -07:00
Doug Gregor
ab4c58482e [Concurrency] Centralize rejection of concurrency-only attributes.
Reject concurrency-only attributes in the parser if the experimental
concurrency mode is not enabled.
2020-09-18 12:24:19 -07:00
Doug Gregor
cb6429530c [Concurrency] Actor-isolated members cannot satisfy protocol requirements.
Enforce the actor-isolation constraint that an actor-isolated member
(e.g., a non-async instance method or an instance property) cannot be
used to conform to a protocol requirement.
2020-09-17 13:36:57 -07:00
Doug Gregor
22a350b1ac [Concurrency] Add parsing support for actor classes.
Introduce the "actor class" syntax. Ensure that it is only used for
root classes or classes that inherit from other actor classes.
2020-09-09 20:46:30 -07:00
Anthony Latsis
4b4634141f Sema: Remove TypeLoc from ExplicitCast 2020-06-09 15:20:25 +03:00
Slava Pestov
0eb2484a93 AST: Only build request dependency graph if frontend is run with -build-request-dependency-graph
This adds a measurable amount of runtime overhead, but it's only
needed for debugging.
2020-01-08 22:35:55 -05:00
Robert Widmann
e7170bd751 Add Qualified Lookup Requests 2019-12-16 15:36:09 -08:00
Robert Widmann
371526bdea Add a high-level request to type check a file 2019-12-03 17:16:14 -08:00
Hamish Knight
eacca4ed0c Requestify circular inheritance checking
Add requests for checking whether a class,
protocol, or enum have circular references in
their inheritance lists.
2019-11-11 09:34:56 -08:00
Hamish Knight
16cff49e65 [Sema] Requestify inheritsSuperclassInitializers (#27936)
* [Sema] Factor out shouldAttemptInitializerSynthesis

This makes sure we don't attempt to synthesize
a memberwise or default initializer for an invalid
decl, or one in a module interface.

* [Sema] Requesify inheritsSuperclassInitializers

This commit introduces a request for computing
whether a class inherits both designated and
convenience initializers from its superclass.

The shared logic of finding initializers which the
subclass hasn't overriden has been factored out
into `collectNonOveriddenSuperclassInits`.

* Cleanup addImplicitInheritedConstructorsToClass

This commit removes some code that's no longer
needed. In addition, now that we've requestified
`inheritsSuperclassInitializers`, we can directly
diagnose on non-inherited required convenience
inits within the loop.

* Inherited init synthesis no longer deals with clang decls

Now that the computation of
`inheritsSuperclassInitializers` has been split off
into a request, we can avoid calling
`addImplicitInheritedConstructorsToClass` for clang
decls.

* Address review feedback

Continue to cache the InheritsSuperclassInits bit
on the AST.
2019-10-31 11:07:06 -07:00
Slava Pestov
a260d0a445 AST: getInterfaceType() returns ErrorType instead of Type() on circularity 2019-10-08 01:37:09 -04:00
Pavel Yaskevich
d0530b996c Merge pull request #26798 from xedin/introduces-cs-holes
[ConstraintSystem] Introduce a notion of a "hole"
2019-08-27 15:54:01 -07:00
Doug Gregor
1ee6d8139a [Constraint solver] Cope with circular inheritance.
This loop in the constraint solver won't terminate when given
ill-formed code involving circular inheritance. Make it
terminate. Fixes rdar://problem/54296278.
2019-08-27 10:29:36 -07:00
Pavel Yaskevich
fbb55ce5bc [Diagnostics] Add a tailored diagnostic for no accessible initializers 2019-08-22 17:25:24 -07:00
Slava Pestov
ed3e4dc931 Sema: Add implicit constructors before checking members 2019-07-17 18:07:03 -04:00
Brent Royal-Gordon
9117c5728a Allow inheritance from resilient classes with missing members
When a class has missing vtable entries, we don’t allow it to be subclassed. This is unnecessarily restrictive for resilient classes, and @_implementationOnly imports now make missing vtable entries much more common. This commit carves out an exception to that rule for resilient classes.

Fixes <rdar://problem/50902125>.
2019-05-17 20:05:19 -07:00
Sam Lazarus
3d9b6396a1 Merge pull request #24059 from sl/sl/sr-10293
Allow var / let as parameter names but provide a warning and fixit to add backticks.
2019-04-26 09:30:23 -04:00
Sam Lazarus
ede8127adf Test: Add and update tests for allowing var and let as argument labels 2019-04-26 04:08:27 -04:00
Slava Pestov
3f5a06bc3e AST: Always diagnose request evaluator cycles 2019-04-22 22:22:23 -04:00
Slava Pestov
691802c65c Sema: Fix override matching of inout and vararg parameters
First, if the base parameter is inout or vararg, the derived parameter
must be too. Second, we do not allow covariant overrides of inout or
vararg parameters.

Fixes <https://bugs.swift.org/browse/SR-10231>.
2019-04-01 22:41:16 -04:00
fischertony
762eec38f3 [Sema] Always allow public overrides of open methods 2019-02-27 06:31:43 +03:00