Commit Graph

1245 Commits

Author SHA1 Message Date
Hamish Knight
3e28bbbd2c Update for review feedback
- Remove OriginalArguments in favor of storing the
pre-rewritten argument list, which simplifies things
nicely
- Adopt llvm::indexed_accessor_iterator
2021-09-01 18:40:29 +01:00
Hamish Knight
8c2b88abc0 [CS] Adopt ArgumentList
- Explicitly limit favoring logic to only handle
unary args, this seems to have always been the
case, but needs to be handled explicitly now that
argument lists aren't exprs
- Update the ConstraintLocator simplification to
handle argument lists
- Store a mapping of locators to argument lists
in the constraint system
- Abstract more logic into a getArgumentLocator
method which retrieves an argument-to-param locator
from an argument anchor expr
2021-09-01 18:40:25 +01:00
swift-ci
5fe1881a91 Merge remote-tracking branch 'origin/main' into rebranch 2021-08-27 21:53:32 -07:00
Rintaro Ishizaki
49547a5378 [NFC][Basic] Import llvm::isa_and_nonnull to 'swift' namespace
Just for convenicence.

* Replace `llvm::isa_and_nonnull` with imported `isa_and_nonnull`
* Repalce some `EXPR && isa<T>(EXPR)` with `isa_and_nonnull<T>(EXPR)`
2021-08-27 11:36:21 -07:00
swift-ci
0a4b07a10c Merge remote-tracking branch 'origin/main' into rebranch 2021-08-20 09:33:58 -07:00
Frederick Kellison-Linn
5f07747cb3 [Sema] Diagnose user-specified placeholders which couldn’t be resolved 2021-08-19 14:53:33 -04:00
swift-ci
6f33655298 Merge remote-tracking branch 'origin/main' into rebranch 2021-08-13 19:53:46 -07:00
Pavel Yaskevich
994f9a9a3d [Diagnostics] Result Builders: Improve diagnostic for unsupported observed vars 2021-08-13 13:42:13 -07:00
Pavel Yaskevich
0074adc6fe [Diagnostics] Result Builders: Extract pattern binding and var storage diagnostics into methods 2021-08-13 12:30:16 -07:00
Pavel Yaskevich
85d203cb34 [Diagnostics] Result Builders: Improve diagnostic for unsupported lazy/wrapped/computed vars 2021-08-13 12:04:06 -07:00
Pavel Yaskevich
67377216de [Diagnostics] Result Builders: Improve diagnostic for uninitialized variable declarations
Resolves: rdar://81532339
2021-08-13 10:41:13 -07:00
swift-ci
2aedbaa7ef Merge remote-tracking branch 'origin/main' into rebranch 2021-08-10 12:13:26 -07:00
Hamish Knight
e82edadee7 Remove some obsolete literal handling logic
We no longer convert literals into constructor
calls in Sema, SILGen emits the necessary calls.
2021-08-06 17:07:22 +01:00
Arnold Schwaighofer
5a83172a55 Merge remote-tracking branch 'upstream/main' into rebranch 2021-08-05 12:04:56 -07:00
Hamish Knight
21e8a320ec [CS] Better handle paren fix-its for unresolved chains
I missed this case when previously improving the
logic here. As it turns out, using the raw anchor
as the root expression from which to derive parent
information is insufficient. This is because it
may not capture relevant parent exprs not a part
of the fix locator.

Instead, pass down a function that can be used to
derive the parent expressions from the constraint
system's own parent map. Also make sure to assign
to `expr` for the UnresolvedMemberChainResultExpr
case to make sure we correctly check for it as a
sub-expression.

Finally, now that we're looking at more parent
exprs, add logic to handle `try` and `await`
parents, as well as ClosureExprs and
CollectionExprs. I couldn't come up with a test
case for CollectionExpr, as we emit different
diagnostics in that case, but it's probably better
to tend on the side of being more future proof
there.

