Commit Graph

26323 Commits

Author SHA1 Message Date
Pavel Yaskevich
fd9a3c915b Merge pull request #75486 from xedin/fix-unsed-decl-in-generic-spec-diagnostic
[Diagnostics] Add a note to invalid generic function specialization d…
2024-08-01 10:08:43 -07:00
Hamish Knight
79be21f4ae Merge pull request #75528 from hamishknight/foldable-tangent
[Sema] Fold SequenceExpr in pre-checking pre-walk
2024-08-01 01:48:51 +01:00
Pavel Yaskevich
ceeb6ec23f Merge pull request #75526 from gregomni/specialize
[Sema] Improve diagnoses of generic specializations
2024-07-31 16:27:11 -07:00
Holly Borla
dfea802e51 [Concurrency] Delete sendable checking subsumed by region isolation.
Sema's sendable checking is subsumed by the region isolation SIL pass. Now
that region isolation is always enabled under complete concurrency checking,
the code can be deleted from the actor isolation checker. Note that this
removes these diagnostics from targeted concurrency checking. I think it's
better to remove these diagnostics from targeted checking because in many
cases, they're false positive data-race reports that the programmer ultimately
won't have to address. If we want these diagnostics in targeted checking, we
should do it via region isolation.
2024-07-30 22:11:49 -07:00
Greg Titus
d87e049cde Improve diagnoses of generic specializations
Always add constraints, find fixes during simplify.
New separate fix for allow generic function specialization.
Improve parse heuristic for isGenericTypeDisambiguatingToken.
Degrade concrete type specialization fix to warning for macros.
2024-07-30 18:51:34 -07:00
Allan Shortlidge
5819c31a6c Merge pull request #75568 from tshortli/next-isolation-availability
NFC: Update stale references to `next(_:)`
2024-07-30 14:11:19 -07:00
Allan Shortlidge
4224479a43 NFC: Update stale references to next(_:).
In the accepted proposal for SE-0421, `next(_:)` became `next(isolation:)`.
Some of the references to that method in the codebase need to be updated
accordingly.
2024-07-30 09:47:20 -07:00
Ben Barham
e25609c01d [Cleanup] Remove more StringRef::equals
`StringRef::equals` has been removed upstream.
2024-07-29 16:00:26 -07:00
Hamish Knight
7971056e21 [Sema] Fold SequenceExpr in pre-checking pre-walk
Doing it in the post-walk meant we ended up
walking the children twice, which lead to duplicate
diagnostics and incorrect inference of the
level of application for function references. Move
it to the pre-walk, ensuring that we resolve any
operator references before folding.
2024-07-29 00:07:45 +01:00
Hamish Knight
8eaa64d7b8 [Sema] NFC: Minor foldSequence simplification 2024-07-29 00:07:45 +01:00
Hamish Knight
1f91f1201e [Sema] Tweak resolveDeclRefExpr handling
Sink forbidden prefix and `init` recovery into
`resolveDeclRefExpr`, and move diagnosis of `self`
in an `init` accessor into the pre-checking
post-walk such that it applies to any DeclRefExpr.
2024-07-29 00:07:45 +01:00
Hamish Knight
8804d6af00 [Sema] NFC: Move some code 2024-07-29 00:07:45 +01:00
Pavel Yaskevich
0343bb18af Revert "[Sema] Add specialization constraints for func and variable types, then diagnose w/fixes." 2024-07-25 15:43:15 -07:00
Pavel Yaskevich
794ccee2f5 [Diagnostics] Add a note to invalid generic function specialization diagnostic 2024-07-25 12:57:39 -07:00
Konrad `ktoso` Malawski
96c5d836ce [Distributed] Map into context computed property result type for SerReq checking (#75467) 2024-07-25 23:31:08 +09:00
Allan Shortlidge
608f5fce6a Merge pull request #75455 from tshortli/inheritance-availability-exception
Sema: Update inheritance availability checking exception
2024-07-24 20:19:52 -07:00
Greg Titus
47acc09e11 Merge pull request #74909 from gregomni/generic-arg
[Sema] Add specialization constraints for func and variable types, then diagnose w/fixes.
2024-07-24 19:38:11 -07:00
Kavon Farvardin
dfeb52b581 Merge pull request #75449 from kavon/kavon-fixes-2
Consume: warn about no-op consumes to be fixed
2024-07-24 19:04:52 -07:00
Kavon Farvardin
e04b35d709 Consume: warn about no-op consumes to be fixed
As of now, SE-366 is not correctly implemented with respect to concrete,
bitwise-copyable types like `Int`. Writing `consume someInt` doesn't
actually consume the variable binding as it should, meaning code that
should be flagged as having a use-after-consume is being silently
permitted:

```swift
let someInt = 10
let y = consume someInt
print(someInt) // no error!
```

This has been a problem since Swift 5.9. Eventually we plan to fix this
issue, which means code previously doing the above would become an
error. To help people get ready for the fix, start warning people that
these consumes are actually no-ops and suggest removing them until the
intended behavior is actually enforced in the future.

resolves rdar://127081103
2024-07-24 16:05:47 -07:00
Allan Shortlidge
f9ef2db089 Sema: Update inheritance availability checking exception.
The changes from https://github.com/swiftlang/swift/pull/62327 need to be
updated for compatibility with the SDKs accompanying Xcode 16.

Resolves rdar://132438383 and https://github.com/swiftlang/swift/issues/75175.
2024-07-24 15:50:09 -07:00
Greg Titus
6e917b567a Improve diagnoses of generic specializations
Always add constraints, find fixes during simplify.
New separate fix for allow generic function specialization.
Improve parse heuristic for isGenericTypeDisambiguatingToken.
2024-07-24 14:25:11 -07:00
Allan Shortlidge
66e2f972ab Merge pull request #75432 from tshortli/maccatalyst-upstream
Upstream missing macCatalyst support
2024-07-24 09:58:04 -07:00
Joe Groff
044d8c9f56 Merge pull request #75378 from jckarter/warn-on-runtime-function-symbol-references
Stage in a warning when trying to access symbols used by the compiler.
2024-07-24 08:18:57 -07:00
Hamish Knight
b191390130 Merge pull request #75421 from hamishknight/skip
[Sema] Don't parse skipped bodies when computing discriminators
2024-07-24 09:58:44 +01:00
Holly Borla
1527139393 Merge pull request #75425 from hborla/redundant-copyable
[Conformance] Always downgrade redundant conformances to marker protocols to a warning.
2024-07-23 20:55:22 -07:00
Allan Shortlidge
f7ff3f0001 SILGen: Introduce macCatalyst support for @backDeployed.
Upstreams the necessary changes to compile references to `@backDeployed`
declarations correctly when a `macabi` target triple or a `-target-variant` is
specified.
2024-07-23 17:00:10 -07:00
Holly Borla
5eb16ad3de [Conformance] Always downgrade redundant conformances to marker protocols to
a warning.

Previous compiler versions allowed this, so we should stage the change in as
a warning. This was already a warning across modules, so this change only impacts
redundant conformances to marker protocols within a module. This code also isn't
particularly harmful, because marker protocols don't have requirements, so there
isn't the same risk of unexpected behavior as other redundant conformances.
2024-07-23 14:08:14 -07:00
Hamish Knight
37ac51099d [Sema] Don't parse skipped bodies when computing discriminators
The refactoring in #68760 accidentally caused us to
start parsing skipped function bodies if they have
parameters, as the local discriminator request kicks
parsing through `getBody()`. Cherry-pick part of
47ff9568db749def08007b64a5425789cb514ac3 which was
never landed, ensuring we don't call `getBody` for
a skipped function body.

This is meant to be a minimal low-risk change that
fixes the issue in question, restoring the behavior
we had in 5.10. Fixing the parser skipping
behavior for `#sourceLocation` will be done in
a follow-up. We also ought to see if there's a
better way we can enforce that skipped function
bodies don't end up getting parsed, for now I've
added a test.

rdar://131726797
2024-07-23 21:11:25 +01:00
Kavon Farvardin
2557ba96c8 Noncopyable: deprecate '@_moveOnly' attribute
This hidden attribute is a leftover from before the '~Copyable' syntax.

rdar://130526083
2024-07-23 11:05:33 -07:00
Kavon Farvardin
653e224711 Sema: handle ~<<error type>> gracefully 2024-07-23 11:05:33 -07:00
Kavon Farvardin
6e35711bb4 Noncopyable: prevent keypaths from accessing
We don't yet have keypaths working correctly to allow access to
noncopyable fields, so we should raise a friendly error in Sema rather
than an error-out elsewhere vaguely.

resolves rdar://109287447
2024-07-22 21:22:05 -07:00
Kavon Farvardin
998986caca Noncopyable: fix implicit conversion error
Implicit initializers internally have "Default" parameter ownership
specifiers, which can only happen for a noncopyable type if the decl is
synthesized, since ownership is required to be specified if it were
written in the source.

There's no reason to warn for such decls, since the user can't see it
anyway. So specifically target an explicitly written "borrowing" as
being confusing, since that's the only valid case that could happen
anyway.

resolves rdar://131546153
2024-07-22 15:57:34 -07:00
Hamish Knight
95b431e2ac Merge pull request #75391 from hamishknight/quick-cleanup 2024-07-22 09:57:21 +01:00
Hamish Knight
7cb1868419 Merge pull request #75392 from hamishknight/yeet
[Sema] NFC: Remove `findLHS`
2024-07-21 22:43:43 +01:00
Hamish Knight
a00b003a01 [Sema] NFC: Remove findLHS
This is no longer used.
2024-07-21 19:43:48 +01:00
Hamish Knight
22b08da0dd [Sema] Remove replaceInvalidRefsWithErrors param
Doesn't seem like anything is relying on setting
this to `false` anymore, remove it.
2024-07-21 15:27:15 +01:00
Holly Borla
ee2dd82d56 Merge pull request #75235 from rofle100lvl/change_note_main_actor_variables
Change note for non marked with main actor global variables
2024-07-20 11:43:29 -07:00
Горбенко Роман
2c1e45a598 Changed note main actor variables 2024-07-20 02:39:33 +02:00
Joe Groff
8bc5a1f1fc Stage in a warning when trying to access symbols used by the compiler.
Attempting to bypass the compiler and access runtime functions directly has
a long history of breaking in hard-to-predict ways, and there's usually a better
way. Put up a warning to try to flush out misuses of runtime functions to see
if we can turn this into an error.
2024-07-19 16:55:11 -07:00
Holly Borla
22db5634ef Merge pull request #75359 from hborla/unavailable-sendable-restated
[Concurrency] Don't warn about re-stating inherited unavailable conformances to `Sendable`.
2024-07-19 12:32:07 -07:00
Joe Groff
9f2ee07de8 Merge pull request #75334 from jckarter/extern-is-experimental
`@_extern` is an experimental feature.
2024-07-19 09:04:14 -07:00
Konrad `ktoso` Malawski
be1a69b1d7 [Distributed] Simplify AsLocalActor detecting a bit in isolation checker (#75361) 2024-07-19 00:34:21 -07:00
Holly Borla
69b2435bab [Concurrency] Don't warn about re-stating inherited unavailable conformances
to `Sendable`.

The unavailability check was not using the root conformance, which is where
the extension declaration with the unavailability attribute is for inherited
conformances, leading to bogus warnings about re-stating unchecked conformances
to `Sendable`.
2024-07-18 20:44:28 -07:00
Ben Barham
9a886c6a5c Merge pull request #75346 from bnbarham/more-startswith-rename
[Cleanup] Rename more `startswith` to `starts_with`
2024-07-18 19:06:22 -07:00
Konrad `ktoso` Malawski
e53cd7d079 [Distributed] Handle #isolation param in DA as known to not cross isolation (#75327)
The isolation checker was assuming that one can only be isolated to a
specific var, but that's not true for distributed actors -- because the
default parameter emitted by #isolation is a method call -- converting
the self into an any Actor.

We must handle this in isolation checker in order to avoid thinking
we're crossing isolation boundaries and making methods implicitly async
etc, when we're actually not.

resolves rdar://131874709
2024-07-19 09:47:24 +09:00
Doug Gregor
1baccc2ac5 Merge pull request #75347 from DougGregor/isolation-in-unsafe-inherit-downgrade-old-concurrency-lib
Downgrade the error about `#isolation` in `@_unsafeInheritExecutor` when the concurrency library is old
2024-07-18 16:06:31 -07:00
Holly Borla
37bca4dd75 Merge pull request #75331 from hborla/missing-return
[Attr] Add a missing return statement at the end of `allowSymbolLinkageMarkers`
2024-07-18 13:16:29 -07:00
Joe Groff
51829c17bf @_extern is an experimental feature.
Mark it as such. rdar://132013078
2024-07-18 11:46:16 -07:00
Doug Gregor
d4ba753aab Downgrade the error about #isolation in @_unsafeInheritExecutor when the concurrency library is old
The introduction of the error concerning use of `#isolation` within an
`@_unsafeInheritExecutor` function was carefully staged between the
concurrency library and compiler to avoid breaking source
compatibility. However, it is a source compatibility break when
dealing certain revisions of the concurrency library that adopted
`#isolation` prior to the compiler error. Detect when the _Concurrency
library doesn't have the necessary workarounds in it and downgrade the
error to a warning.

Fixes rdar://132023573.
2024-07-18 11:36:43 -07:00
Ben Barham
010e75399b [Cleanup] Rename more startswith to starts_with
`startswith` is removed upstream, use `starts_with` instead.
2024-07-18 09:49:49 -07:00