107225 Commits

Author SHA1 Message Date
Pavel Yaskevich
2c9092486e Merge pull request #85939 from xedin/rdar-159408715
[Diagnostics] Don't attempt to synthesize arguments when destructurin…
2025-12-10 06:49:02 -08:00
Pavel Yaskevich
cb8d672511 Merge pull request #85873 from xedin/rdar-165862285
[CSRanking] Disambiguate static vs. instance method that used to be s…
2025-12-10 06:48:20 -08:00
Hamish Knight
63abfab670 Merge pull request #85738 from hamishknight/to-wit
[Frontend] Enforce an error was emitted for invalid conformance
2025-12-10 14:00:14 +00:00
Egor Zhdan
39d13c4093 [cxx-interop] Fix compile error
This fixes a compiler error introduced by ad56e061. The signature of `isMemberwiseInitializer()` changed after the CI ran on the PR.
2025-12-10 13:43:21 +00:00
Egor Zhdan
ad56e061af Merge pull request #85066 from egorzhdan/egorzhdan/std-function-context
[cxx-interop] Allow initializing `std::function` from Swift capturing closures
2025-12-10 13:35:34 +00:00
Slava Pestov
3dcd9bb011 Merge pull request #85938 from slavapestov/12-year-old-fixme-strikes-back
Sema: Tighten ridiculous disambiguation hack for overloaded type declarations
2025-12-10 06:53:43 -05:00
Slava Pestov
e7d2c163be Merge pull request #85933 from slavapestov/fix-ben-regression
Sema: Disambiguate some more bidirectional conversions
2025-12-10 06:53:01 -05:00
Slava Pestov
6701e5b39b Sema: Tighten ridiculous disambiguation hack for overloaded type declarations
We noticed that a project failed to build with prepared overloads enabled,
but built successfully with prepared overloads disabled.

It turns out that the code clearly should never have been accepted in the
first place, because the type checker was making an arbitrary choice between
two nominal type declarations with the same name.

Further inspection revealed this was because of a FIXME added in 2013 which
was far too broad. Tighten up the logic here to only disambiguate if at least
one of the two declarations is a type alias, and it has the same underlying
type as the other one. A choice between unrelated nominal type declarations
should always be ambiguous.

This still isn't perfect, because we might have two generic type aliases
that are referenced in both solutions with different substitution maps,
in which case we will still erroneously pick the first one. But this
is better than the old logic, at least.

Fixes rdar://165863775.
2025-12-09 22:48:12 -05:00
Saleem Abdulrasool
58035835d2 Merge pull request #85899 from compnerd/filename
DriverTool: adjust `argv[0]` scanning for CAS
2025-12-09 18:13:01 -08:00
Pavel Yaskevich
1f887202e1 [Diagnostics] Don't attempt to synthesize arguments when destructuring a single tuple argument results in an overrun
If arguments are represented by a single tuple it's possible
that the issue is not about missing parameters but instead
about tuple destructuring. Fix `fixMissingArguments` to check for
overruns after destructuring and stop if that produces more
arguments then parameters because such situations are better
diagnosed as a general conversion failure rather than a missing
argument(s) problem.

Resolves: rdar://159408715
2025-12-09 16:52:41 -08:00
Slava Pestov
d5c049ed69 Sema: Better debug output in compareSolutions() 2025-12-09 18:38:19 -05:00
Slava Pestov
f3e6b4ceda Sema: Disambiguate some more bidirectional conversions
This fixes an ambiguity introduced by the stdlib change in
0f99458900.

