Commit Graph

2572 Commits

Author SHA1 Message Date
Michael Gottesman
56cb980540 Merge pull request #74564 from gottesmm/pr-9be87019f95149167c2e03043b7a86b82f9d282c
Follow up fixes with feedback from #74129
2024-06-25 10:24:26 -07:00
Tim Kientzle
598e5104ef Merge pull request #74184 from tbkka/tbkka-assertions2
Add `#include "swift/Basic/Assertions.h"` to a lot of source files
2024-06-20 12:13:28 -07:00
Michael Gottesman
9b0e0f5010 Follow up fixes with feedback from #74129
Didn't need to modify any tests since this shouldn't have any functional
change. Just a slight cleanup.
2024-06-19 20:04:05 -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
Greg Titus
6266564700 Tuple mismatch with argument locator should be handled by ArgumentMismatch 2024-06-18 21:58:39 -07:00
Tim Kientzle
1098054291 Merge branch 'main' into tbkka-assertions2 2024-06-18 17:52:00 -07:00
Greg Titus
3e7f323276 Merge pull request #74464 from gregomni/issue-46902
[Sema] Fix hole where missing_nullary_call wasn't diagnosed in ternary condition.
2024-06-17 08:49:44 -07:00
Greg Titus
10138d8390 Fix hole where missing_nullary_call wasn't diagnosed in ternary condition. 2024-06-16 22:19:48 -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
Michael Gottesman
f9954181ae Merge pull request #74129 from gottesmm/pr-d17a3faab1ceab8b831d7649c1005be9c49d771c
[region-isolation] Implement function sub typing rules
2024-06-14 12:53:22 -07:00
Michael Gottesman
16d0194d77 [sending] Improve the sending mismatch errors and make them warnings when not in swift 6.
This will ensure that we do not break anyone who has adopted APIs like
CheckedContinuation.resume that now have sending parameters.

An example of where this can come up is shown by the ProcessType in SwiftToolsCore:

```swift
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
@discardableResult
public func waitUntilExit() async throws -> ProcessResult {
    try await withCheckedThrowingContinuation { continuation in
        DispatchQueue.processConcurrent.async {
            self.waitUntilExit(continuation.resume(with:))
        }
    }
}
```

This fails to compile since self.waitUntilExit doesn't expect a function that
takes a sending parameter. We want to give people time to fix such issues.
2024-06-13 22:23:08 -07:00
Michael Gottesman
2ac874e8e3 [sending] Fix a few bugs around closure inference of sending parameters and results.
I found this while writing tests for the earlier part of this work. Since this
is also type checking work, I am just folding this work into that work.
2024-06-12 16:13:05 -07:00
Michael Gottesman
3c166b5d96 [sending] Implement non-protocol function subtyping rules.
rdar://127675288
2024-06-12 16:13:05 -07:00
Tim Kientzle
1d961ba22d Add #include "swift/Basic/Assertions.h" to a lot of source files
Although I don't plan to bring over new assertions wholesale
into the current qualification branch, it's entirely possible
that various minor changes in main will use the new assertions;
having this basic support in the release branch will simplify that.
(This is why I'm adding the includes as a separate pass from
rewriting the individual assertions)
2024-06-05 19:37:30 -07:00
Kavon Farvardin
79075e900d Merge pull request #73927 from kavon/ncgenerics-diagnostics-improved
NCGenerics: improve diagnostics
2024-06-04 21:47:01 -07:00
Kavon Farvardin
c9cfe28e6d NCGenerics: improve diagnostics
Removing the old, ad-hoc diagnostics code improves the diagnostics we
emit, since the existing diagnostics for missing conformances is already
pretty good.

rdar://127369509
2024-06-04 15:06:32 -07:00
Pavel Yaskevich
243cc1641d [CSSimplify] Don't pile up fixes for incorrect optional chaining
If the contextual type propagated into the optional chain mismatches with
the inner type formed from its member references and that inner type
is a result of some fix, let's consider that un-salvageable and avoid
producing additional "ignore contextual type" fixes which only lead
to subpar solutions.
2024-05-28 15:52:53 -07:00
Slava Pestov
33071e2525 Sema: Use getNextDepth()/getMaxDepth() 2024-05-01 12:09:01 -04:00
Anthony Latsis
d18a7fd073 Sema: Require CS to certify conversions associated w/ existential member accesses 2024-04-18 22:54:19 +03:00
Slava Pestov
d8ff9670bf Sema: Use Requirement::getProtocolDecl() 2024-04-16 12:34:55 -04:00
John McCall
b773c49368 Allow @isolated(any) mismatches in witness matching.
I'm not really convinced that this shouldn't be done by introducing a new
kind of constraint rather than hacking in what are essentially conversions
as "bind" constraints, but this is the most direct path for now.

