@@ -4201,28 +4201,21 @@ class CompletionOverrideLookup : public swift::VisibleDeclConsumer {
4201
4201
// If resolved print it.
4202
4202
return nullptr ;
4203
4203
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 ;
4207
4209
4210
+ // Collect requirements on the associatedtype.
4208
4211
SmallVector<Type, 2 > opaqueTypes;
4209
4212
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 ();
4226
4219
4227
4220
if (!hasExplicitAnyObject) {
4228
4221
if (opaqueTypes.empty ())
0 commit comments