Commit Graph

6 Commits

Author SHA1 Message Date
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
Egor Zhdan
6852bc9834 Revert "[ConstraintSystem] C++ Interop: Binding a string literal to std.string shouldn't increase the score"
This reverts commit cd9c37ca

This is causing build failures for some projects. We need more time to investigate. Reverting this temporarily in the meantime.

rdar://158439395
2025-11-05 11:19:11 -08:00
Pavel Yaskevich
cd9c37cac6 [ConstraintSystem] C++ Interop: Binding a string literal to std.string shouldn't increase the score
Since this is a C++ stdlib type we need make sure that any overloads
that use it are preferred over custom types that also conform to
`ExpressibleByStringLiteral` when argument is a string literal.

This is important for operators like `==` which could be heterogenous
and have a custom C++ type that conforms to `ExpressibleByStringLiteral`
on either side together with `std.string` i.e.
`==(std.string, const CustomString &)`, such overloads should only
be selected if argument passed to `CustomString` is non-literal because
literals are convered by a stdlib `==(std.string, std.string)` overload.
2025-07-24 14:08:15 -07:00
Egor Zhdan
d594f475ee [cxx-interop] Check for unsafe types of default arguments consistently
If the C++ type of a function parameter defines a custom copy constructor, assume that it is safe to use from Swift. This matches the heuristic that we use to detect if a C++ method is safe based on the return type.

rdar://121391798
2024-01-26 19:26:27 +00:00
Egor Zhdan
dab1cb5e12 [cxx-interop] Simplify a std::string test
`std::string` can be accessed directly from Swift, there is no need to go through a using-decl.
2023-06-13 17:22:21 +01:00
zoecarver
fefe39e89e [cxx-interop] Add a basic test for using std::string. 2022-02-02 14:31:04 -08:00