Commit Graph

985 Commits

Author SHA1 Message Date
jreference
2cf01a18de [Sema] Fix issue 65330 Unhelpful error when missing contextually required as bridging conversion to AnyObject in structural position. Minor formatting change in previous test case 2023-05-06 10:47:15 +08:00
Pavel Yaskevich
cb2fdd9b54 [CSDiagnostics] Add a diagnostic for pack expansions without pack references 2023-05-02 09:32:19 -07:00
Pavel Yaskevich
c74824e1ab [CSDiagnostics] Diagnose situations when value pack expansion does expect a tuple argument
Diagnose situation when a single argument to tuple type is passed to
a value pack expansion parameter that expects distinct N elements:

```swift
struct S<each T> {
  func test(x: Int, _: repeat each T) {}
}

S<Int, String>().test(x: 42, (2, "b"))
```
2023-05-02 09:32:19 -07:00
Pavel Yaskevich
03f88a0041 [CSSimplify] Add tailored diagnostics for same-shape mismatches related to arguments
Suggest to drop tuples, synthesized or remove extraneous arguments
based on pack shape mismatches.
2023-05-02 09:32:19 -07:00
Holly Borla
234b5dc660 [SE-0393] Require the repeat keyword for generic requirement expansions. 2023-04-12 22:04:01 -07:00
Pavel Yaskevich
c7766763e8 Merge pull request #64846 from Rajveer100/branch-for-issue-53822
Improved Cast Diagnostics when Literals are involved
2023-04-07 20:31:58 -07:00
Alex Lorenz
64a4b3159c [interop] add SWIFT_ prefix to the C++ interop annotations 2023-04-06 12:11:25 -07:00
Rajveer
2c96e90c71 [Sema] Improved Cast Diagnostics when Literals are involved
Fixes Issue #53822
2023-04-07 00:18:02 +05:30
Alex Lorenz
30d0c17bf9 [interop] update names and add docs for the interop C++ helper macros 2023-04-04 15:13:59 -07:00
Zoe Carver
e93e7d1b7a Merge pull request #64513 from zoecarver/revert-75dc69a81da07647bda2d1ccc3b82ce6e68b44a7
Revert 75dc69a81d
2023-03-23 09:58:10 -07:00
Holly Borla
da3079de05 [ConstraintSystem] Diagnose pack expansion expressions in non-variadic contexts. 2023-03-21 21:58:05 -07:00
Holly Borla
c60b4860ab Merge pull request #64498 from hborla/diagnose-pack-outside-expansion-expr
[ConstraintSystem] Enforce `TVO_CanBindToPack`, and diagnose pack references outside of pack expansion expressions.
2023-03-21 14:00:52 -07:00
zoecarver
4c73369366 Revert "[cxx-interop] Add debug dump when we hit The Flakey Issue™."
This reverts commit 75dc69a81d.
2023-03-21 13:27:17 -07:00
zoecarver
00dc5406fb Revert "[nfc] Fix a few warnings I introduced."
This reverts commit 077d3cb8b3.
2023-03-21 13:27:11 -07:00
Alex Hoppen
9bd880ddde Merge pull request #64405 from ahoppen/ahoppen/fix-locator-simplification
[CS] Fix locator simplification with 'Member' path element
2023-03-21 09:19:14 -07:00
Holly Borla
cb19fc3a71 [ConstraintSystem] Enforce TVO_CanBindToPack, and diagnose pack references outside
of pack expansion expressions.
2023-03-20 20:13:48 -07:00
zoecarver
fcd72898e3 [cxx-interop] Suggest 'self_contained' fixit on return type, not parent. 2023-03-20 16:14:42 -07:00
zoecarver
d9a063c137 [cxx-interop] Attempt to fix at -> subscript fix-it. 2023-03-20 16:14:42 -07:00
zoecarver
30482c39cf [cxx-interop] Fix end -> nil fixit. 2023-03-20 16:14:42 -07:00
zoecarver
048e5c73f6 [cxx-interop] Update fix-its to use new macro naming. 2023-03-20 16:14:42 -07:00
zoecarver
ebc492a368 [cxx-interop] Add fix-its to apply 'safe_to_import' and 'self_contained'. 2023-03-20 16:14:42 -07:00
Alex Hoppen
cebc084367 [CS] Fix locator simplification with 'Member' path element
Previously, a `Member` path element in a `ConstraintLocator` was simplified to the base on which the member was accessed. This is incorrect.
2023-03-20 09:19:21 -07:00
zoecarver
077d3cb8b3 [nfc] Fix a few warnings I introduced. 2023-03-17 13:49:47 -07:00
Pavel Yaskevich
ed9e2d6f6b Merge pull request #64398 from xedin/rdar-106621760
[CSDiagnostics] Ignore placeholder types that appear in editor placeh…
2023-03-16 10:22:20 -07:00
Luciano Almeida
4d981e3c0b Merge pull request #63904 from LucianoPAlmeida/ambiguous-overload
[Sema] Diagnose function coercion ambiguity
2023-03-15 23:18:00 -03:00
Zoe Carver
e5cc1163ab Merge pull request #64395 from zoecarver/user/zoecarver/97361196-take-two
[cxx-interop] Add debug dump when we hit The Flakey Issue™.
2023-03-15 16:41:33 -07:00
Pavel Yaskevich
d1badfeda4 [CSDiagnostics] Ignore placeholder types that appear in editor placeholder expressions
When placeholder type appears in an editor placeholder i.e.
`<#T##() -> _#>` we rely on the parser to produce a diagnostic
about editor placeholder and glance over all placeholer type
inference issues.

