Skip to content

Commit 3d22ac7

Browse files
committed
[Swift] Update for removal of Type::transform()
1 parent 8abe125 commit 3d22ac7

File tree

3 files changed

+28
-22
lines changed

3 files changed

+28
-22
lines changed

lldb/source/Plugins/ExpressionParser/Swift/SwiftExpressionParser.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -941,14 +941,14 @@ MaterializeVariable(SwiftASTManipulatorBase::VariableInfo &variable,
941941
"actual_swift_type is a nullptr");
942942

943943
auto transformed_type =
944-
actual_swift_type->transform([](swift::Type t) -> swift::Type {
945-
if (auto *aliasTy =
946-
swift::dyn_cast<swift::TypeAliasType>(t.getPointer())) {
947-
if (aliasTy && aliasTy->getDecl()->isDebuggerAlias()) {
944+
actual_swift_type->transformRec([](swift::TypeBase *t)
945+
-> std::optional<swift::Type> {
946+
if (auto *aliasTy = swift::dyn_cast<swift::TypeAliasType>(t)) {
947+
if (aliasTy->getDecl()->isDebuggerAlias()) {
948948
return aliasTy->getSinglyDesugaredType();
949949
}
950950
}
951-
return t;
951+
return std::nullopt;
952952
});
953953

954954
if (!transformed_type)

lldb/source/Plugins/LanguageRuntime/Swift/SwiftLanguageRuntimeRemoteAST.cpp

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
#include "swift/AST/ASTContext.h"
1919
#include "swift/AST/ASTMangler.h"
2020
#include "swift/AST/ASTWalker.h"
21+
#include "swift/AST/Type.h"
22+
#include "swift/AST/Types.h"
2123
#include "swift/RemoteAST/RemoteAST.h"
2224

2325
using namespace lldb;
@@ -312,26 +314,29 @@ CompilerType SwiftLanguageRuntimeImpl::BindGenericTypeParametersRemoteAST(
312314

313315
// Rewrite all dynamic self types to their static self types.
314316
target_swift_type =
315-
target_swift_type.transform([](swift::Type type) -> swift::Type {
316-
if (auto *dynamic_self =
317-
llvm::dyn_cast<swift::DynamicSelfType>(type.getPointer()))
317+
target_swift_type.transformRec([](swift::TypeBase *type)
318+
-> std::optional<swift::Type> {
319+
if (auto *dynamic_self = llvm::dyn_cast<swift::DynamicSelfType>(type))
318320
return dynamic_self->getSelfType();
319-
return type;
321+
return std::nullopt;
320322
});
321323

322324
// Thicken generic metatypes. Once substituted, they should always
323325
// be thick. TypeRef::subst() does the same transformation.
324326
target_swift_type =
325-
target_swift_type.transform([](swift::Type type) -> swift::Type {
326-
using namespace swift;
327-
const auto thin = MetatypeRepresentation::Thin;
328-
const auto thick = MetatypeRepresentation::Thick;
329-
if (auto *metatype = dyn_cast<AnyMetatypeType>(type.getPointer()))
327+
target_swift_type.transformRec([](swift::TypeBase *type)
328+
-> std::optional<swift::Type> {
329+
const auto thin = swift::MetatypeRepresentation::Thin;
330+
const auto thick = swift::MetatypeRepresentation::Thick;
331+
if (auto *metatype = swift::dyn_cast<swift::AnyMetatypeType>(type)) {
330332
if (metatype->hasRepresentation() &&
331333
metatype->getRepresentation() == thin &&
332-
metatype->getInstanceType()->hasTypeParameter())
333-
return MetatypeType::get(metatype->getInstanceType(), thick);
334-
return type;
334+
metatype->getInstanceType()->hasTypeParameter()) {
335+
return swift::Type(swift::MetatypeType::get(
336+
metatype->getInstanceType(), thick));
337+
}
338+
}
339+
return std::nullopt;
335340
});
336341

337342
while (target_swift_type->hasOpaqueArchetype()) {

lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4652,14 +4652,15 @@ void SwiftASTContext::CacheDemangledTypeFailure(ConstString name) {
46524652
/// requires some more plumbing on the Swift side to properly handle generic
46534653
/// specializations.
46544654
static swift::Type ConvertSILFunctionTypesToASTFunctionTypes(swift::Type t) {
4655-
return t.transform([](swift::Type t) -> swift::Type {
4656-
if (auto *silFn = t->getAs<swift::SILFunctionType>()) {
4655+
return t.transformRec([](swift::TypeBase *t) -> std::optional<swift::Type> {
4656+
if (auto *silFn = swift::dyn_cast<swift::SILFunctionType>(t)) {
46574657
// FIXME: Verify ExtInfo state is correct, not working by accident.
46584658
swift::FunctionType::ExtInfo info;
4659-
return swift::FunctionType::get({}, t->getASTContext().TheEmptyTupleType,
4660-
info);
4659+
return swift::Type(
4660+
swift::FunctionType::get({}, t->getASTContext().TheEmptyTupleType,
4661+
info));
46614662
}
4662-
return t;
4663+
return std::nullopt;
46634664
});
46644665
}
46654666

0 commit comments

Comments
 (0)