@@ -4238,28 +4238,21 @@ class CompletionOverrideLookup : public swift::VisibleDeclConsumer {
4238
4238
// If resolved print it.
4239
4239
return nullptr ;
4240
4240
4241
- // Collect requirements on the associatedtype.
4242
- ProtocolDecl *protoD =
4243
- ResultT->castTo <DependentMemberType>()->getAssocType ()->getProtocol ();
4241
+ auto genericSig = VD->getDeclContext ()->getGenericSignatureOfContext ();
4242
+
4243
+ if (genericSig->isConcreteType (ResultT))
4244
+ // If it has same type requrement, we will emit the concrete type.
4245
+ return nullptr ;
4244
4246
4247
+ // Collect requirements on the associatedtype.
4245
4248
SmallVector<Type, 2 > opaqueTypes;
4246
4249
bool hasExplicitAnyObject = false ;
4247
- for (auto req : protoD->getRequirementSignature ()) {
4248
- if (!req.getFirstType ()->isEqual (ResultT))
4249
- continue ;
4250
-
4251
- switch (req.getKind ()) {
4252
- case RequirementKind::Conformance:
4253
- case RequirementKind::Superclass:
4254
- opaqueTypes.push_back (req.getSecondType ());
4255
- break ;
4256
- case RequirementKind::Layout:
4257
- hasExplicitAnyObject |= req.getLayoutConstraint ()->isClass ();
4258
- break ;
4259
- case RequirementKind::SameType:
4260
- return nullptr ;
4261
- }
4262
- }
4250
+ if (auto superTy = genericSig->getSuperclassBound (ResultT))
4251
+ opaqueTypes.push_back (superTy);
4252
+ for (auto proto : genericSig->getConformsTo (ResultT))
4253
+ opaqueTypes.push_back (proto->getDeclaredInterfaceType ());
4254
+ if (auto layout = genericSig->getLayoutConstraint (ResultT))
4255
+ hasExplicitAnyObject = layout->isClass ();
4263
4256
4264
4257
if (!hasExplicitAnyObject) {
4265
4258
if (opaqueTypes.empty ())
0 commit comments