Commit Graph

18963 Commits

Author SHA1 Message Date
Pavel Yaskevich
51ff12d06e [ConstraintLocator] Augment ContextualType element to carry its purpose
Having purpose attached to the contextual type element makes it much
easier to diagnose contextual mismatches without involving constraint
system state.
2021-04-26 09:51:21 -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
Hamish Knight
d309caea11 [AST] Remove 'is super' bit on ApplyExpr
This appears to be equivalent to
`getArg()->isSuperExpr()`. Let's use that instead.
2021-04-26 12:06:52 +01:00
Luciano Almeida
c15dde4265 Merge pull request #37057 from LucianoPAlmeida/placeholder-checkedcast-warn
[Sema] Do not attempt warn extraneous checked cast for placeholder types
2021-04-25 08:03:18 -03:00
Doug Gregor
02821fd0f4 Merge pull request #37053 from DougGregor/disable-actor-inheritance 2021-04-24 22:31:09 -07:00
Luciano Almeida
b851974424 [Sema] Do not attempt warn extraneous checked cast for placeholder types 2021-04-24 23:52:58 -03:00
Evan Wilde
e9baa3fdd3 Fix interpolated string effect placement
This fixes the placement of the await fix-it inside of interpolated
strings. We were putting the effect between the `\` and `(`, which
doesn't exactly work out very well. I'm intentionally being relatively
gentle with the casting when grabbing the body of the interpolated
string.

I can't think of a valid expression that doesn't result in that
structure, so it's probably safe to do a straight cast, and probably
should switch it over eventually. In the current state-of-affairs, it
will put the fix-it placement in the wrong place if my assumptions are
broken about the structure of the code.
2021-04-24 07:51:18 -07:00
Evan Wilde
fffedc79b6 Update error messages
This patch restructures how we emit the effect errors for missing
awaits. As we're traversing the expressions, we collect all of the
locations where a missing await is, and metadata about the reason for
the error, as well as the "anchor".

The anchor is where the await should actually be placed in the
expression to fix things. The error is emitted for the whole
sub-expression instead of for the exact synchronization/call-site of the
async function. This avoids the erroneous message for

```
 _ = 32 + asyncFunc()
```

The old behaviour was to put the `await` between the `+` operator and
the call to `asyncFunc()`, but this is not a valid place to put effects.
Note; this issue is also present in the fix-it for `try` insertions and
also needs to be fixed. Instead, the anchor points between the
assignment expression and 32, labelling the whole right-side of the
assignment as being the asynchronous function. We emit notes for each
uncovered async point in the entire expression though, so that someone
can see why the expression is async.
2021-04-24 07:51:18 -07:00
Evan Wilde
3ece00452a Record initial parent map
We need to be able to traverse back to the top of expressions in order
to emit the diagnostic to the right place. This patch records the parent
map of the highest expression in the tree that the checker was
constructed with. This will record the mapping for all sub-expressions
as well.
2021-04-23 21:47:43 -07:00
Evan Wilde
a7b4d3692b Add pre-expr visit
Adding an expression pre-visit to the EffectHandling walker, allowing
sub-classes visit all expressions.
2021-04-23 21:44:12 -07:00
Ikko Ashimine
2d702b86ca [ConstraintGraph] Fix typo
absense -> absence
2021-04-24 09:59:35 +09: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
Pavel Yaskevich
5a7fd6825d Merge pull request #36732 from Strieker/composed_property_wrapper_improved_error_handling
Improved error handling for composed property wrapper mismatches
2021-04-23 09:22:21 -07:00
Doug Gregor
7cc19b5807 [SE-0306] Require 'nonisolated' on lets for synchronous cross-actor access. 2021-04-23 02:20:35 -07:00
Alexis Laferrière
c0394f6421 Merge pull request #36996 from xymus/lib-access-level-spi-in-api
[Sema] Allow SPI use in API for a module that is completely SPI
2021-04-22 16:54:49 -07:00
Strieker
4e2b67cbae [NFC] Resolved merge conflict in CSSimplify.cpp after making changes to improve error handling for composed wrapped value mismatches 2021-04-22 11:49:21 -07:00
Strieker
b3f0442faa [ConstraintSystem] Modified CSGen.cpp in order to resolve a failing test in property_wrappers.swift 2021-04-22 11:31:42 -07:00
Strieker
c9b53ec66f [ConstraintSystem] Created a locator in CSGen to store the location where the wrappedValue type of a property wrapper was determined and added necessary logic so that a constraint locator can recognize a composed property wrapper’s wrapped value type in CSFix.cpp, CSFix.h, and CSSimplify.cpp. 2021-04-22 11:31:41 -07:00
Strieker
11efb7d0b3 [Diagnostics] Added new diagnostic error string for composed property wrapper mismatch in DiagnosticsSema.def and made changes to show the new composed property wrapper mismatch type diagnostic in both CSDiagnostics.cpp and CSDiagnostics.h. 2021-04-22 11:31:41 -07:00
Strieker
3891dc7fdc [ConstraintSystem] Added necessary logic so that a constraint locator can recognize a composed property wrapper’s wrapped value type. 2021-04-22 11:31:41 -07:00
Alex Hoppen
1504870004 Merge pull request #36973 from ahoppen/pr/create-implicit-switch-stmt
[AST] Add method to create an implicit `SwitchStmt`
2021-04-22 11:42:08 +02:00
Doug Gregor
90c1fece9e Merge pull request #37002 from DougGregor/inherit-actor-context-attr 2021-04-21 23:10:56 -07:00
Doug Gregor
6928c3f1c9 Make sure that we perform the actor hop for @_inheritActorContext 2021-04-21 17:35:17 -07:00
Robert Widmann
ce7bdab9e4 Merge pull request #36752 from LucianoPAlmeida/SR-9425-enum-eq
[SR-9425][Sema] Use derived conformance as witness when possible for == operator of raw representable enums
2021-04-21 16:39:38 -07:00
Doug Gregor
b9f1e7f626 [Concurrency] Add @_inheritActorContext hidden parameter attribute.
This new attribute can be used on parameters of `@Sendable async` type
to indicate that the closures arguments passed to such parameters
should inherit the actor context where they are formed, which is not
the normal behavior for `@Sendable` closures.

Another part of rdar://76927008.
2021-04-21 15:23:27 -07:00
Slava Pestov
bfa690e121 Merge pull request #36403 from slavapestov/remove-synthesized-decls
Sema: Remove SourceFile::SynthesizedDecls
2021-04-21 15:11:13 -04:00
Alex Hoppen
b68443156a Merge pull request #36818 from ahoppen/pr/rdar76329083
[TypeChecker] Fix assertion failure when using Self in extension that’s not on top-level
2021-04-21 10:20:57 +02:00
Slava Pestov
8464afd738 Sema: Remove SourceFile::SynthesizedDecls 2021-04-21 00:07:29 -04:00
Slava Pestov
e53bd7f6b3 AutoDiff: Check conformances on synthesized TangentVector struct
Once SF.SynthesizedDecls is gone, we can't rely on this happening for us.
2021-04-21 00:07:28 -04:00
Slava Pestov
1b91218633 AutoDiff: Don't check hasInterfaceType() in ResolveEffectiveMemberwiseInitRequest::evaluate()
This check made this request depend on evaluation order, sometimes
synthesizing a second memberwise initializer if the previous one's
interface type had not been computed yet.
2021-04-21 00:07:28 -04:00
Slava Pestov
7839ab6947 AutoDiff: Synthesize the memberwise initializer earlier
We need to do this before we synthesize the body of the
AdditiveArithmetic witnesses, so that it becomes part of
the ABI members of the nominal.
2021-04-21 00:07:28 -04:00
Slava Pestov
f6b191b69a AutoDiff: Use getLocalProtocols() instead of getInheritedProtocols() 2021-04-21 00:07:28 -04:00
Slava Pestov
c530baa518 AutoDiff: Clean up getOrSynthesizeTangentVectorStruct() a bit 2021-04-21 00:07:28 -04:00
Luciano Almeida
5eb893f6b5 [Sema] Make isRawRepresentableGenericFunction to make sure is the stdlib fn and the requirement are exact 2021-04-20 23:57:53 -03:00
Doug Gregor
abfc9bcdc4 Add @_implicitSelfCapture attribute to disable "self." requirement.
Add a new parameter attribute `@_implicitSelfCapture` that disables the
requirement to explicitly use `self.` to refer to a member of `self`
in an escaping closure.

Part of rdar://76927008.
2021-04-20 17:26:07 -07:00
Luciano Almeida
c43ca8a287 [Sema] Adapt witness resolver to fail if default RawRepresentable generic function is best witness when raw representable enum can derive equatable conformance 2021-04-20 19:50:13 -03:00
Alexis Laferrière
758351110a [Sema] Allow the use of SPI in API for SPI modules
When the whole module has an SPI distribution, SPI declarations can be
used in API.

rdar://75335462
2021-04-20 15:02:51 -07:00
Alex Hoppen
aa69529809 [AST] Add method to create an implicit SwitchStmt
There are a number of occurances that create implicit `Switch`s by passing `SourceLoc()` for all location paramters. Refactor those occurances out to a separate `createImplicit` method that automatically fills the locations with invalid source locations.
2021-04-20 22:34:09 +02:00
Evan Wilde
a11e2642f7 Merge pull request #36972 from etcwilde/ewilde/no-global-actor-deinit
[Concurrency] Don't propagate global actor-ness to deinit
2021-04-20 12:58:59 -07:00
Alejandro Alonso
444c35cf8d Merge pull request #36953 from Azoy/isType-isDeclType
[NFC] Introduce isDecl and getDeclType
2021-04-20 15:33:00 -04:00
Evan Wilde
b1c5505e0c Don't propagate global actor to deinit
Destructors can't be run on the main actor since they may be called from
a asynchronous context. Because we are the only ones with a handle to
the class, we can touch Main-Actor protected properties from anywhere
safely. We can't touch static properties though since those will still
be alive and accessible from outside of just this dying instance.
2021-04-20 10:17:50 -07:00
Azoy
9ed732f0ab Introduce isDecl and getDeclType
fix enum logic issue

fix tests

guard against null types
2021-04-20 02:22:16 -04:00
Pavel Yaskevich
7e406a753d Merge pull request #36948 from Jumhyn/placeholder-type-get-fix
[Sema] Fix stale reference passed to PlaceholderType::get
2021-04-19 11:09:12 -07:00
Nathan Hawes
f75f5fe78d Merge pull request #36879 from nathawes/track-match-call-result
[ConstraintSystem] Record parameter bindings in solutions (NFC)
2021-04-18 06:10:23 +10:00
Doug Gregor
3b62296170 Merge pull request #36907 from DougGregor/global-actor-function-type-isolation 2021-04-16 21:22:02 -07:00
Frederick Kellison-Linn
237b73d7b2 [Sema] Fix stale reference passed to PlaceholderType::get 2021-04-16 23:00:12 -04:00
Pavel Yaskevich
593bbab880 [TypeChecker] PreCheck: Don't strip away tuple/paren from subscripts and ObjC literals
`PreCheckExpression` already skips calls, make sure that invalid subscripts,
dynamic subscript, ObjC literals preserve paren/tuple for an index/argument.

Resolves: rdar://61749633
2021-04-16 11:40:19 -07:00
Luciano Almeida
00c25317ea Merge pull request #36883 from LucianoPAlmeida/SR-13483-closure-args
[SR-13483][Sema] Make sure to record the correct remove args fix when repairing a tuple destructure attempt
2021-04-16 08:34:07 -03:00
Alex Hoppen
282cbc3590 Merge pull request #36930 from ahoppen/pr/complete-switch-expr-in-closure
[Parse] Create SwitchStmt nodes for `switch` statements with errors
2021-04-16 10:44:00 +02:00
Nathan Hawes
c57c403ffa [ConstraintSystem] Record parameter bindings in solutions (NFC)
This saves us from needing to re-match args to params in CSApply and is also
useful for a forthcoming change migrating code completion in argument position
to use the solver-based typeCheckForCodeCompletion api.

rdar://76581093
2021-04-16 18:32:06 +10:00