Resolves: rdar://106621760
2023-03-15 12:53:12 -07:00
zoecarver
75dc69a81d [cxx-interop] Add debug dump when we hit The Flakey Issue™.
This commit should be reverted in a week or two. Sorry.
2023-03-15 12:46:53 -07:00
Luciano Almeida
b375c097a9 [Diagnostic] Fix regression in requirement diagnostics 2023-03-15 09:45:30 -03:00
Luciano Almeida
4ebedc8333 [Sema] Adjust getCalleeLocator to look into coercion operand 2023-03-14 23:06:11 -03:00
Pavel Yaskevich
438ee330f1 [ConstraintSystem] Add new conversion kind - ArrayToCPointer
It's `ArrayToPointer` conversion that has PointerToCPointer
semantics for (un-)signed integer element types.
2023-03-14 11:22:52 -07:00
Luciano Almeida
5fee07b73f [CSDiagnostics] Adapt diagnostics to handle new CoercionOperand elt 2023-03-11 18:47:53 -03:00
Luciano Almeida
63315ccce9 [Diagnostics] Adjust ExtraneousArgumentsFailure note diagnostic 2023-03-11 18:47:52 -03:00
Holly Borla
8012e45109 [Diagnostics] Diagnose pack element expressions containing a non-pack subexpression. 2023-03-05 00:11:54 -08:00
Andrew Trick
f1ff6958a3 Merge pull request #63825 from atrick/diagnose-implicit-raw-bitwise
Warn on implicit pointer conversion from nontrivial inout values.
2023-03-02 10:57:30 -08:00
Kavon Farvardin
cc0b668efb Merge pull request #63922 from kavon/standard-issue-neuralyzer
Implement the `forget` statement (as `_forget`)
2023-03-01 11:10:25 -08:00
Kavon Farvardin
f41ed5926b implement the forget statement
Currently, this is staged in as `_forget`,
as part of SE-390. It can only be used on
`self` for a move-only type within a consuming
method or accessor. There are other rules, see
Sema for the details.

A `forget self` really just consumes self and
performs memberwise destruction of its data.
Thus, the current expansion of this statement
just reuses what we inject into the end of a
deinit.

Parsing of `forget` is "contextual".
By contextual I mean that we do lookahead to
the next token and see if it's identifier-like.
If so, then we parse it as the `forget` statement.
Otherwise, we parse it as though "forget" is an
identifier as part of some expression.

This way, we won't introduce a source break for
people who wrote code that calls a forget
function.

This should make it seamless to change it from
`_forget` to `forget` in the future.

resolves rdar://105795731
2023-02-28 21:15:17 -08:00
Doug Gregor
200f2340d9 [Macros] Be deliberate about walking macro arguments vs. expansions
Provide ASTWalker with a customization point to specify whether to
check macro arguments (which are type checked but never emitted), the
macro expansion (which is the result of applying the macro and is
actually emitted into the source), or both. Provide answers for the
~115 different ASTWalker visitors throughout the code base.

Fixes rdar://104042945, which concerns checking of effects in
macro arguments---which we shouldn't do.
2023-02-28 17:48:23 -08:00
Andrew Trick
185e6fabd5 Add TypeBase::isArrayType helper API.
This is also needed in SIL diagnostics, not just Sema diagnostics,
because implicit Array conversion generates special SIL patterns.
2023-02-27 21:51:17 -08:00
Zoe Carver
5406f1aafe Merge pull request #63673 from zoecarver/fixits-for-common-swiftifications
[cxx-interop] Offer fix-it to re-write ".at(42)" as "[42]".
2023-02-22 10:13:36 -08:00
zoecarver
38658a051f [cxx-interop] Fix test for linux; bail if we didn't load the overlay. 2023-02-21 10:52:57 -08:00
Luciano Almeida
22a18de1b1 [Sema] Improving integer literal as boolean diagnostic 2023-02-21 10:30:48 -03:00
zoecarver
1b0ee8e8de [cxx-interop] Fix two source locations; replace end with nil. 2023-02-20 14:57:51 -08:00
zoecarver
d19b587c35 [cxx-interop] Update based on review feedback. 2023-02-20 14:57:50 -08:00
zoecarver
5ac94a8a90 [cxx-interop] Completely overhaul diagnostics/notes for unsafe projections. 2023-02-20 14:57:50 -08:00
zoecarver
4e0860b0d2 [cxx-interp] Add fix-its for front(), back(), begin(), and end(). 2023-02-20 14:57:50 -08:00
zoecarver
9ce9310df5 [cxx-interop] Offer fix-it to re-write ".at(42)" as "[42]".
Only applies to random access collections. The first of many fix-its like this :)
2023-02-20 14:57:50 -08:00
Hamish Knight
c87b1b8bef Merge pull request #63022 from hamishknight/express-yourself 2023-02-03 16:40:09 +00:00
Kavon Farvardin
ab130883a3 Initial ban of move-only types from being used generically
Since values of generic type are currently assumed to always
support copying, we need to prevent move-only types from
being substituted for generic type parameters.

This approach leans on a `_Copyable` marker protocol to which
all generic type parameters implicitly must conform.

A few other changes in this initial implementation:

- Now every concrete type that can conform to Copyable will do so. This fixes issues with conforming to a protocol that requires Copyable.
- Narrowly ban writing a concrete type `[T]` when `T` is move-only.
2023-02-01 23:38:28 -08:00
Holly Borla
e41cdfbdd4 Merge pull request #63341 from hborla/generalize-macro-expansion-expr
[Macros] Generalize `MacroExpansionExpr` and use it for both freestanding and attached macros.
2023-02-01 11:04:39 -08:00