Commit Graph

2744 Commits

Author SHA1 Message Date
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
Kavon Farvardin
08b71e0136 NCGenerics: rebuild stdlib from its interface
When a NoncopyableGenericsMismatch happens between the compiler and
stdlib, allow the compiler to rebuild the stdlib from its interface
instead of exiting with an error.
2024-02-15 18:08:54 -08:00
Pavel Yaskevich
b691f41c05 Merge pull request #71571 from xedin/copyable-fixes-for-variadics
[AST] Handle pack element types in `LookupConformanceInModuleRequest`
2024-02-13 09:52:29 -08:00
Pavel Yaskevich
bb26b66390 [CSSimplify] Don't attempt to destructure tuples to check for Copyable when non-copyable generics feature is enabled 2024-02-12 16:48:28 -08:00
Pavel Yaskevich
6c7000ae0b [Sema/IRGen] Extend ad-hoc requirement handling to DistributedTargetInvocationResultHandler.onReturn 2024-02-12 14:26:30 -08:00
Pavel Yaskevich
4d45701046 [Sema/IRGen] Extend ad-hoc requirement handling to DistributedTargetInvocationDecoder.decodeNextArgument 2024-02-12 14:26:30 -08:00
Pavel Yaskevich
4f32111bf8 [Sema/IRGen] Extend ad-hoc requirement handling to DistributedTargetInvocationEncoder.record{Argument, ReturnType} 2024-02-12 14:26:30 -08:00
Pavel Yaskevich
0db22316a2 [ConstraintSystem] Record conformances synthesized for ad-hoc distributed requirements 2024-02-12 14:26:30 -08:00
Pavel Yaskevich
171fb0ae0d [CSSimplify] Synthesize conformances for ad-hoc distributed witness requirements
Instead of handing failures in `matchWitness` let's syntehsize
conformances during solving. Next step would be to record them
and use in `Solution::computeSubstitutions`.
2024-02-12 14:26:30 -08:00
Slava Pestov
6027bf46a6 AST: Simplify collectExistentialConformances() 2024-02-10 09:36:37 -05:00
Kavon Farvardin
74a3839cf3 Merge pull request #71515 from kavon/ncgenerics-test-fixes-kavon-v7
Ncgenerics test fixes kavon v7
2024-02-09 19:39:18 -08:00
Slava Pestov
06b1aee360 Evaluator: Cache circular evaluation to avoid redundant diagnostics
Previously, if a request R evaluated itself N times, we would emit N
"circular reference" diagnostics. These add no value, so instead let's
cache the user-provided default value on the first circular evaluation.

This changes things slightly so that instead of returning an
llvm::Expected<Request::OutputType>, various evaluator methods take
a callback which can produce the default value.

The existing evaluateOrDefault() interface is unchanged, and a new
evaluateOrFatal() entry point replaces
llvm::cantFail(ctx.evaluator(...)).

Direct callers of the evaluator's operator() were updated to pass in
the callback. The benefit of the callback over evaluateOrDefault() is
that if the default value is expensive to constuct, like a dummy
generic signature, we will only construct it in the case where a
cycle actually happened, otherwise we just delete the callback.

(cherry picked from commit b8fcf1c709efa6cd28e1217bd0efe876f7c0d2b7)
2024-02-09 16:02:24 -08:00
Kavon Farvardin
7bf570d579 NCGenerics: conformance to Any does not always hold
`Any` now implies the requirements `Copyable & Escapable`. Check it like
 any ordinary existential.
2024-02-09 15:46:43 -08:00
Doug Gregor
a4f0709c2f Rename AsyncIteratorProtocol.next(_:) to next(isolation:)
Match the name of the method as specified in SE-0421
2024-02-09 14:18:37 -08:00
Kavon Farvardin
d768c75134 NCGenerics: narrow use of custom diagnostics
In some cases we get a `ConstraintKind::SelfObjectOfProtocol` here.
That's typically for an existential cast. In such a case, we actually
get a better standard diagnostic than what MustBeCopyable can produce
currently. So this change narrows things to what MustBeCopyable is
better at diagnosing.
2024-02-09 12:35:15 -08:00
Hamish Knight
2c77947000 Merge pull request #71006 from hamishknight/implicit-last-expression
Introduce implicit last expression results
2024-02-08 10:15:01 +00:00
Kavon Farvardin
aaf2f7e565 Merge pull request #71438 from kavon/ncgenerics-test-fixes-kavon-v4
Ncgenerics test fixes kavon v4
2024-02-07 19:28:11 -08:00
Kavon Farvardin
056493b079 NCGenerics: fix !hasTypeVariable() assert 2024-02-07 11:05:08 -08:00
Hamish Knight
1003b2f30b [CS] Remove CTP_ImpliedReturnStmt
Unify with `CTP_ReturnStmt`, and have the
SyntacticElementTarget carry the ReturnStmt for
regular type-checking, which we can use to record
implied returns.
2024-02-07 18:14:23 +00:00
Hamish Knight
61a4148925 [CS] Generalize implied result handling
Track the implied result exprs in the constraint
system, and allow arbitrary propagation of
implied results down if/switch expression
branches. This is required for allowing implied
results in non-single-expression closures.
2024-02-07 18:14:22 +00:00
John McCall
2f8a33cf0a Experimental type-checking support for @isolated(any) function types. 2024-02-06 22:54:27 -05:00
Slava Pestov
d46bd335de Merge pull request #71371 from slavapestov/ncgenerics-fixes-3
Non-copyable generics fixes, part 3
2024-02-06 08:35:07 -05:00
Slava Pestov
a68c806290 Sema: Skip a legacy check when built with SWIFT_ENABLE_EXPERIMENTAL_NONCOPYABLE_GENERICS 2024-02-05 11:25:57 -05:00
Freddy Kellison-Linn
aedf854e33 Follow ups for keypath function conversion PR 2024-02-03 13:41:22 -05:00
Frederick Kellison-Linn
0735629c8d Merge pull request #39612 from Jumhyn/keypath-function-conversion
[ConstraintSystem] Allow function-function conversions for keypath literals
2024-02-03 10:26:13 -08:00
Hamish Knight
27c08b130a Merge pull request #71123 from hamishknight/sema-expr-return
Move the single-expr return transform from Parse to Sema
2024-01-31 10:13:24 +00:00
Doug Gregor
29cfe61472 Merge pull request #71253 from DougGregor/hash-table-iteration-considered-harmful
Fix nondeterminism in explicitly-specified generic macro arguments
2024-01-30 15:21:40 -08:00
Doug Gregor
7712903f6b Fix nondeterminism in explicitly-specified generic macro arguments
A hash table got flattened into an array without any ordering guarantees,
and then we assumed it was in order. Fixes rdar://121397992.
2024-01-30 12:40:23 -08:00
Hamish Knight
9b64990d24 [AST] Remove the "single expression body" bit
Remove this bit from function decls and closures.
Instead, for closures, infer it from the presence
of a single return or single expression AST node
in the body, which ought to be equivalent, and
automatically takes result builders into
consideration. We can also completely drop this
query from AbstractFunctionDecl, replacing it
instead with a bit on ReturnStmt.
2024-01-30 14:08:54 +00:00