Commit Graph

2224 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
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
d40663dd66 [Concurrency] Flip the implicitly async select in a concurrency error.
This diagnostic was presenting "implicitly async" for explicitly async calls,
and vice versa, because the `select` was incorrect.
2024-07-31 06:46:07 -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
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
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
ab75611caa Test: update tests with no-op consumes 2024-07-24 16:06:19 -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
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
Kavon Farvardin
5230b19ef6 Test: replace '@_moveOnly' with '~Copyable' 2024-07-23 11:05:33 -07: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
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
Allan Shortlidge
ecc1a2de2c Tests: Drop maccatalyst_support requirement for several tests.
As much as possible, we should avoid using `REQUIRES: maccatalyst_support`
since tests restricted this way are not run in PR tests. Many tests that
exercise macCatalyst behaviors can be run in a macOS configuration, without
full macCatalyst standard library support.

Also, adopt `%target-cpu` lit substitution where appropriate to avoid needless
standard library module rebuilds when running tests locally.
2024-07-19 17:02:28 -07:00
Allan Shortlidge
a8a1eb2666 Merge pull request #75182 from tshortli/warn-soft-deprecated
Introduce `-warn-soft-deprecated` option
2024-07-11 21:06:30 -07:00
Allan Shortlidge
1d715e2474 Sema: Diagnose references to soft-deprecated declarations.
When `-warn-soft-deprecated` is specified, diagnose references to declarations
that are deprecated in future OS versions.

Resolves rdar://130424183.
2024-07-11 14:04:38 -07:00
Ellie Shin
cb776089cb Merge pull request #75154 from swiftlang/elsh/drop-exp-prefix
Drop experimental prefixes from PackageCMO flags.
2024-07-11 12:12:29 -07:00
Andrew Trick
12acde2215 Merge pull request #75096 from meg-gupta/lifetimedeparg
Add support for lifetime dependence in parameter position
2024-07-10 22:56:23 -07:00
Ellie Shin
f405ad4b95 Update tests 2024-07-10 19:20:45 -07:00
Kavon Farvardin
bbc02a5544 Merge pull request #75141 from kavon/invertible-conformance-same-sourcefile
NCGenerics: enforce same-source conformance rule
2024-07-10 17:50:13 -07:00
Meghana Gupta
7499cf3fbb Update lifetime dependence tests 2024-07-10 14:48:30 -07:00
Kavon Farvardin
233742a565 NCGenerics: enforce same-source conformance rule
SE-427 says the conformance to Copyable must appear in the same source
file as the nominal type.

