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