@@ -210,13 +210,24 @@ static void realizeTypeRequirement(Type subjectType, Type constraintType,
210
210
result.push_back ({req, loc, wasInferred});
211
211
}
212
212
213
- static void inferRequirements (Type type, SourceLoc loc,
214
- SmallVectorImpl<StructuralRequirement> &result) {
213
+ // / Infer requirements from applications of BoundGenericTypes to type
214
+ // / parameters. For example, given a function declaration
215
+ // /
216
+ // / func union<T>(_ x: Set<T>, _ y: Set<T>)
217
+ // /
218
+ // / We automatically infer 'T : Hashable' from the fact that 'struct Set'
219
+ // / declares a Hashable requirement on its generic parameter.
220
+ void swift::rewriting::inferRequirements (
221
+ Type type, SourceLoc loc,
222
+ SmallVectorImpl<StructuralRequirement> &result) {
215
223
// FIXME: Implement
216
224
}
217
225
218
- static void realizeRequirement (Requirement req, RequirementRepr *reqRepr, bool infer,
219
- SmallVectorImpl<StructuralRequirement> &result) {
226
+ // / Desugar a requirement and perform requirement inference if requested
227
+ // / to obtain zero or more structural requirements.
228
+ void swift::rewriting::realizeRequirement (
229
+ Requirement req, RequirementRepr *reqRepr, bool infer,
230
+ SmallVectorImpl<StructuralRequirement> &result) {
220
231
auto firstType = req.getFirstType ();
221
232
if (infer) {
222
233
auto firstLoc = (reqRepr ? reqRepr->getFirstTypeRepr ()->getStartLoc ()
@@ -269,8 +280,11 @@ static void realizeRequirement(Requirement req, RequirementRepr *reqRepr, bool i
269
280
}
270
281
}
271
282
272
- static void realizeInheritedRequirements (TypeDecl *decl, Type type, bool infer,
273
- SmallVectorImpl<StructuralRequirement> &result) {
283
+ // / Collect structural requirements written in the inheritance clause of an
284
+ // / AssociatedTypeDecl or GenericTypeParamDecl.
285
+ void swift::rewriting::realizeInheritedRequirements (
286
+ TypeDecl *decl, Type type, bool infer,
287
+ SmallVectorImpl<StructuralRequirement> &result) {
274
288
auto &ctx = decl->getASTContext ();
275
289
auto inheritedTypes = decl->getInherited ();
276
290
0 commit comments