Commit Graph

7621 Commits

Author SHA1 Message Date
Mishal Shah
c110c9570f Merge pull request #83809 from finagolfin/cross-tools
[6.2.1][build] Make it possible to build a cross-compilation toolchain for Android, including Testing
2025-09-18 09:10:48 -07:00
Pavel Yaskevich
bbb11ec272 [TypeCheckEffects] AbstractFunction: Parameter types should be mapped into context
Parameter type could be represented by an associated type which is
bound to a concrete type by an extension, `AbstractFunction::getType()`
should map it into context before returning because the construct is
that it always produces a function type.

Resolves: rdar://156955193
(cherry picked from commit 32b97d0e2a)
(cherry picked from commit 7f652915d9)
2025-08-27 10:35:50 -07:00
Finagolfin
bfac55b009 [build] Change Foundation macro checks because of #83422
I missed that `build-script` passes back `false` instead, so use the `true_false`
function for broader checking.
2025-08-19 18:46:02 +05:30
Finagolfin
8a9ae8d789 [build] Make the new --cross-compile-build-swift-tools flag public
This new flag makes it easy to build Swift cross-compilation toolchains, by
disabling cross-compilation of all host tools, like the Swift compiler and
various macros, building on prior pulls #38441 and #82163.

Also, add two class methods to the Testing macros product so it works with #83260.
2025-08-19 18:45:49 +05:30
finagolfin
2de7f9427a [build][android] Use a CMake toolchain file to cross-compile Testing (#83260)
Also, disable a recently failing test for Android armv7.
2025-08-19 18:45:31 +05:30
Erik Eckstein
d2e872fe6b tests: increase the timeout for large_nested_array.swift.gyb
This fixes a timeout failure in CI. It looks like that some CI machines are slower than expected.
I could not reproduce this locally. There doesn't seem to be a compile time regression.
2025-08-06 09:55:19 +02:00
Hamish Knight
5d93006d4c [Sema] Avoid folding sequences multiple times for completion
Completion can end up calling into pre-checking multiple times in
certain cases, make sure we don't attempt to fold a SequenceExpr
multiple times since its original AST is in a broken state
post-folding. Instead, just return the already-folded expression.

rdar://133717866
2025-07-14 17:49:23 +01:00
Hamish Knight
736ed5bd82 Merge pull request #82911 from hamishknight/unbounded-6.2
[6.2] [Completion] Avoid using unbound contextual type in argument completion
2025-07-09 21:27:57 +01:00
Hamish Knight
91222b9ebe [Completion] Avoid using unbound contextual type in argument completion
Match the logic in `getTypeForCompletion` and avoid using an unbound
generic type as the expected type for a completion.

rdar://155420395
2025-07-09 13:02:32 +01:00
Nate Chandler
ba0b2e7c51 [ODL] Visit objc_method insts.
No update is needed for the values they produce.  This pass should
really be refactored not to crash on instructions that aren't explicitly
listed or at least not to compile if not every instruction is listed.

rdar://155059418
2025-07-08 17:24:41 -07:00
Hamish Knight
9671ed9d85 [Completion] Map failable initializer result type into context
Make sure we don't pass an interface type to `setTypeContext`.

rdar://155038769
2025-07-04 13:59:07 +01:00
Hamish Knight
ee5f4df5ee Merge pull request #82775 from hamishknight/simple-fix-6.2
[6.2] [CS] Ensure type variables are eliminated by `Solution::simplifyType`
2025-07-04 10:56:34 +01:00
Hamish Knight
7e537b7f00 [CS] Ensure type variables are eliminated by Solution::simplifyType
`TypeSimplifier` may not eliminate type variables from e.g the
pattern types of pattern expansion types since they can remain
unresolved due to e.g having a placeholder count type. Make sure we
eliminate any remaining type variables along with the placeholders.
There's probably a more principled fix here, but this is a quick and
low risk fix we can hopefully take for 6.2.

rdar://154954995
2025-07-03 17:53:23 +01:00
Hamish Knight
4c6e06fed3 [AST] Use ErrorType for invalid value generic parameter
If we fail to resolve the value type for a value generic parameter,
previously we would have returned a null Type, causing crashes
downstream. Instead, return an ErrorType, leaving a null Type for
cases where the generic parameter isn't a value generic at all.

rdar://154856417
2025-07-02 21:19:45 +01:00
QuietMisdreavus
a75f94eef4 [6.2] use RespectOriginallyDefinedIn when mangling extension contexts (#82657)
- **Explanation**: USR mangling can include an extension context infix
(`AAE`) when an extended type uses `@_originallyDefinedIn` on platforms
other than the active one. This adds a check for the
`RespectOriginallyDefinedIn` flag when checking extension decls against
their extended type.
- **Scope**: Changes USR mangling in these situations so that USRs are
the same for the same code regardless of platform.
- **Issues**: rdar://152598492
- **Original PRs**: https://github.com/swiftlang/swift/pull/82348
- **Risk**: Low. The change is limited to situations where the name
mangler is already disrespecting the alternate module name, and only
additionally turns on that flag for any USR mangling.
- **Testing**: Automated tests
- **Reviewers**: @edymtt @augusto2112
2025-07-01 00:30:15 -07:00
Hamish Knight
dbc9dae27f [CS] Use the resolved type in NonOptionalUnwrapFailure::diagnoseAsError
Diagnostics can outlive the ConstraintSystem itself if we have a
diagnostic transaction for e.g `typeCheckParameterDefault`, make sure
we don't try to use a solver-allocated type as an argument.
2025-06-30 10:34:18 +01:00
Hamish Knight
2acacc9a74 [CS] Avoid escaping solver-allocated types in computeSubstitutions
Make sure we call `simplifyType` for the opened type bindings to
ensure holes get converted to UnresolvedType.

rdar://154553285
2025-06-30 10:34:18 +01:00
Dario Rexin
96d6eb87ee Merge pull request #82352 from drexin/wip-153681688-6.2
[6.2][IRGen] Fix placeholder logic for emission of conditionally inverted protocols
2025-06-23 18:22:26 -07:00
Hamish Knight
8f66e610df Merge pull request #82340 from hamishknight/record-opened-6.2 2025-06-19 08:19:06 +01:00
Dario Rexin
ae8c455170 [IRGen] Fix placeholder logic for emission of conditionally inverted protocols
rdar://153681688

Instead fo counting the actual conformances, the logic took the size of the bit field, i.e. used the highest set bit, so when a type had a conditional conformance only on ~Escapable, but not on ~Copyable, it would still add 2 placeholders, but only fill one.
2025-06-18 14:47:40 -07:00
Hamish Knight
612f7b213c Merge pull request #82319 from hamishknight/keyed-6.2
[6.2] [Sema] Tighten up function call check in `resolveKeyPathExpr`
2025-06-18 18:24:30 +01:00
Hamish Knight
4d654b271f [CS] Distinguish locators for generic args in addSpecializationConstraint
Make sure we give each argument a different locator to ensure we
can correctly record any opened types.

rdar://153674889
2025-06-18 16:21:45 +01:00
Hamish Knight
0409102619 Merge pull request #82304 from hamishknight/wrapping-paper-6.2 2025-06-18 08:51:09 +01:00
Hamish Knight
f95eb6bf48 [Sema] Tighten up function call check in resolveKeyPathExpr
Check for `CallExpr` instead of `ApplyExpr`, we don't support
arbitrary postfix operators in key paths.
2025-06-17 23:07:55 +01:00
Hamish Knight
61e0326b7f [Sema] Add null check in createMemberwiseInitParameter
The property wrapper initializer info may be null if e.g we had a
request cycle, just use the property's interface type in that case.

rdar://82899428
2025-06-17 17:31:24 +01:00
Nate Chandler
2cf7ef5fdc [IRGen] Fix FixedArray of fixedSize 1 elt addring.
When a `FixedArray`'s fixed size is 1, it looks like `[1 x %Ty]`. Given
an array's address, performing an operation on each element's address
entail's indexing into the array to each element's index to produce an
element's address for each index.  That is true even when the array
consists of a single element.  In that case, produce an address for that
single element by indexing to index 0 into each passed-in array.

rdar://151726387
2025-06-16 20:34:22 -07:00
Meghana Gupta
2bbc1c393c Merge pull request #82224 from meg-gupta/fixinlinercrashcp
[6.2] Fix an inliner crash when inlining begin_apply with scoped lifetime dependence
2025-06-13 23:06:36 -07:00
Meghana Gupta
d5b82a3b7c [6.2] Fix an inliner crash when inlining begin_apply with scoped lifetime dependence 2025-06-13 14:18:29 -07:00
Hamish Knight
19bc18f064 Merge pull request #82152 from hamishknight/fix-nested-arenas-6.2 2025-06-13 08:01:57 +01:00
Meghana Gupta
8d3f38623d [NFC] Update tests and diagnostics 2025-06-11 13:15:22 -07:00
Hamish Knight
cc66fc886f [CS] Avoid solver-allocated inputs with typesSatisfyConstraint
Escaping solver-allocated types into a nested allocation arena is
problematic since we can e.g lazily compute the `ContextSubMap` for a
`NominalOrBoundGenericNominalType`, which is then destroyed when we
exit the nested arena. Ensure we don't pass any types with type
variables or placeholders to `typesSatisfyConstraint`.

rdar://152763265
2025-06-10 16:08:00 +01:00
Pavel Yaskevich
f8a3c3b1ff [TypeCheckEffects] Fix AbstractFunction::getType to look through all levels of optional
A member and a parameter could be wrapped in an arbitrary number
of `Optional`, we need to look through all of them to get to the
underlying function type.

Resolves: rdar://151943924
(cherry picked from commit 86390ab91f)
2025-06-09 17:18:11 -07:00
nate-chandler
4051ea2e78 Merge pull request #82044 from nate-chandler/cherrypick/release/6.2/rdar152580661
6.2: [TypeLowering] Record pack used in aggregate signature.
2025-06-06 14:53:18 -07:00
Nate Chandler
d8c6f9817c [TypeLowering] Record pack used in aggregate sig.
Every `LowerType::visit*` function eventually calls through to a
`LowerType::handle*` function.  After
https://github.com/swiftlang/swift/pull/81581, every
`LowerType::handle*` needs to set the `hasPack` flag based on the
passed-in type by calling `mergeHasPack`.  Add the missing call in the
`handleAggregateByProperties` function.

rdar://152580661
2025-06-05 17:45:14 -07:00
Pavel Yaskevich
6e9d97e273 Merge pull request #81945 from xedin/various-diagnostic-fixes-6.2
[6.2][Diagnostics] A collection of diagnostic fixes/improvements
2025-06-03 19:57:44 -07:00
Pavel Yaskevich
d8642fce19 [Tests] NFC: Update all of the test-cases improved by changes to generic argument mismatch handling
(cherry picked from commit 4132aa04f9)
2025-06-03 09:33:13 -07:00
Meghana Gupta
637f8ef03e [6.2] Fix deserialization of lifetime dependencies on ast function types 2025-06-02 17:36:22 -07:00
Michael Gottesman
b8cf5aeb34 Updates for 6.2.
These were changes that were not updated in the previous commit due to merge conflict
resolution or that the test itself was not in 6.2.
2025-05-23 10:33:58 -07:00
Pavel Yaskevich
dd95c60c70 [TypeChecker] Improve diagnostics for access to actor-isolated values outside of the actor
Replaces generic `expression is 'async' but is not marked with 'await`
diagnostic with a tailed one for cases where there is an access to an
actor-isolated value outside of its actor without `await` keyword.

This makes the diagnostics for async and sync contexts consistent
and actually identifies a problem instead of simply pointing out
the solution.

Resolves: rdar://151720646
(cherry picked from commit 7a6ba8e8c58c58b3438f31fec06102d02bae81a5)
2025-05-22 23:52:02 -07:00
nate-chandler
1887346228 Merge pull request #81659 from nate-chandler/cherrypick/release/6.2/rdar147207926
6.2: [TypeLowering] Record packs used in signatures.
2025-05-21 13:40:48 -07:00
Nate Chandler
701ad64ca6 [TypeLowering] Record packs used in signatures.
To determine whether an instruction may require pack metadata, the types
of its operands are examined.

Previously, the top level type was checked for having a pack in its
signature, and the whole type was checked for having a type anywhere in
its layout (via TypeLowering).  This didn't account for the case where
the metadata was required for a resilient type which uses a pack in its
signature.

Here, during type lowering, a type having a pack in its signature is
counted towards the type having a pack.

Fixes a compiler crash.

rdar://147207926
2025-05-20 17:26:46 -07:00
nate-chandler
8e0a3896af Merge pull request #81574 from nate-chandler/cherrypick/release/6.2/rdar151325025
6.2: [MoveOnlyChecker] Don't complete phis.
2025-05-19 08:19:26 -07:00
Nate Chandler
f648171f0d [MoveOnlyChecker] Don't complete phis.
Apply the MoveOnlyAddressChecker change from
https://github.com/swiftlang/swift/pull/73358 to the
MoveOnly[Value]Checker.

After 7713eef817, before running value
checking, all lifetimes in the function are completed.  That doesn't
quite work because lifetime completion expects not to encounter
reborrows or their adjacent phis.

rdar://151325025
2025-05-16 14:24:22 -07:00
Nate Chandler
b014950aac [MoveOnly] Fix consume of addr with mutated field.
Don't fail out of use visitation when encountering an apply which uses a
field of the value as an inout parameter.

rdar://139666145
2025-05-15 15:23:00 -07:00
Anthony Latsis
d3cead65fe Merge pull request #81038 from AnthonyLatsis/collybia-nuda-6.2
[6.2] AST: Quote attributes more consistently in diagnostics
2025-04-25 21:53:21 +01:00
nate-chandler
e2d59bdb5b Merge pull request #81044 from nate-chandler/rdar141279635
6.2: [MoveOnly] Fix consumption of opened existentials.
2025-04-23 20:53:04 -07:00
Nate Chandler
875e67a2b9 [MoveOnly] Fix consumption of opened existentials.
Enable walking into `TypeOffsetSizePair`s from an existential into an
archetype.  And set the access kind on `open_existential_addr`
instructions which are the sources of rewritten `copy_addr`s to mutable.

rdar://141279635
2025-04-23 13:28:49 -07:00
Hamish Knight
71be544585 [ASTPrinter] Add missing null check in isNonSendableExtension
The extended nominal may not be present for an invalid extension.

rdar://149032713
2025-04-23 21:13:34 +01:00
Anthony Latsis
5e41794680 AST: Quote attributes more consistently in DiagnosticsSema.def 2025-04-23 19:18:08 +01:00
Slava Pestov
4af982902c cmake: Add NO_SWIFTMODULE option to add_swift_target_library() 2025-04-21 15:01:28 -04:00