mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
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
This commit is contained in:
@@ -257,28 +257,11 @@ void ConstraintSystem::assignFixedType(TypeVariableType *typeVar, Type type,
|
||||
|
||||
// If the protocol has a default type, check it.
|
||||
if (auto defaultType = TypeChecker::getDefaultType(literalProtocol, DC)) {
|
||||
auto isDefaultType = [&literalProtocol, &defaultType](Type type) {
|
||||
// Treat `std.string` as a default type just like we do
|
||||
// Swift standard library `String`. This helps to disambiguate
|
||||
// operator overloads that use `std.string` vs. a custom C++
|
||||
// type that conforms to `ExpressibleByStringLiteral` as well.
|
||||
//
|
||||
// This doesn't clash with String because inference won't attempt
|
||||
// C++ types unless we discover them from a constraint and the
|
||||
// optimizer and old hacks always prefer the actual default type.
|
||||
if (literalProtocol->getKnownProtocolKind() ==
|
||||
KnownProtocolKind::ExpressibleByStringLiteral &&
|
||||
type->isCxxString()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check whether the nominal types match. This makes sure that we
|
||||
// properly handle Array vs. Array<T>.
|
||||
return defaultType->getAnyNominal() == type->getAnyNominal();
|
||||
};
|
||||
|
||||
if (!isDefaultType(type))
|
||||
// Check whether the nominal types match. This makes sure that we
|
||||
// properly handle Array vs. Array<T>.
|
||||
if (defaultType->getAnyNominal() != type->getAnyNominal()) {
|
||||
increaseScore(SK_NonDefaultLiteral, locator);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user