Commit Graph

25318 Commits

Author SHA1 Message Date
nate-chandler
5e92df0014 Merge pull request #71470 from nate-chandler/bitwise-copyable/same-file
[BitwiseCopyable] Require conformance in same module as declaration.
2024-02-08 16:19:56 -08:00
nate-chandler
f9e6478b3d Merge pull request #71468 from nate-chandler/nfc/20240208/1/bitwise-copyable-known-protocol-kind
[NFC] BitwiseCopyable: Use getKnownProtocolKind.
2024-02-08 13:34:00 -08:00
nate-chandler
1259eeec43 Merge pull request #71462 from nate-chandler/bitwise-copyable/indirect-enums
[BitwiseCopyable] Ban indirect enums and cases.
2024-02-08 11:28:53 -08:00
Nate Chandler
ce6c25977b [BitwiseCopyable] Req conformance in decl module.
Don't allow conformances to `BitwiseCopyable` to be declared in other
modules.
2024-02-08 10:51:13 -08:00
Pavel Yaskevich
95beb6cdd9 Merge pull request #71444 from xedin/remote-duplicate-entry-in-solution-total-memory
[ConstraintSystem] NFC: Remove duplicate entry from `Solution::getTot…
2024-02-08 09:30:16 -08:00
Nate Chandler
c73ecd028a [NFC] BitwiseCopyable: Use getKnownProtocolKind.
Rather than getting ahold of the BitwiseCopyable protocol and doing a
pointer comparison to another ProtocolDecl, check whether the latter's
known protocol kind is ::BitwiseCopyable.
2024-02-08 07:59:40 -08:00
Nate Chandler
0bc38128d8 [BitwiseCopyable] Ban indirect enums and cases.
Enums which are entirely indirect or which have indirect cases are never
trivial and hence cannot conform to BitwiseCopyable.
2024-02-08 06:47:32 -08:00
Nate Chandler
d192a8330d [BitwiseCopyable] Remove existential conformance.
It makes sense to form an existential of a type that conforms to
`BitwiseCopyable` but such an existential is not itself trivial and
consequently not `BitwiseCopyable`.
2024-02-08 06:46:47 -08:00
nate-chandler
a679bbcc7a Merge pull request #71456 from nate-chandler/bitwise-copyable/implicit-nonescaping-noncopyable
[BitwiseCopyable] Don't diagnose implicit checks.
2024-02-08 06:45:40 -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
Holly Borla
40ff560f66 Merge pull request #71463 from hborla/downgrade-witness-isolation-error
[Concurrency] Downgrade errors about actor-isolated witnesses to warnings until Swift 6 when the witness is a non-Sendable `let`.
2024-02-07 22:38:05 -08:00
Holly Borla
e32fd8a322 [Concurrency] Downgrade errors about actor-isolated witnesses to warnings until
Swift 6 when the witness is a non-Sendable 'let'.
2024-02-07 19:37:30 -08: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
Nate Chandler
81ae7463dd [BitwiseCopyable] Don't diagnose implicit checks.
Previously, the diagnostics for conforming a non-escaping or
non-copyable type to `_BitwiseCopyable` were emitted even in the case of
an implicit check for conformance.  Here this is fixed to suppress the
diagnostics in the case of an implicit check as is done for other
diagnostics.
2024-02-07 16:34:50 -08:00
Kavon Farvardin
3dda59fea7 Sema: improve function cast checking
Functions can in fact conform to some protocols, notably,
marker protocols. Dynamically they have no influence on whether the cast
will succeed or not, as there is no way to tell if a type conforms to
such a protocol at runtime. But we should check them statically because
they otherwise can be cast to Any eventually.
2024-02-07 14:54:37 -08:00
Kavon Farvardin
3ab4c7548c Sema: ban extensions of known marker protocols
There's no good reason to permit them. Conformances like Copyable and
Sendable are pervasive, so it's as though we are permitting extensions
of `Any`. Until there's a good argument in favor of such extensions,
remove the capability now.
2024-02-07 14:54:36 -08:00
Pavel Yaskevich
b761e4f320 [ConstraintSystem] NFC: Remove duplicate entry from Solution::getTotalMemory 2024-02-07 12:33:07 -08:00
John McCall
60807a76a4 Merge pull request #71433 from rjmccall/isolated-any-typechecking
Experimental type-checking support for `@isolated(any)` function types.
2024-02-07 14:07:53 -05:00
Kavon Farvardin
056493b079 NCGenerics: fix !hasTypeVariable() assert 2024-02-07 11:05:08 -08:00
Hamish Knight
7b4c9fef02 Allow implicit last expressions for functions and closures
Gated behind the experimental feature
`ImplicitLastExprResults`.
2024-02-07 18:14:23 +00:00
Hamish Knight
33cdd33f9e [CS] Account for implicit returns in closures
Avoid defaulting to Void if we have an implicit
return from which we can infer the result type.
2024-02-07 18:14:23 +00: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
Hamish Knight
d73e394ea7 Allow implicit last expression results for if/switch expressions
Allow implicitly treating the last expression of
the branch as the result, behind the experimental
feature `ImplicitLastExprResults`.
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
Doug Gregor
3a5ee89b4d Merge pull request #71426 from DougGregor/lift-retroactive-objc-bridgeable-conformance
Remove an old restriction on `_ObjectiveCBridgeable` conformances.
2024-02-06 19:36:26 -08:00
Doug Gregor
0b01b55e73 Remove an old restriction on _ObjectiveCBridgeable conformances.
Historically, we checked against a specific allowlist for a certain set
of types that were allowed to introduce an `_ObjectiveCBridgeable`
conformance in a different module that where the type was defined.
This rigid allow-list isn't really buying us much, but it's getting in
the way of some refactoring for swift-foundation that's changing
the layering. Remove this diagnostic, since it really isn't buying us
much nowadays, and we have the more general warnings about retroactive
conformances to make folks think twice.
2024-02-06 16:09:17 -08:00
Alejandro Alonso
7c95bdb0c0 Diagnose static exclusive only in clients without the feature flag 2024-02-06 13:51:10 -08:00
Kavon Farvardin
906d261a19 Merge pull request #71395 from kavon/ncgenerics-test-fixes-kavon-v2
NCGenerics: more test fixes (v2)
2024-02-06 11:14:39 -08:00
Pavel Yaskevich
4cd167c918 Merge pull request #71393 from xedin/filter-out-escapable-from-leading-dot-in-generic-context
[CSBindings] Don't allow leading-dot base inference from Escapable pr…
2024-02-06 09:27:52 -08:00
Kavon Farvardin
70266b589a NCGenerics: avoid UGT's in queries
An unbound generic type is not something that should end up in
`isNoncopyable` or `isEscapable` queries because there are no
conformances for such a type; it's unbound!

fixes test/Constraints/closures.swift
2024-02-06 08:15:26 -08:00
Kavon Farvardin
c67645f850 NCGenerics: handle @_moveOnly correctly
We let TypeCheckAttr diagnose illega uses of the attribute. In addition,
we need to exclude protocols from inferring a marking, because when we
build the StructuralRequirements for a protocol, we ignore the
"marking" this we'll miss this legacy attribute.

fixes Sema/moveonly_decl_attr.swift
2024-02-06 08:15:26 -08:00
nate-chandler
f98b211f18 Merge pull request #71403 from nate-chandler/delete-flag
[Frontend] Removed enable-lexical-borrow-scopes flag.
2024-02-06 07:00:25 -08: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
Konrad `ktoso` Malawski
5acd366c98 [macros] allow forwarding generic arguments through macro declarations (#71271)
* [macros] allow forwarding generic arguments through macro declarations

[macros] add more tests for generic argument forwarding in macro declarations

* [macros] correct replacement picking logic
2024-02-06 03:56:20 -08:00
Hamish Knight
7b012d825c Merge pull request #70600 from hamishknight/postal-service
[ASTWalker] Continue post-walking with `Action::SkipChildren`
2024-02-06 10:24:38 +00:00
Nate Chandler
ddccaa7d9c [Frontend] Removed lexical-borrow-scope flag.
Adding `move_value [lexical]` and `begin_borrow [lexical]` should happen
all the time at this point.  Remove the ability to omit these
instructions and update the corresponding tests.
2024-02-05 17:34:10 -08:00
Slava Pestov
9f0bf00c3f Sema: Two small fixes for noncopyable generics SIL tests 2024-02-05 18:43:06 -05:00
Slava Pestov
af50d7e6b8 AST: Add allowInverses flag to AbstractGenericSignatureRequest 2024-02-05 18:43:06 -05:00
Slava Pestov
4e84d28670 SIL: Build substitution signature without expanding defaults or applying inverses 2024-02-05 18:43:06 -05:00
Slava Pestov
d9c82b1b04 Sema: Clean up printing of generic signatures in missing witness diagnostics
Instead of stripping out requirements, let's pass the right PrintOptions.
2024-02-05 17:13:02 -05:00
Pavel Yaskevich
a613015b33 [CSBindings] Don't allow leading-dot base inference from Escapable protocol
Similarly to `Copyable`, `Escapable` shouldn't have any members
declared and as a result shouldn't be considered for leading-dot
base type inference.
2024-02-05 10:15:19 -08:00
Pavel Yaskevich
55af87f8e0 Merge pull request #71372 from apple/function-keypath-follow-ups
Follow ups for keypath function conversion PR
2024-02-05 09:47:45 -08:00
Andrew Trick
e738b8a77e Merge pull request #71353 from meg-gupta/initlifetimedep
Support for lifetime dependence specifiers on initializers
2024-02-05 08:55:54 -08: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
Slava Pestov
d981cf3b77 Sema: De-requestify TypeBase::isNoncopyable() and TypeBase::isEscapable()
And consolidate the logic in ConformanceLookup.cpp.
2024-02-05 11:25:57 -05:00
Holly Borla
93b68cd9df Merge pull request #71365 from hborla/lazy-trc-extension 2024-02-05 08:06:45 -08:00
Hamish Knight
15fa06dd37 [ASTWalker] Cleanup some cases manually doing post-walks
We can replace these with `Action::SkipChildren`.
2024-02-05 15:27:26 +00:00
Hamish Knight
05615fa0e4 NFC: Rename TypeWalker's SkipChildren to SkipNode
For consistency with ASTWalker.
2024-02-05 15:27:25 +00:00
Hamish Knight
16cfca4186 [ASTWalker] NFC: Rename SkipChildren -> SkipNode
This better describes what the action currently
does, and allows us to re-introduce `SkipChildren`
with the correct behavior.
2024-02-05 15:27:25 +00:00