Skip to content

Commit fda6f9b

Browse files
committed
Fix a round trip debug type failure with typealias
When checking equality of types with existential types removed, recursively remove existential types inside an existential type. Fixes: #66554
1 parent 12ebe0a commit fda6f9b

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

lib/IRGen/IRGenDebugInfo.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,11 @@ class EqualUpToClangTypes
9898
};
9999

100100
static bool equalWithoutExistentialTypes(Type t1, Type t2) {
101-
auto withoutExistentialTypes = [](Type type) -> Type {
101+
static Type (*withoutExistentialTypes)(Type) = [](Type type) -> Type {
102102
return type.transform([](Type type) -> Type {
103-
if (auto existential = type->getAs<ExistentialType>())
104-
return existential->getConstraintType();
103+
if (auto existential = type->getAs<ExistentialType>()) {
104+
return withoutExistentialTypes(existential->getConstraintType());
105+
}
105106
return type;
106107
});
107108
};
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// RUN: %target-build-swift -g %s
2+
3+
// https://github.com/apple/swift/issues/66554
4+
// IRGenDebugInfo type reconstruction crash because existential types
5+
// inside typealias are not taken into account when comparing type
6+
// equality
7+
8+
protocol Protocol<T> { associatedtype T }
9+
typealias AnyProtocol<T> = any Protocol<T>
10+
let crash: AnyProtocol<Any?>

0 commit comments

Comments
 (0)