Commit Graph

38524 Commits

Author SHA1 Message Date
Hamish Knight
63cc9260c1 Merge pull request #67563 from hamishknight/complete
[CodeComplete] Properly handle `if`/`switch` expressions
2023-08-02 09:56:46 +01:00
Konrad `ktoso` Malawski
95920b2570 [Concurrency] Fix init task group with flags availability
resolves rdar://112469076
2023-08-02 12:02:27 +09:00
Joe Groff
aa397c763e Merge pull request #67657 from jckarter/sil-type-consolidate-move-only-predicate
Remove redundant SILType::isMoveOnlyNominalType (NFC)
2023-08-01 17:33:34 -07:00
Alex Hoppen
ef8e4ac0f3 [AST] Remove gyb_syntax_support
We are no longer using these Python files to generate anything in SwiftSyntax. We can just remove them and instead commit the generated `.def` files.
2023-08-01 17:20:14 -07:00
Pavel Yaskevich
bb135181bd Merge pull request #67625 from xedin/enable-init-accessors-feature
[Frontend/NFC] SE-0400: Enable `InitAccessors` feature by default
2023-08-01 15:54:43 -07:00
Kuba (Brecka) Mracek
8510bdd7f0 Merge pull request #67587 from kubamracek/move-target-const-folding-to-swift-simplification
Move target const folding to swift simplification
2023-08-01 15:19:26 -07:00
Alejandro Alonso
df17f7be90 Implement dependent layouts for raw types
Update raw_layout.swift

Allow for concrete specializations of raw layout

Make test platform agnostic
2023-08-01 14:09:23 -07:00
Joe Groff
03eec7da2b Remove redundant SILType::isMoveOnlyNominalType (NFC)
and implement `SILType::isPureMoveOnly` in terms of `Type::isPureMoveOnly`.
2023-08-01 14:07:38 -07:00
Amritpan Kaur
1384ff0038 [CSBinding] Allow inference to bind AnyKeyPath as a KeyPath
that can be converted to AnyKeyPath later.
2023-08-01 09:15:04 -07:00
Hamish Knight
1dd86fccdb [CodeComplete] More efficient skipping for completions in if/switch exprs
Skip type-checking multi-statement branches if the
completion is in a single-expression branch, and
skip type-checking the expression as a whole if
the completion is in a multi-statement branch.
2023-08-01 15:21:29 +01:00
Hamish Knight
bf3c807c27 [Sema] Introduce PreCheckFunctionBodyRequest
Split out the part of TypeCheckFunctionBodyRequest
that inserts and removes implicit returns.
2023-08-01 15:21:29 +01:00
Ikko Eltociear Ashimine
a4ab34475a [SILOptimizer] Fix typo in KeyPathProjector.h
addres -> address
2023-08-01 16:40:07 +09:00
Holly Borla
fb2f9bfb7a Merge pull request #67627 from hborla/extension-macro-swiftinterface
[Macros] Add back the `ExtensionMacro` feature identifier as a `LANGUAGE_FEATURE` for use in swiftinterfaces.
2023-07-31 17:07:09 -07:00
Kuba Mracek
66a3a56e11 Use ->getCanonicalType in BridgedTypeArray::getAt to avoid assertion failures 2023-07-31 16:32:42 -07:00
Amritpan Kaur
df17f19979 [ConstraintSystem] Set up key path root lookups. 2023-07-31 16:09:08 -07:00
Holly Borla
4b09d4c513 [Macros] Add back the ExtensionMacro feature identifier as a language feature
that can be used in swiftinterfaces.
2023-07-31 13:39:13 -07:00
Pavel Yaskevich
2a0651e8b0 [Frontend/NFC] SE-0400: Enable InitAccessors feature by default 2023-07-31 13:18:59 -07:00
Kuba Mracek
ae6129cf69 Cache the IRGenModule even between SIL passes 2023-07-31 11:57:28 -07:00
Kuba Mracek
5dac59ce71 Move TargetConstantFolding pass to the simplification passes in Swift, enable using MemoryLayout's .size, .stride, .alignment fields in forced-const global initializers 2023-07-31 10:54:07 -07:00
Pavel Yaskevich
a22bd2741e Merge pull request #67593 from xedin/textual-sil-assign_or_init
[SIL] InitAccessors: Support `assign_or_init` in textual SIL
2023-07-31 09:11:44 -07:00
Joe Groff
16c59fa12c Merge pull request #67588 from jckarter/raw-layout-multi-file
Requestify raw layout "like" type resolution.
2023-07-31 08:38:49 -07:00
Paolo Tranquilli
e13a85c8f1 NFC: make headers compatible with C++20
In a downstream project we are using the Swift code as a library and
compiling with C++20. This mostly works except for two backward
incompatibilities introduced by C++20:

