Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -941,14 +941,14 @@ MaterializeVariable(SwiftASTManipulatorBase::VariableInfo &variable,
"actual_swift_type is a nullptr");

auto transformed_type =
actual_swift_type->transform([](swift::Type t) -> swift::Type {
if (auto *aliasTy =
swift::dyn_cast<swift::TypeAliasType>(t.getPointer())) {
if (aliasTy && aliasTy->getDecl()->isDebuggerAlias()) {
actual_swift_type->transformRec([](swift::TypeBase *t)
-> std::optional<swift::Type> {
if (auto *aliasTy = swift::dyn_cast<swift::TypeAliasType>(t)) {
if (aliasTy->getDecl()->isDebuggerAlias()) {
return aliasTy->getSinglyDesugaredType();
}
}
return t;
return std::nullopt;
});

if (!transformed_type)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
#include "swift/AST/ASTContext.h"
#include "swift/AST/ASTMangler.h"
#include "swift/AST/ASTWalker.h"
#include "swift/AST/Type.h"
#include "swift/AST/Types.h"
#include "swift/RemoteAST/RemoteAST.h"

using namespace lldb;
Expand Down Expand Up @@ -312,26 +314,29 @@ CompilerType SwiftLanguageRuntimeImpl::BindGenericTypeParametersRemoteAST(

// Rewrite all dynamic self types to their static self types.
target_swift_type =
target_swift_type.transform([](swift::Type type) -> swift::Type {
if (auto *dynamic_self =
llvm::dyn_cast<swift::DynamicSelfType>(type.getPointer()))
target_swift_type.transformRec([](swift::TypeBase *type)
-> std::optional<swift::Type> {
if (auto *dynamic_self = llvm::dyn_cast<swift::DynamicSelfType>(type))
return dynamic_self->getSelfType();
return type;
return std::nullopt;
});

// Thicken generic metatypes. Once substituted, they should always
// be thick. TypeRef::subst() does the same transformation.
target_swift_type =
target_swift_type.transform([](swift::Type type) -> swift::Type {
using namespace swift;
const auto thin = MetatypeRepresentation::Thin;
const auto thick = MetatypeRepresentation::Thick;
if (auto *metatype = dyn_cast<AnyMetatypeType>(type.getPointer()))
target_swift_type.transformRec([](swift::TypeBase *type)
-> std::optional<swift::Type> {
const auto thin = swift::MetatypeRepresentation::Thin;
const auto thick = swift::MetatypeRepresentation::Thick;
if (auto *metatype = swift::dyn_cast<swift::AnyMetatypeType>(type)) {
if (metatype->hasRepresentation() &&
metatype->getRepresentation() == thin &&
metatype->getInstanceType()->hasTypeParameter())
return MetatypeType::get(metatype->getInstanceType(), thick);
return type;
metatype->getInstanceType()->hasTypeParameter()) {
return swift::Type(swift::MetatypeType::get(
metatype->getInstanceType(), thick));
}
}
return std::nullopt;
});

while (target_swift_type->hasOpaqueArchetype()) {
Expand Down
11 changes: 6 additions & 5 deletions lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4690,14 +4690,15 @@ void SwiftASTContext::CacheDemangledTypeFailure(ConstString name) {
/// requires some more plumbing on the Swift side to properly handle generic
/// specializations.
static swift::Type ConvertSILFunctionTypesToASTFunctionTypes(swift::Type t) {
return t.transform([](swift::Type t) -> swift::Type {
if (auto *silFn = t->getAs<swift::SILFunctionType>()) {
return t.transformRec([](swift::TypeBase *t) -> std::optional<swift::Type> {
if (auto *silFn = swift::dyn_cast<swift::SILFunctionType>(t)) {
// FIXME: Verify ExtInfo state is correct, not working by accident.
swift::FunctionType::ExtInfo info;
return swift::FunctionType::get({}, t->getASTContext().TheEmptyTupleType,
info);
return swift::Type(
swift::FunctionType::get({}, t->getASTContext().TheEmptyTupleType,
info));
}
return t;
return std::nullopt;
});
}

Expand Down