Skip to content

Fix a round trip debug type failure with typealias #67051

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 7, 2023
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
7 changes: 4 additions & 3 deletions lib/IRGen/IRGenDebugInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,11 @@ class EqualUpToClangTypes
};

static bool equalWithoutExistentialTypes(Type t1, Type t2) {
auto withoutExistentialTypes = [](Type type) -> Type {
static Type (*withoutExistentialTypes)(Type) = [](Type type) -> Type {
return type.transform([](Type type) -> Type {
if (auto existential = type->getAs<ExistentialType>())
return existential->getConstraintType();
if (auto existential = type->getAs<ExistentialType>()) {
return withoutExistentialTypes(existential->getConstraintType());
}
return type;
});
};
Expand Down
10 changes: 10 additions & 0 deletions test/IRGen/round-trip-debug-types-typealias.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// RUN: %target-build-swift -g %s

// https://github.com/apple/swift/issues/66554
// IRGenDebugInfo type reconstruction crash because existential types
// inside typealias are not taken into account when comparing type
// equality

protocol Protocol<T> { associatedtype T }
typealias AnyProtocol<T> = any Protocol<T>
let crash: AnyProtocol<Any?>