resolves rdar://131486561
2024-07-10 14:02:10 -07:00
Meghana Gupta
13cfbca720 Add unit test for lifetime dependence related to function types 2024-07-09 09:13:57 -07:00
Hamish Knight
4beaaf32ad [CS] Improve placeholder diagnostics slightly
Make sure `CouldNotInferPlaceholderType` can
produce a diagnostic for a `PlaceholderType`
locator element, and avoid emitting an extra
diagnostic for a placeholder type in an invalid
position.
2024-07-07 23:42:33 +01:00
Harlan Haskins
c2a87aa3a0 Relax @retroactive check to allow same-package declarations (#73512)
* Relax @retroactive check to allow same-package declarations

* Add package decls to the test too

* Fix tests

* Import test libraries publicly so I can use their conformances in public retroactive extensions
2024-07-02 21:09:24 -06:00
Michael Gottesman
34195ff213 Merge pull request #74610 from gottesmm/pr-324fd70c13e87a329334341aae4667f2d1be152c
[sending] Remove transferring.
2024-07-02 14:02:18 -07:00
Allan Shortlidge
0dbbb68171 Sema: Fix accessor availability checking in argument lists.
The changes in https://github.com/apple/swift/pull/72410 caused a regression
when checking availability in the following example:

```
// warning: Setter for 'hasDeprecatedSetter' is deprecated: ...
x[y.hasDeprecatedSetter] = ...
```

The result of `y.hasDeprecatedSetter` is being passed as an argument to the
subscript and its setter will not be called. To fix this,
`ExprAvailabilityWalker` now consistently creates a new default
`MemberAccessContext` when descending into any `Argument`, since the access
context for the expressions surrounding the call should not affect the
arguments to the call.

Additionally, `MemberAccessContext` has been refactored to better model context
state transitions. Instead of only modeling which accessors will be called, the
enumeration's members now reflect the possible states that
`ExprAvailabilityWalker` can be in during its traversal. This should hopefully
make it easier to follow the logic for traversal of `LoadExpr`s and arguments.

Resolves rdar://130487998.
2024-06-27 11:13:52 -07:00
Allan Shortlidge
0673e99839 Tests: Add tests exercising subscripts to availability_accessors.swift.
Some of the test cases demonstrate the issue reported in rdar://130487998.
2024-06-27 11:13:52 -07:00
Allan Shortlidge
2953a26b28 Tests: Add tests exercising subscripts to availability_accessors.swift.
Some of the test cases demonstrate the issue reported in rdar://130487998.
2024-06-27 11:13:52 -07:00
Allan Shortlidge
31df22f5ec Sema: A LoadExpr enclosing a call does not affect the arguments.
Fixes missing setter availability diagnostics in some edge cases.
2024-06-25 11:08:20 -07:00
Allan Shortlidge
89e31cd818 Tests: Expand test coverage of inout parameters availability_accessors.swift. 2024-06-25 10:55:29 -07:00
Allan Shortlidge
46e7f7f014 Tests: Consolidate takesInOut() helper in availability_accessors.swift.
NFC.
2024-06-25 09:20:52 -07:00
Allan Shortlidge
6e16075692 Sema: Suppress set accessor availability diagnostics in LoadExprs.
This fixes a regression from https://github.com/swiftlang/swift/pull/72369.
The compiler now incorrectly diagnoses use of an unavailable setter in this
example:

```
func increaseBrightness(in window: UIWindow) {
  // warning: setter for 'screen' was deprecated in iOS 13.0
  window.screen.brightness = 1.0
}
```

While the setter is deprecated, it would not be called in the generated code
since `screen` is a reference type and there is no writeback through the setter
for `screen` after setting `brightness`.

Resolves rdar://129679658
2024-06-25 09:20:34 -07:00
Allan Shortlidge
e055b383d2 Tests: Add test cases to availability_accessors.swift using classes.
Many of the new FIXMEs demonstrate the regression reported in rdar://129679658.
2024-06-25 09:17:04 -07:00
Allan Shortlidge
f0ff799251 Tests: Refactor availability_accessors.swift. 2024-06-25 09:17:04 -07:00
Michael Gottesman
112071e57d [sending] Remove transferring.
Out of an abundance of caution, we:

1. Left in parsing support for transferring but internally made it rely on the
internals of sending.

2. Added a warning to tell people that transferring was going to
be removed very soon.

Now that we have given people some time, remove support for parsing
transferring.

rdar://130253724
2024-06-21 16:03:21 -07:00
Holly Borla
9facbd466b Merge pull request #74567 from hborla/remove-disable-region-isolation
[Concurrency] Remove `-disable-region-based-isolation-with-strict-concurrency`.
2024-06-20 10:34:33 -07:00
Holly Borla
1a07152ee0 [NFC][Concurrency] Remove -disable-region-based-isolation-with-strict-concurrency
from tests.
2024-06-19 20:48:59 -07:00
Pavel Yaskevich
adaaf5a522 Merge pull request #74542 from gregomni/issue-74463
[Sema] Tuple mismatch with argument locator should be handled by ArgumentMismatch
2024-06-19 14:39:14 -07:00
Holly Borla
4bec599931 Merge pull request #74543 from hborla/promote-isolated-any
[Features] Promote `IsolatedAny` and its alias to a language feature.
2024-06-19 10:32:30 -07:00
Greg Titus
a3ab8bbe70 Merge pull request #74540 from gregomni/issue-46000
[Sema] Remove external dependencies and move test from validation_test to test.
2024-06-18 22:29:50 -07:00
Holly Borla
966269d31a [Features] Promote IsolatedAny and its alias to a language feature.
The proposal is accepted and implemented for Swift 6.0.
2024-06-18 22:09:16 -07:00
Greg Titus
6266564700 Tuple mismatch with argument locator should be handled by ArgumentMismatch 2024-06-18 21:58:39 -07:00
Greg Titus
18392fd576 Remove external dependencies and move from validation_test to test. 2024-06-18 19:01:08 -07:00
Greg Titus
fb2d667e45 Merge pull request #74243 from gregomni/rvalue-ambiguous
[Sema] Score non-settable overload choices higher in RValueToLValue fix
2024-06-15 15:35:39 -07:00
Greg Titus
843ce585a3 Set fix impact for non-settable overload choices higher, so we get diagnoses from better choices. 2024-06-15 11:43:21 -07:00
Alexis Laferrière
4dc060303e Merge pull request #74142 from xymus/access-level-conformances
Sema: Report public conformances to non-publicly imported protocols
2024-06-13 19:34:37 -07:00
Alexis Laferrière
e5bc35b484 Tests: Temporarly disable checks from reverted exportability checking 2024-06-13 15:20:18 -07:00
Alexis Laferrière
915b1e3def Sema: Update more tests with more precise message about exported conformances 2024-06-13 15:20:18 -07:00