@@ -4238,92 +4238,90 @@ ConstraintResult GenericSignatureBuilder::expandConformanceRequirement(
4238
4238
};
4239
4239
4240
4240
// Add requirements for each of the associated types.
4241
- for (auto Member : proto->getMembers ()) {
4242
- if (auto assocTypeDecl = dyn_cast<AssociatedTypeDecl>(Member)) {
4243
- // Add requirements placed directly on this associated type.
4244
- Type assocType =
4245
- DependentMemberType::get (selfType.getDependentType (*this ), assocTypeDecl);
4246
- if (!onlySameTypeConstraints) {
4247
- auto assocResult =
4248
- addInheritedRequirements (assocTypeDecl, assocType, source,
4249
- /* inferForModule=*/ nullptr );
4250
- if (isErrorResult (assocResult))
4251
- return assocResult;
4252
- }
4253
-
4254
- // Add requirements from this associated type's where clause.
4255
- RequirementRequest::visitRequirements (assocTypeDecl,
4256
- TypeResolutionStage::Structural,
4257
- [&](const Requirement &req, RequirementRepr *reqRepr) {
4258
- // If we're only looking at same-type constraints, skip everything else.
4259
- if (onlySameTypeConstraints &&
4260
- req.getKind () != RequirementKind::SameType)
4261
- return false ;
4262
-
4263
- auto innerSource = FloatingRequirementSource::viaProtocolRequirement (
4264
- source, proto, reqRepr, /* inferred=*/ false );
4265
- addRequirement (req, reqRepr, innerSource, &protocolSubMap,
4266
- /* inferForModule=*/ nullptr );
4241
+ for (auto assocTypeDecl : proto->getAssociatedTypeMembers ()) {
4242
+ // Add requirements placed directly on this associated type.
4243
+ Type assocType =
4244
+ DependentMemberType::get (selfType.getDependentType (*this ), assocTypeDecl);
4245
+ if (!onlySameTypeConstraints) {
4246
+ auto assocResult =
4247
+ addInheritedRequirements (assocTypeDecl, assocType, source,
4248
+ /* inferForModule=*/ nullptr );
4249
+ if (isErrorResult (assocResult))
4250
+ return assocResult;
4251
+ }
4252
+
4253
+ // Add requirements from this associated type's where clause.
4254
+ RequirementRequest::visitRequirements (assocTypeDecl,
4255
+ TypeResolutionStage::Structural,
4256
+ [&](const Requirement &req, RequirementRepr *reqRepr) {
4257
+ // If we're only looking at same-type constraints, skip everything else.
4258
+ if (onlySameTypeConstraints &&
4259
+ req.getKind () != RequirementKind::SameType)
4267
4260
return false ;
4268
- });
4269
-
4270
- // Check whether we inherited any types with the same name.
4271
- auto knownInherited =
4272
- inheritedTypeDecls.find (assocTypeDecl->getFullName ());
4273
- if (knownInherited == inheritedTypeDecls.end ()) continue ;
4274
-
4275
- bool shouldWarnAboutRedeclaration =
4276
- source->kind == RequirementSource::RequirementSignatureSelf &&
4277
- !assocTypeDecl->getAttrs ().hasAttribute <NonOverrideAttr>() &&
4278
- !assocTypeDecl->getAttrs ().hasAttribute <OverrideAttr>() &&
4279
- !assocTypeDecl->hasDefaultDefinitionType () &&
4280
- (!assocTypeDecl->getInherited ().empty () ||
4281
- assocTypeDecl->getTrailingWhereClause () ||
4282
- getASTContext ().LangOpts .WarnImplicitOverrides );
4283
- for (auto inheritedType : knownInherited->second ) {
4284
- // If we have inherited associated type...
4285
- if (auto inheritedAssocTypeDecl =
4286
- dyn_cast<AssociatedTypeDecl>(inheritedType)) {
4287
- // Complain about the first redeclaration.
4288
- if (shouldWarnAboutRedeclaration) {
4289
- auto inheritedFromProto = inheritedAssocTypeDecl->getProtocol ();
4290
- auto fixItWhere = getProtocolWhereLoc ();
4291
- Diags.diagnose (assocTypeDecl,
4292
- diag::inherited_associated_type_redecl,
4293
- assocTypeDecl->getFullName (),
4294
- inheritedFromProto->getDeclaredInterfaceType ())
4295
- .fixItInsertAfter (
4296
- fixItWhere.first ,
4297
- getAssociatedTypeReqs (assocTypeDecl, fixItWhere.second ))
4298
- .fixItRemove (assocTypeDecl->getSourceRange ());
4299
-
4300
- Diags.diagnose (inheritedAssocTypeDecl, diag::decl_declared_here,
4301
- inheritedAssocTypeDecl->getFullName ());
4302
-
4303
- shouldWarnAboutRedeclaration = false ;
4304
- }
4305
4261
4306
- continue ;
4307
- }
4262
+ auto innerSource = FloatingRequirementSource::viaProtocolRequirement (
4263
+ source, proto, reqRepr, /* inferred=*/ false );
4264
+ addRequirement (req, reqRepr, innerSource, &protocolSubMap,
4265
+ /* inferForModule=*/ nullptr );
4266
+ return false ;
4267
+ });
4308
4268
4309
- // We inherited a type; this associated type will be identical
4310
- // to that typealias.
4311
- if (source->kind == RequirementSource::RequirementSignatureSelf) {
4312
- auto inheritedOwningDecl =
4313
- inheritedType->getDeclContext ()->getSelfNominalTypeDecl ();
4269
+ // Check whether we inherited any types with the same name.
4270
+ auto knownInherited =
4271
+ inheritedTypeDecls.find (assocTypeDecl->getFullName ());
4272
+ if (knownInherited == inheritedTypeDecls.end ()) continue ;
4273
+
4274
+ bool shouldWarnAboutRedeclaration =
4275
+ source->kind == RequirementSource::RequirementSignatureSelf &&
4276
+ !assocTypeDecl->getAttrs ().hasAttribute <NonOverrideAttr>() &&
4277
+ !assocTypeDecl->getAttrs ().hasAttribute <OverrideAttr>() &&
4278
+ !assocTypeDecl->hasDefaultDefinitionType () &&
4279
+ (!assocTypeDecl->getInherited ().empty () ||
4280
+ assocTypeDecl->getTrailingWhereClause () ||
4281
+ getASTContext ().LangOpts .WarnImplicitOverrides );
4282
+ for (auto inheritedType : knownInherited->second ) {
4283
+ // If we have inherited associated type...
4284
+ if (auto inheritedAssocTypeDecl =
4285
+ dyn_cast<AssociatedTypeDecl>(inheritedType)) {
4286
+ // Complain about the first redeclaration.
4287
+ if (shouldWarnAboutRedeclaration) {
4288
+ auto inheritedFromProto = inheritedAssocTypeDecl->getProtocol ();
4289
+ auto fixItWhere = getProtocolWhereLoc ();
4314
4290
Diags.diagnose (assocTypeDecl,
4315
- diag::associated_type_override_typealias ,
4291
+ diag::inherited_associated_type_redecl ,
4316
4292
assocTypeDecl->getFullName (),
4317
- inheritedOwningDecl->getDescriptiveKind (),
4318
- inheritedOwningDecl->getDeclaredInterfaceType ());
4293
+ inheritedFromProto->getDeclaredInterfaceType ())
4294
+ .fixItInsertAfter (
4295
+ fixItWhere.first ,
4296
+ getAssociatedTypeReqs (assocTypeDecl, fixItWhere.second ))
4297
+ .fixItRemove (assocTypeDecl->getSourceRange ());
4298
+
4299
+ Diags.diagnose (inheritedAssocTypeDecl, diag::decl_declared_here,
4300
+ inheritedAssocTypeDecl->getFullName ());
4301
+
4302
+ shouldWarnAboutRedeclaration = false ;
4319
4303
}
4320
4304
4321
- addInferredSameTypeReq (assocTypeDecl, inheritedType);
4305
+ continue ;
4306
+ }
4307
+
4308
+ // We inherited a type; this associated type will be identical
4309
+ // to that typealias.
4310
+ if (source->kind == RequirementSource::RequirementSignatureSelf) {
4311
+ auto inheritedOwningDecl =
4312
+ inheritedType->getDeclContext ()->getSelfNominalTypeDecl ();
4313
+ Diags.diagnose (assocTypeDecl,
4314
+ diag::associated_type_override_typealias,
4315
+ assocTypeDecl->getFullName (),
4316
+ inheritedOwningDecl->getDescriptiveKind (),
4317
+ inheritedOwningDecl->getDeclaredInterfaceType ());
4322
4318
}
4323
4319
4324
- inheritedTypeDecls.erase (knownInherited);
4325
- continue ;
4320
+ addInferredSameTypeReq (assocTypeDecl, inheritedType);
4326
4321
}
4322
+
4323
+ inheritedTypeDecls.erase (knownInherited);
4324
+ continue ;
4327
4325
}
4328
4326
4329
4327
// Check all remaining inherited type declarations to determine if
0 commit comments