Skip to content

Commit a68039e

Browse files
committed
Sema: Stash the ProtocolDecl inside the LiteralRequirement
1 parent 5e3a55d commit a68039e

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

include/swift/Sema/CSBindings.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,8 @@ struct PotentialBinding {
152152
};
153153

154154
struct LiteralRequirement {
155+
/// The literal protocol.
156+
ProtocolDecl *Protocol;
155157
/// The source of the literal requirement.
156158
Constraint *Source;
157159
/// The default type associated with this literal (if any).
@@ -164,12 +166,14 @@ struct LiteralRequirement {
164166
/// this points to the source of the binding.
165167
mutable Constraint *CoveredBy = nullptr;
166168

167-
LiteralRequirement(Constraint *source, Type defaultTy, bool isDirect)
168-
: Source(source), DefaultType(defaultTy), IsDirectRequirement(isDirect) {}
169+
LiteralRequirement(ProtocolDecl *protocol, Constraint *source,
170+
Type defaultTy, bool isDirect)
171+
: Protocol(protocol), Source(source), DefaultType(defaultTy),
172+
IsDirectRequirement(isDirect) {}
169173

170174
Constraint *getSource() const { return Source; }
171175

172-
ProtocolDecl *getProtocol() const { return Source->getProtocol(); }
176+
ProtocolDecl *getProtocol() const { return Protocol; }
173177

174178
bool isCovered() const { return bool(CoveredBy); }
175179

lib/Sema/CSBindings.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1070,7 +1070,7 @@ void BindingSet::addLiteralRequirement(Constraint *constraint) {
10701070
defaultType = TypeChecker::getDefaultType(protocol, CS.DC);
10711071
}
10721072

1073-
LiteralRequirement literal(constraint, defaultType, isDirect);
1073+
LiteralRequirement literal(protocol, constraint, defaultType, isDirect);
10741074
Literals.insert({protocol, std::move(literal)});
10751075
}
10761076

0 commit comments

Comments
 (0)