rdar://81512079
2021-08-04 14:34:24 +01:00
willtunnels
319b3e64aa Add support for opaque result types in structural positions (#38392)
* [TypeResolver][TypeChecker] Add support for structural opaque result types

* [TypeResolver][TypeChecker] Clean up changes that add structural opaque result types
2021-08-03 23:45:02 -04:00
Hamish Knight
84a2c5c2c1 [Sema] Improve extra trailing closure diagnostic
Emit the specialized extraneous trailing closure
diagnostic for multiple trailing closures and
unlabelled unary argument lists, and add a
specialized trailing closure version for the multiple
extraneous case.
2021-08-02 12:59:43 +01:00
swift-ci
1fc44750c3 Merge remote-tracking branch 'origin/main' into rebranch 2021-07-28 13:54:07 -07:00
Doug Gregor
7c0bdff052 Improve misleading diagnostics regarding implicit Sendable conformances 2021-07-28 10:41:59 -07:00
swift-ci
a2a6e5a7e8 Merge remote-tracking branch 'origin/main' into rebranch 2021-07-27 02:53:21 -07:00
Hamish Knight
5d1fea24ad [CS] Don't consider implicit TupleExprs in exprNeedsParensOutsideFollowingOperator
Such implicit tuples may be used to represent
argument lists for e.g binary expressions, and as
such shouldn't be considered as parent exprs that
satisfy the role of parentheses.

Also fix the callers to use the raw anchor as the
root expression they pass to provide an accurate
parent map. This requires sinking the
UnresolvedMemberChainResultExpr handling logic into
`getPrecedenceParentAndIndex`.

rdar://81109287
2021-07-26 18:17:01 +01:00
swift-ci
fd87ebc401 Merge remote-tracking branch 'origin/main' into rebranch 2021-07-23 07:13:34 -07:00
Robert Widmann
d86551de67 Lift Requirement and Parameter Accessors up to GenericSignature
Start treating the null {Can}GenericSignature as a regular signature
with no requirements and no parameters. This not only makes for a much
safer abstraction, but allows us to simplify a lot of the clients of
GenericSignature that would previously have to check for null before
using the abstraction.
2021-07-22 23:27:05 -07:00
swift-ci
a3ebc9a069 Merge remote-tracking branch 'origin/main' into rebranch 2021-07-12 10:51:07 -07:00
Doug Gregor
29f5d7a64a [SE-0302] Implement '@unchecked Sendable' syntax.
Parse and provide semantic checking for '@unchecked Sendable', for a
Sendable conformance that doesn't perform additional semantic checks
for correctness.

Part of rdar://78269000.
2021-07-11 12:29:53 -07:00
swift-ci
e0e2634b84 Merge remote-tracking branch 'origin/main' into rebranch 2021-07-06 09:35:07 -07:00
OneUpWallStreet
25df5d2c48 Fixed some common grammatical errors in the comments. (#38248) 2021-07-05 01:00:48 -07:00
Evan Wilde
42ff140171 llvm::StringRef equals_lower -> equals_insensitive
The `equals_lower` API was replaced with `equals_insensitive` in llvm
commit 2e4a2b8430aca6f7aef8100a5ff81ca0328d03f9 and
3eed57e7ef7da5eda765ccc19fd26fb8dfcd8d41.

Ran git clang-format.

(cherry picked from commit e21e70a6bf)
2021-07-02 10:55:17 -07:00
Luciano Almeida
7f085082dd Merge pull request #38153 from JiarenWang/wjr
[SR-14824] Improve diagnostic for multi-statement closures instead of…
2021-07-01 08:56:10 -03:00
Luciano Almeida
0519dd7cab [Sema] Adjustments on implementation and diagnostic message for SR-14720 2021-06-30 06:39:04 -03:00
Luciano Almeida
51ee1de6f9 [Sema] Adjust escapeness function parameter diagnostic to use decl description 2021-06-30 06:39:04 -03:00
Luciano Almeida
48792bbfdc [Sema] Add tailored diagnostic for a escapeness mismatch in a fn type parameter position 2021-06-30 06:39:04 -03:00
jiaren wang
c5de1f0800 [SR-14824] Improve diagnostic for multi-statement closures instead of saying "too complex closure return type" 2021-06-30 14:36:38 +08:00
Holly Borla
89418c6766 Merge pull request #38112 from hborla/return-type-fixit-loc
[Diagnostics] Correct the insert location of missing return type fix-it.
2021-06-28 16:29:34 -07:00
Pavel Yaskevich
6fcb47d790 Merge pull request #38111 from xedin/rdar-79672230
[Diagnostics] Fix requirement note to properly handle layout requirements
2021-06-28 10:03:08 -07:00
Holly Borla
e139c45702 [Diagnostics] In ExtraneousReturnFailure, insert the return type fix-it
after any effects specifiers like async, throws, rethrows, etc.
2021-06-28 09:44:38 -07:00
Pavel Yaskevich
2b58a75f97 [Diagnostics] Fix requirement note to properly handle layout requirements
Layout requirement doesn't have a second type since it's always `AnyObject`,
requirement failure note should handle that, otherwise in no assertion builds
this would crash in diagnostic engine trying to emit the note.

Resolves: rdar://79672230
2021-06-25 14:08:43 -07:00
Pavel Yaskevich
51fe32dc1a [Diagnostics] NFC: Remove unused last argument from requirement failure notes 2021-06-25 13:44:30 -07:00
Holly Borla
d083c66686 [ConstraintSystem] Before matching tuple types, add each complete tuple
type to the locator.

This will provide context for tuple element mismatch diagnostics, instead
of attempting to compute the full tuple type in diagnostics code with a pile
of special cases (see getStructuralTypeContext in CSFix.cpp).
2021-06-24 09:40:14 -07:00
Pavel Yaskevich
fc982aec83 [Diagnostics] Use signed integer to store difference in optionality between types
For checked cast coercion warnings let's store difference in optionality
as an `int` because it's possible that "to" type is more optional than
"from" type.
2021-06-21 13:31:59 -07:00
Pavel Yaskevich
0d50593f68 [Diagnostics] NFC: Fix a typo in a method name: wrapedTypes -> wrappedTypes 2021-06-21 13:31:59 -07:00
Pavel Yaskevich
b4c873aa55 Merge pull request #37941 from LucianoPAlmeida/SR-14784-diag
[SR-14784][Sema] Make sure we look through optionals on anchor fnType for MissingCallFailure
2021-06-16 09:55:11 -07:00
Luciano Almeida
33e47c1e6b [Sema] Make sure we look through optionals on anchor fnType for MissingCallFailure 2021-06-15 23:41:11 -03:00
Pavel Yaskevich
7089b35bcf [AST] NFC: Clarify when extension type repr wouldn't be available 2021-06-14 17:56:40 -07:00
Pavel Yaskevich
a7988b0633 [Diagnostics] Make sure extension type repr is available before using it
Before suggesting to add `where Self == ...` condition to the extension
of a protocol involved in a static member lookup, let's check whether
type repr is available and valid.

Resolves: rdar://78097387
2021-06-14 17:56:16 -07:00
Pavel Yaskevich
2b207e8f07 [Diagnostics] Augment "expected parameter" note with an argument type
Currently ambiguity notes attached to a candidate only mention
expected type and its position. To improve clarify of such notes
it's useful to print argument type as well since it's not always
clear what it is at the first glance at the code.

Resolves: SR-14634
Resolves: rdar://78224323
2021-05-26 12:58:35 -07:00
Hamish Knight
46fa6e5721 [AST] Improve BinaryExpr
Abstract away the TupleExpr gunk and expose
`getLHS` and `getRHS` accessors. This is in
preparation for completely expunging the use
of TupleExpr as an argument list.
2021-05-19 14:48:01 +01:00
Slava Pestov
131d3f4bce Sema: Pass down a ModuleDecl instead of a DeclContext to conformsToProtocol()
... and a bunch of follow-up simplifications pushing ModuleDecls further
up, since I couldn't resist the yak shave.
2021-05-17 16:34:18 -04:00
Holly Borla
e1591314cf Merge pull request #37380 from hborla/property-wrapper-inference-crash
[ConstraintSystem] Fix a constraint system crash with property wrapper inference using the $ syntax.
2021-05-12 08:55:51 -07:00
Holly Borla
c297070106 [Diagnostics] Always use the parameter name for closure parameter diagnostics,
because the $ prefix does not indicate that the parameter is anonymous.
2021-05-11 18:30:27 -07:00