Skip to content

Commit 4cd8313

Browse files
committed
Demangler: edge case in existential demangling
We now may have constrained existentials that have no primary associated types, so there won't be any arguments for the parameterized protocol type. Because the "constrained" part is that there's an inverse. resolves rdar://128695929 (cherry picked from commit b604488)
1 parent 47c7c2d commit 4cd8313

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

lib/AST/ASTDemangler.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -760,8 +760,18 @@ Type ASTBuilder::createConstrainedExistentialType(
760760
}
761761
args.push_back(argTy->getSecond());
762762
}
763-
Type constrainedBase =
764-
ParameterizedProtocolType::get(base->getASTContext(), baseTy, args);
763+
764+
Type constrainedBase;
765+
766+
// We may not have any arguments because the constrained existential is a
767+
// plain protocol with an inverse requirement.
768+
if (args.empty()) {
769+
constrainedBase =
770+
ProtocolType::get(baseDecl, baseTy, base->getASTContext());
771+
} else {
772+
constrainedBase =
773+
ParameterizedProtocolType::get(base->getASTContext(), baseTy, args);
774+
}
765775

766776
// Handle inverse requirements.
767777
if (!inverseRequirements.empty()) {

test/Interpreter/moveonly_existentials.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// RUN: %empty-directory(%t)
2-
// RUN: %target-build-swift %s -o %t/bin
2+
// RUN: %target-build-swift -g %s -o %t/bin
33
// RUN: %target-codesign %t/bin
44
// RUN: %target-run %t/bin | %FileCheck %s
55

0 commit comments

Comments
 (0)