@@ -4201,28 +4201,21 @@ class CompletionOverrideLookup : public swift::VisibleDeclConsumer {
42014201 // If resolved print it.
42024202 return nullptr ;
42034203
4204- // Collect requirements on the associatedtype.
4205- ProtocolDecl *protoD =
4206- ResultT->castTo <DependentMemberType>()->getAssocType ()->getProtocol ();
4204+ auto genericSig = VD->getDeclContext ()->getGenericSignatureOfContext ();
4205+
4206+ if (genericSig->isConcreteType (ResultT))
4207+ // If it has same type requrement, we will emit the concrete type.
4208+ return nullptr ;
42074209
4210+ // Collect requirements on the associatedtype.
42084211 SmallVector<Type, 2 > opaqueTypes;
42094212 bool hasExplicitAnyObject = false ;
4210- for (auto req : protoD->getRequirementSignature ()) {
4211- if (!req.getFirstType ()->isEqual (ResultT))
4212- continue ;
4213-
4214- switch (req.getKind ()) {
4215- case RequirementKind::Conformance:
4216- case RequirementKind::Superclass:
4217- opaqueTypes.push_back (req.getSecondType ());
4218- break ;
4219- case RequirementKind::Layout:
4220- hasExplicitAnyObject |= req.getLayoutConstraint ()->isClass ();
4221- break ;
4222- case RequirementKind::SameType:
4223- return nullptr ;
4224- }
4225- }
4213+ if (auto superTy = genericSig->getSuperclassBound (ResultT))
4214+ opaqueTypes.push_back (superTy);
4215+ for (auto proto : genericSig->getConformsTo (ResultT))
4216+ opaqueTypes.push_back (proto->getDeclaredInterfaceType ());
4217+ if (auto layout = genericSig->getLayoutConstraint (ResultT))
4218+ hasExplicitAnyObject = layout->isClass ();
42264219
42274220 if (!hasExplicitAnyObject) {
42284221 if (opaqueTypes.empty ())
0 commit comments