Fixes rdar://125394096
2024-03-28 02:11:34 -04:00
John McCall
a89564b1ae [NFC] Paranoia and grammar 2024-03-28 02:04:32 -04:00
Slava Pestov
614dd51f76 Sema: Remove unnecessary ProtocolDecl::getSuperclass() check
The condition that the conforming type satisfies the superclass bound
of the conformed protocol is already covered by the conformance constraint
itself.
2024-03-21 14:49:05 -04:00
Angela Laar
6d2e87f8c7 Merge pull request #72367 from angela-laar/dot-isolation-member-for-optionals
[Sema] `.isolation` member missing for optional function values
2024-03-19 10:44:08 -07:00
Pavel Yaskevich
56d207ab1a Merge pull request #72277 from xedin/improvements-to-protocol-witness-matching
[Sema/ClangImporter] Improvements to witness matching
2024-03-19 09:36:32 -07:00
Angela Laar
12ff5eeea7 test function isolation expression 2024-03-18 17:04:32 -07:00
Pavel Yaskevich
5890de3823 [CSSimplify] NFC: Rework a comment about why match is imported to allow 2024-03-18 12:10:44 -07:00
Pavel Yaskevich
c06a1a8ee9 [Sema] WitnessMatching: Warn about sendability mismatches associated with ObjC requirements
Since importer ignored `swift_attr` that appeared in a type context
until recently we need to maintain status quo with concurrency stripping
from ObjC requirements in modes that don't have full concurrency
checking enabled.
2024-03-18 10:43:42 -07:00
Pavel Yaskevich
4d501efc0a [Sema] WitnessMatching: Anchor witness on the requirement declaration 2024-03-18 10:43:41 -07:00
Pavel Yaskevich
1fa0179e96 Merge pull request #72353 from xedin/rdar-124549952
[CSSimplify] Mark all type variables in member type as holes if base …
2024-03-18 09:25:28 -07:00
Angela Laar
e37008c215 [Sema] .isolation member missing for optional function values 2024-03-15 16:19:04 -07:00
Pavel Yaskevich
b6ba3fead8 [CSSimplify] Mark all type variables in member type as holes if base is a hole
Even if the member type variable is partially resolved, we still need
to mark inner type variables (if any) as holes because they might not
be connected to anything that could provide contextual type(s).

Resolves: rdar://124549952
2024-03-15 10:11:15 -07:00
Kavon Farvardin
2a51f105b3 more enablement of code 2024-03-14 23:10:44 -07:00
Kavon Farvardin
149c052ec5 use new noncopyable types infrastructure
The infrastructure underpinning the new feature NoncopyableGenerics is
mature enough to be used.
2024-03-14 23:10:44 -07:00
Holly Borla
0a627bc44c Merge pull request #72324 from hborla/extract-function-isolation-expr
[Concurrency] Add a `.isolation` member on dynamically isolated function values.
2024-03-14 06:56:43 -07:00
Holly Borla
d9aa8697ab [Concurrency] Teach the constraint system about .isolation on dynamically
isolated function values.
2024-03-13 22:23:31 -07:00
Pavel Yaskevich
38ca3cc435 Merge pull request #72230 from xedin/skip-marker-protocols-while-casting
[CSSimplify] Allow type inference through marker protocol existential…
2024-03-13 14:12:27 -07:00
Pavel Yaskevich
93fabf05ea Merge pull request #72239 from xedin/infersendablefromcaptures-fixes
[Sema] A few minor fixes for `InferSendableFromCaptures` feature
2024-03-13 14:12:01 -07:00
Erik Eckstein
3c76464c1c rename withConcurrent -> withSendable
That was missed when "concurrent" was renamed to "sendable"
2024-03-13 09:58:31 +01:00
Pavel Yaskevich
4628987972 [CSSimplify] InferSendableFromCaptures: Don't expect Sendable to be always present
Fixes a crash in `test/SILGen/opaque_values_silgen_lib.swift`
2024-03-11 10:41:48 -07:00
Pavel Yaskevich
681d1605af [CSSimplify] Allow type inference through marker protocol existential casts
```swift
class A<T> {
}

class B<U> : A<U> {
}

func test(v: any B<Int> & Sendable) {
  _ = v as A // infers `Int` for `A.T`
}
```
2024-03-11 10:38:46 -07:00
Holly Borla
babf807ccf Merge pull request #71709 from calda/cal--65921
[SE-0286] Fix issue where forward scanning default value heuristic wouldn't be applied in Swift 6 mode
2024-03-09 18:09:33 -08:00
Pavel Yaskevich
279e147ae2 Merge pull request #71701 from li3zhen1/my-branch
[CSDiagnostics] Add diagnostics for holes in generic parameter packs
2024-03-06 11:58:19 -08:00
cui fliter
127077b3aa chore: fix some comments
Signed-off-by: cui fliter <imcusg@gmail.com>
2024-03-05 17:23:22 +08:00
Doug Gregor
6075de1b62 Add upcoming feature ImplicitOpenExistentials for SE-0352
To maintain source compatibility, SE-0352 does not open existentials
with "self-conforming" type, such as `any Error` or existentials based
on `@objc` protocols. The proposal specified that this behavior would
change in Swift 6. Implement that behavior change, which can be
enabled prior to Swift 6 with the upcoming feature
`ImplicitOpenExistentials` (as documented in SE-0362).

Fixes #70873 / rdar://120902975.
2024-03-01 11:50:39 -08:00
li3zhen1
a5e04b5de5 [CSDiagnostics] Add diag for holes in generic pack element 2024-02-22 00:22:43 -05:00
Ben Barham
ef8825bfe6 Migrate llvm::Optional to std::optional
LLVM has removed llvm::Optional, move over to std::optional. Also
clang-format to fix up all the renamed #includes.
2024-02-21 11:20:06 -08:00
Pavel Yaskevich
2eda1cb9a6 [CSSimplify] Adjust isBindable to reject binding if it's directly to a type variable
Although inference doesn't allow direct bindings to
type variables, they can still get through via `matchTypes`
when type is a partially resolved pack expansion that simplifies
down to a type variable.
2024-02-20 13:42:43 -08:00
Cal Stephens
63e9bfc38b [SE-0286] Fix issue where forward scanning default value heuristic wouldn't be applied in Swift 6 mode 2024-02-17 18:53:16 -08:00