Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion include/swift/AST/KnownIdentifiers.def
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ IDENTIFIER(Any)
IDENTIFIER(ArrayLiteralElement)
IDENTIFIER(asLocalActor)
IDENTIFIER(atIndexedSubscript)
IDENTIFIER(basic_string)
IDENTIFIER_(bridgeToObjectiveC)
IDENTIFIER(buildArray)
IDENTIFIER(buildBlock)
Expand Down
3 changes: 0 additions & 3 deletions include/swift/AST/Types.h
Original file line number Diff line number Diff line change
Expand Up @@ -1110,9 +1110,6 @@ class alignas(1 << TypeAlignInBits) TypeBase
/// Check if this is a ObjCBool type from the Objective-C module.
bool isObjCBool();

/// Check if this is a std.string type from C++.
bool isCxxString();

/// Check if this is the type Unicode.Scalar from the Swift standard library.
bool isUnicodeScalar();

Expand Down
16 changes: 0 additions & 16 deletions lib/AST/Type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
#include "swift/AST/Types.h"
#include "swift/Basic/Assertions.h"
#include "swift/Basic/Compiler.h"
#include "clang/AST/DeclCXX.h"
#include "llvm/ADT/APFloat.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallPtrSet.h"
Expand Down Expand Up @@ -1303,21 +1302,6 @@ bool TypeBase::isObjCBool() {
return module->getName().is("ObjectiveC") && NTD->getName().is("ObjCBool");
}

bool TypeBase::isCxxString() {
auto *nominal = getAnyNominal();
if (!nominal)
return false;

auto *clangDecl =
dyn_cast_or_null<clang::CXXRecordDecl>(nominal->getClangDecl());
if (!clangDecl)
return false;

auto &ctx = nominal->getASTContext();
return clangDecl->isInStdNamespace() && clangDecl->getIdentifier() &&
ctx.Id_basic_string.is(clangDecl->getName());
}

bool TypeBase::isUnicodeScalar() {
if (!is<StructType>())
return false;
Expand Down
25 changes: 4 additions & 21 deletions lib/Sema/ConstraintSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
12 changes: 0 additions & 12 deletions test/Interop/Cxx/stdlib/Inputs/std-string.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,3 @@ struct HasMethodThatReturnsString {
};

inline std::string takesStringWithDefaultArg(std::string s = "abc") { return s; }

struct StringBox {
std::string value;

friend bool operator==(const StringBox &lhs, const std::string &rhs) {
return lhs.value == rhs;
}

friend bool operator==(const std::string &lhs, const StringBox &rhs) {
return rhs == lhs;
}
};

This file was deleted.