* [P1008] disallows aggregate initialization when defaulted or deleted
  constructors are specified. This lead to a compilation error for
  aggregate initialization of `swift::Compilation::Result`. The backward
  and forward compatible fix for that is to provide a constructor
  turning aggregate initializations into a normal constructor call.
* [P1185] introduces more candidates for overload resolution of
  comparison operator calls. As explained in [P1630], this leads in some
  cases to ambiguity compilation errors in C++20, which is exactly the
  case with `swift::ValueOwnershipKind`. The fix in this case is to
  remove some redundant operator calls conditionally on the
  `__cpp_impl_three_way_comparison` feature test macro, which [includes
  the papers mentioned above][feature_test].

[P1008]: https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p1008r1.pdf
[P1185]: https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1185r2.html
[P1630]: https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1630r1.html
[feature_test]: https://en.cppreference.com/w/cpp/feature_test
2023-07-31 17:34:05 +02:00
Joe Groff
56f2ae6b08 Requestify raw layout "like" type resolution.
This ensures it's resolved on demand even across files. rdar://112998213
2023-07-28 13:46:50 -07:00
nate-chandler
5116600284 Merge pull request #67583 from nate-chandler/checked_cast_br/formal-source
[SIL] Add source formal type to checked_cast_br.
2023-07-28 10:54:06 -07:00
Joshua Turcotti
2eade1d1b5 Merge pull request #67511 from JTurcotti/tweaks
[SendNonSendable] Assorted Bugfixes and Tweaks
2023-07-28 09:24:36 -07:00
Pavel Yaskevich
ddad2a7dad [SIL] InitAccessors: Reference a field that assign_or_init is associated with
The field removes the need to dig through init accessor reference
to find what stored properties and handled by the instruction.
2023-07-28 08:32:37 -07:00
Slava Pestov
50b8c347eb Merge pull request #67565 from slavapestov/fix-issue67322
TypeDecoder: Push one-element tuple unwrapping down into createTupleType() implementations
2023-07-28 09:32:03 -04:00
swift-ci
617b25ac80 Merge pull request #67567 from nate-chandler/rdar112792831-2
[IRGen] alloc_stack may allocate pack metadata.
2023-07-27 18:32:25 -07:00
Allan Shortlidge
1381d9a7b2 Merge pull request #67575 from tshortli/fix-warnings
NFC: Fix warnings
2023-07-27 16:52:03 -07:00
jturcotti
bb2f3c011e rename DeferredSendableChecking pass to SendNonSendable pass, handle more instructions such as try_apply and begin_apply, and fix bugs 2023-07-27 16:45:29 -07:00
Nate Chandler
e5d87f75a8 [SIL] Add source formal type to checked_cast_br.
It is necessary for opaque values where for casts that will newly start
out as checked_cast_brs and be lowered to checked_cast_addr_brs, since
the latter has the source formal type, IRGen relies on being able to
access it, and there's no way in general to obtain the source formal
type from the source lowered type.
2023-07-27 15:04:15 -07:00
Nate Chandler
471c9789c7 [AST] NFC: Refactor pack recursive properties.
Eliminated HasConcretePack and added HasPack and HasPackArchetype.
Renamed the old `hasPack` to `hasAnyPack`; as before, it means that the
type has a parameter pack, a pack, or a pack archetype.
2023-07-27 13:18:14 -07:00
Allan Shortlidge
7c93887c21 Merge pull request #67556 from tshortli/derived-codable-conformance-unavailable-enum-element
Sema: Avoid decoding unavailable enum elements in derived Codable conformances
2023-07-27 13:07:24 -07:00
Allan Shortlidge
f9a93a55d7 NFC: Fix duplicate definition of macro warnings.
Centralize the `SWIFT_{BEGIN/END}_NULLABILITY_ANNOTATIONS` definitions in a new
Nullability.h header to share.
2023-07-27 13:02:22 -07:00
Pavel Yaskevich
9b3980573f Merge pull request #67297 from amritpan/build-out-resolve-kp
[ConstraintSystem] Set up keypath expressions typechecking
2023-07-27 09:52:09 -07:00
Slava Pestov
3a24b5361d TypeDecoder: Push one-element tuple unwrapping down into createTupleType() implementations
The old behavior was only correct when building substituted types,
ie, if createTupleType() was never called with a pack expansion type.