Since (borrowing T) -> () and (T) -> () both convert to
each other, we could end up with ambiguous solutions where
neither one was better than the other. Generalize the
existing trick we use for labeled vs unlabeled tuples to
also strip off ownership specifiers and @convention(...)
from function types. This fixes the regression, as well
an existing FIXME in a test I added a while ago where
the same problem arises with @convention(block).
2025-12-09 18:31:59 -05:00
Slava Pestov
5e952e9b22 Merge pull request #85902 from slavapestov/csbindings-cleanups
Sema: A few more simple CSBindings cleanups
2025-12-09 18:29:53 -05:00
Meghana Gupta
4089775de8 Fix swiftinterface printing of accessors and inferred lifetime dependencies when Lifetimes feature is enabled 2025-12-09 14:59:41 -08:00
Alexis Laferrière
85d522e4c2 Merge pull request #85917 from xymus/exportability-nle-classes
Sema: Allow non-open class properties to reference hidden dependencies in non-library-evolution mode
2025-12-09 13:36:01 -08:00
John Hui
f1e2b7a07f Merge pull request #85723 from an0/my-branch
[ClangImporter] Fix NS_CLOSED_ENUM to validate raw values
2025-12-09 13:35:30 -08:00
Hamish Knight
20bee09dc9 Merge pull request #85889 from hamishknight/overrun
[Parse] Fix buffer overrun in `advanceIfMultilineDelimiter`
2025-12-09 20:26:24 +00:00
Arnold Schwaighofer
4d879967a7 [embedded] Feature::EmbeddedExistentials requires Feature::Embedded 2025-12-09 10:21:51 -08:00
Gábor Horváth
d97fa92a33 Merge pull request #85650 from Xazax-hun/refcounted-ptr-conversions
[cxx-interop] Introduce SWIFT_REFCOUNTED_PTR
2025-12-09 17:01:08 +00:00
Egor Zhdan
a6b30c4dd0 Merge pull request #85869 from egorzhdan/egorzhdan/remove-interop-compat-version
[cxx-interop] Remove compatibility versions
2025-12-09 15:45:00 +00:00
Slava Pestov
3c4fef164e Sema: Add some LLVM_DEBUG output to CSBindings.cpp 2025-12-09 09:44:52 -05:00
Slava Pestov
25d9829af9 Sema: Remove incorrect usage of big-O notation from comment 2025-12-09 09:43:22 -05:00
Hamish Knight
f25b4b4fcc Merge pull request #85897 from hamishknight/retraction
[Demangler] Handle invertible reqs for extensions in `findDeclContext`
2025-12-09 14:32:55 +00:00
finagolfin
6d4931986f [autolink-extract] Update deduplication list for Observation (#85856)
All linux and Android CI show this being repeated many times, eg when
[building the Docc binary on the linux
CI](https://ci.swift.org/job/swift-PR-Linux-smoke-test/24247/consoleText):
```
"/home/build-user/build/buildbot_linux/unified-swiftpm-build-linux-x86_64/x86_64-unknown-linux-gnu/release/docc.build/main.swift.o" "-lswiftObservation" ... repeated many times ... "-lswiftObservation" "-lswiftCore"
```
2025-12-09 19:46:07 +05:30
Egor Zhdan
84e7f82363 Reapply "[ConstraintSystem] C++ Interop: Binding a string literal to std.string shouldn't increase the score"
This reverts commit 6852bc9834.

In addition to the original change, this makes sure that C++ `std::string` and Swift `String` are given distinct score, in order to prevent ambiguity which was causing build failures in some projects.

rdar://158439395
2025-12-09 12:55:18 +00:00
Hamish Knight
1fc04bf681 Merge pull request #84514 from hamishknight/not-privy
[Sema] Exclude private initialized vars from memberwise initializer
2025-12-09 04:19:13 +00:00
Arnold Schwaighofer
0c7aded660 Merge pull request #85871 from aschwaighofer/lazy_metadata_emission_embedded_exist
[embedded] Lazily emit class metadata in embedded mode and apply shared linkage
2025-12-08 18:13:38 -08:00
Alexis Laferrière
1fd44e67a2 Sema: Allow refs to hidden dependencies in prorperties of non-open classes
We now report properties referencing types imported from
implementation-only dependencies in non-library-evolution mode as the
memory layouts of structs and enums may be exposed to clients. Here we
exempt non-open classes from this check as clients hold pointers to
classes which hides the class internal memory layouts. Keep forbidding
it for open classes in order to error early, a client trying to subclass
an open class with such a reference from their property would already
see an error about members not deserializable.
2025-12-08 16:39:16 -08:00
Arnold Schwaighofer
d06929ccd2 [embedded] Add support for some foreign metadata 2025-12-08 15:35:43 -08:00
Hamish Knight
45683f6561 [Sema] Exclude private initialized vars from memberwise initializer
Exclude properties with initial values from the memberwise initializer
if they are less accessible than the most accessible property, up to
`internal`. Introduce a compatibility overload that continues to
include the same properties as before until the next language mode.

This is gated behind the `ExcludePrivateFromMemberwiseInit` feature.

rdar://122416579
2025-12-08 23:22:35 +00:00
Hamish Knight
e383766e93 [SILGen] Handle default initialization of init accessor in memberwise init
If the property isn't memberwise initializable we need to emit its
initial value and call the init accessor. This currently isn't necessary
since all init accessor properties are included in the memberwise
initializer, but the following commit will change this.
2025-12-08 23:22:35 +00:00
Hamish Knight
1d8341bd0b [Sema] Swap init accessor check in MemberwiseInitPropertiesRequest
Currently `init` accessors are always memberwise initialized, but I'm
planning on changing that. As such we need to make sure we record
the `init` accessor regardless of whether it is included in the memberwise
init.
2025-12-08 23:22:35 +00:00
Hamish Knight
17af03d622 [Sema] Factor out InitializablePropertiesRequest
This serves as the backing request for both InitAccessorPropertiesRequest
and MemberwiseInitPropertiesRequest, ensuring the former does not
care about the init accessor is included in the memberwise initializer.
2025-12-08 23:22:35 +00:00
Hamish Knight
302e803b2f [AST] Store original lazy VarDecl for backing storage
Store the original VarDecl in the same map we use for tracking the
original wrapper var for property wrappers. This will allow us to
use the same logic to determine the original var for both.
2025-12-08 23:22:35 +00:00
Hamish Knight
c02fb8b1a1 [AST] Factor out printMemberwiseInit
Move the printing logic into libAST such that it can be used both by
the refactoring and by fix-it logic in Sema.
2025-12-08 23:22:35 +00:00
Hamish Knight
01b965fe3c [IDE] Use Identifier for printing member name in generateMemberwiseInit
Avoid relying on the source text and print the identifier, escaping
if needed.
2025-12-08 23:22:35 +00:00
Pavel Yaskevich
df3aa1e011 Merge pull request #85879 from xedin/add-supression-note-to-explicit-sendable-warning
[Diagnostics] TildeSendable: Suggest `Sendable` suppression in explic…
2025-12-08 13:29:25 -08:00
Alexis Laferrière
de9148e6f1 Merge pull request #85868 from xymus/exportability-nle-split
Sema: Distinguish implicitly visible memory layouts from the typical `@frozen` ones
2025-12-08 13:29:16 -08:00
Ryan Mansfield
e60ca698c6 Merge pull request #85440 from rjmansfield/fix-wmo-opt-record-paths
Fix optimization record paths in multi-threaded WMO mode
2025-12-08 16:14:53 -05:00
Dario Rexin
0fdca11e46 [IRGen] Use proper linkage for async function pointers to partial apply forwarders
rdar://163631865

Under certain circumstances the same symbol can be used for different implementations of the forwarders.
The forwarders themselves are already emitted with "internal" LLVM linkage, but some particularities in
the mapping from SILLinkage to LLVM linkage caused async function pointers to partial apply forwarders
to be emitted with linkonce_odr instead, which caused the wrong forwarder to be called at runtime, causing
unexpected behavior and crashes.
2025-12-08 11:30:22 -08:00
Pavel Yaskevich
7d3e40b7bb Merge pull request #85830 from jamieQ/no-async-in-await-fixit
[Sema]: add fixit for `no_async_in_await` warning
2025-12-08 11:26:32 -08:00
Slava Pestov
563ba95a7d Sema: Move definition of hasConversions() before its first use 2025-12-08 10:12:13 -05:00
Slava Pestov
db4e3b0838 Sema: Move definition of checkTypeOfBinding() before its first use 2025-12-08 10:12:13 -05:00
Slava Pestov
2eebdc3bb5 Sema: Simplify addLiteralRequirement() and fix misleading comment
Literal coverage is actually checked elsewhere, so this was
about whether the protocol has a default type only.
2025-12-08 10:12:13 -05:00
Slava Pestov
f4dabfb889 Sema: checkTypeOfBinding() should return a bool
This always returned a std::nullopt, or an optional of the given 'type'.
2025-12-08 10:12:13 -05:00
Slava Pestov
0fabf82ace Sema: Fix assert failure with non-representative type variable in contractEdges() 2025-12-08 10:12:12 -05:00
Saleem Abdulrasool
070916fef3 DriverTool: adjust argv[0] scanning for CAS
Ensure that we nativize the path and consider only the filename starting
prefix to account for file suffixes (e.g. `.exe` on Windows). This
ensures that we properly support other platforms.
2025-12-08 08:53:26 -06:00
Hamish Knight
d8a867df86 [Demangler] Handle invertible reqs for extensions in findDeclContext
If we didn't find an extension result, try again disregarding
invertible requirements since `demangleGenericSignature` won't
include them. This is just meant to be a quick low risk fix that we
can cherry-pick, the proper fix here is to delete all this logic and
just return the nominal along with the ABI module name to filter
lookup results.

rdar://165639044
2025-12-08 12:21:29 +00:00
Hamish Knight
0068438385 [Parse] Fix buffer overrun in advanceIfMultilineDelimiter
Make sure we don't scan off the end of the buffer, and scan for the
delimiter before attempting the lookahead.
2025-12-07 20:05:43 +00:00
Slava Pestov
8da3b62d7b Merge pull request #85293 from slavapestov/too-complex-source-loc
Sema: Fix source location bookkeeping for 'reasonable time' diagnostic
2025-12-07 01:26:04 -05:00