Skip to content

Commit b604488

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
1 parent 43ce060 commit b604488

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
@@ -783,8 +783,18 @@ Type ASTBuilder::createConstrainedExistentialType(
783783
}
784784
args.push_back(argTy->getSecond());
785785
}
786-
Type constrainedBase =
787-
ParameterizedProtocolType::get(base->getASTContext(), baseTy, args);
786+
787+
Type constrainedBase;
788+
789+
// We may not have any arguments because the constrained existential is a
790+
// plain protocol with an inverse requirement.
791+
if (args.empty()) {
792+
constrainedBase =
793+
ProtocolType::get(baseDecl, baseTy, base->getASTContext());
794+
} else {
795+
constrainedBase =
796+
ParameterizedProtocolType::get(base->getASTContext(), baseTy, args);
797+
}
788798

789799
// Handle inverse requirements.
790800
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)