This was the case in the runtime's MetadataLookup which applies
substitutions to an interface type to ultimately construct metadata
for a fully-concrete type, but not in the ASTDemangler, where we
actually build interface types.

Since TypeDecoder doesn't have any way to query the kind of type
it just built, let's just instead make this decision inside the
implementation of the type builder concept.

Fixes https://github.com/apple/swift/issues/67322.
2023-07-27 12:14:54 -04:00
Allan Shortlidge
7996c5b30c Sema: Avoid decoding unavailable enum elements in derived Codable conformances.
The compiler derived implementations of `Codable` conformances for enums did
not take enum element unavailability into account. This could result in
unavailable values being instantiated at runtime, leading to a general
violation of the invariant that unavailable code is unreachable at runtime.
This problem is possible because synthesized code is not type checked; had the
conformances been hand-written, they would have been rejected for referencing
unavailable declarations inside of available declarations.

This change specifically alters derivation for the following declarations:
- `Decodable.init(from:)`
- `Encodable.encode(to:)`
- `CodingKey.init(stringValue:)`

Resolves rdar://110098469
2023-07-26 22:48:25 -07:00
swift-ci
86b812b655 Merge pull request #63033 from nate-chandler/opaque-values/2/20221215
[AddressLowering] Project at storage.
2023-07-26 19:45:30 -07:00
Ben Barham
7e8a33097e Merge pull request #67488 from bnbarham/better-note-locations
[Diagnostics] Improve diagnostics involving macros
2023-07-26 17:48:02 -07:00
Michael Gottesman
8c82b6b7d9 Merge pull request #67546 from gottesmm/pr-9bcf05ac3fb12f2872cc63507f782c766eba18b7
[sema] Ban user created read/set accessor that produce noncopyable types
2023-07-26 16:44:29 -07:00
Hamish Knight
c415744f26 Merge pull request #67537 from hamishknight/loc-step 2023-07-26 22:16:53 +01:00
Egor Zhdan
276a232ea8 Merge pull request #67536 from apple/egorzhdan/unsafe-cxx-mutable-input-iterator
[cxx-interop] Add `UnsafeCxxMutableInputIterator` protocol
2023-07-26 22:15:57 +01:00
Michael Gottesman
2a1d9199a3 [sema] Ban user created read/set accessor that produce noncopyable types.
The reason why we are doing this is that this combination of read/set forces the
compiler to emit a copy if we want to emit a modify operation.

The reason why we are forced to emit such a copy is that:

1. _read provides a guaranteed value in memory
2. performing a modify requires an owned value in memory.

This together implies that the only way we can do this is to copy from the _read
into temporary memory. But we have a noncopyable type so we can't do this.

rdar://112915525
2023-07-26 12:53:43 -07:00
Egor Zhdan
8d7d0efe13 [cxx-interop] Add UnsafeCxxMutableInputIterator protocol
This is an inheritor of the existing `UnsafeCxxInputIterator` protocol, with the only difference being the ability to mutate `var pointee` via a non-const `operator*()`.

This is needed to support mutable subscripts for `std::map` via `CxxDictionary`.

rdar://105399019
2023-07-26 18:20:49 +01:00
Allan Shortlidge
86265881c3 Merge pull request #67528 from tshortli/revert-66930
Sema: Resume diagnosing `@backDeployed` on functions with opaque result types as errors
2023-07-26 09:15:50 -07:00
Joe Groff
705e317c3f Merge pull request #67425 from jckarter/raw-storage
[WIP] Raw storage and locks/atomics prototype
2023-07-26 08:49:02 -07:00
Hamish Knight
a64ba23d7b [CS] NFC: Store ContextualTypeInfo in SyntacticElementTarget
Move the contextual type locator onto
ContextualTypeInfo, and consolidate the separate
fields in SyntacticElementTarget into storing a
ContextualTypeInfo. This then lets us plumb down
the locator for the branch contextual type of an
if/switch expression from the initial constraint
generation, rather than introducing it later. This
should be NFC.
2023-07-26 16:46:54 +01:00
Alex Lorenz
61d73d2b6f Merge pull request #67523 from hyp/eng/compat-version
[cxx-interop] add 'upcoming-swift' C++ interop compat version
2023-07-26 06:09:18 -07:00
Amritpan Kaur
5fa54dfc4d [CSSimplify] Delay matchTypes for key path values
until they are directly bound.
2023-07-25 22:16:28 -07:00
Allan Shortlidge
e3453ca32a Revert "Sema: temporarily downgrade backdeployed_opaque_result_not_supported to a warning"
This reverts commit 0a3dadff90.
2023-07-25 21:13:31 -07:00