Skip to content

Commit f8b293e

Browse files
committed
GSB: RequirementRHS can now store a ProtocolDecl *
1 parent 0836707 commit f8b293e

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

include/swift/AST/GenericSignatureBuilder.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ class GenericSignatureBuilder {
9595
llvm::PointerUnion<Type, PotentialArchetype *, LayoutConstraint>;
9696

9797
using RequirementRHS =
98-
llvm::PointerUnion<Type, LayoutConstraint>;
98+
llvm::PointerUnion<Type, ProtocolDecl *, LayoutConstraint>;
9999

100100
/// The location of a requirement as written somewhere in the source.
101101
typedef llvm::PointerUnion<const TypeRepr *, const RequirementRepr *>

lib/AST/GenericSignatureBuilder.cpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6926,26 +6926,29 @@ void GenericSignatureBuilder::enumerateRequirements(
69266926
SmallVectorImpl<Requirement> &requirements) {
69276927
auto recordRequirement = [&](RequirementKind kind,
69286928
Type depTy,
6929-
RequirementRHS type) {
6929+
RequirementRHS rhs) {
69306930
depTy = getSugaredDependentType(depTy, genericParams);
69316931

6932-
if (auto concreteTy = type.dyn_cast<Type>()) {
6933-
if (concreteTy->hasError())
6932+
if (auto type = rhs.dyn_cast<Type>()) {
6933+
if (type->hasError())
69346934
return;
69356935

69366936
// Drop requirements involving concrete types containing
69376937
// unresolved associated types.
6938-
if (concreteTy->findUnresolvedDependentMemberType()) {
6938+
if (type->findUnresolvedDependentMemberType()) {
69396939
assert(Impl->HadAnyError);
69406940
return;
69416941
}
69426942

6943-
if (concreteTy->isTypeParameter())
6944-
concreteTy = getSugaredDependentType(concreteTy, genericParams);
6943+
if (type->isTypeParameter())
6944+
type = getSugaredDependentType(type, genericParams);
69456945

6946-
requirements.push_back(Requirement(kind, depTy, concreteTy));
6946+
requirements.push_back(Requirement(kind, depTy, type));
6947+
} else if (auto *proto = rhs.dyn_cast<ProtocolDecl *>()) {
6948+
auto type = proto->getDeclaredInterfaceType();
6949+
requirements.push_back(Requirement(kind, depTy, type));
69476950
} else {
6948-
auto layoutConstraint = type.get<LayoutConstraint>();
6951+
auto layoutConstraint = rhs.get<LayoutConstraint>();
69496952
requirements.push_back(Requirement(kind, depTy, layoutConstraint));
69506953
return;
69516954
}
@@ -7079,8 +7082,7 @@ void GenericSignatureBuilder::enumerateRequirements(
70797082

70807083
// Enumerate the conformance requirements.
70817084
for (auto proto : protocols) {
7082-
recordRequirement(RequirementKind::Conformance, subjectType,
7083-
proto->getDeclaredInterfaceType());
7085+
recordRequirement(RequirementKind::Conformance, subjectType, proto);
70847086
}
70857087
}
70867088

0 commit comments

Comments
 (0)