@@ -3734,15 +3734,19 @@ CustomAttrNominalRequest::evaluate(Evaluator &evaluator,
37343734 // If we found declarations that are associated types, look outside of
37353735 // the current context to see if we can recover.
37363736 if (declsAreAssociatedTypes (decls.first )) {
3737- if (auto typeRepr = attr->getTypeRepr ()) {
3738- if (auto identTypeRepr = dyn_cast<SimpleIdentTypeRepr>(typeRepr)) {
3737+ if (auto *unqualIdentRepr =
3738+ dyn_cast_or_null<UnqualifiedIdentTypeRepr>(attr->getTypeRepr ())) {
3739+ if (!unqualIdentRepr->hasGenericArgList ()) {
37393740 auto assocType = cast<AssociatedTypeDecl>(decls.first .front ());
37403741
3742+ const auto name = unqualIdentRepr->getNameRef ();
3743+ const auto nameLoc = unqualIdentRepr->getNameLoc ();
3744+ const auto loc = unqualIdentRepr->getLoc ();
3745+
37413746 modulesFound.clear ();
37423747 anyObject = false ;
37433748 decls = directReferencesForUnqualifiedTypeLookup (
3744- identTypeRepr->getNameRef (), identTypeRepr->getLoc (), dc,
3745- LookupOuterResults::Included);
3749+ name, loc, dc, LookupOuterResults::Included);
37463750 nominals = resolveTypeDeclsToNominal (evaluator, ctx, decls.first ,
37473751 ResolveToNominalOptions (),
37483752 modulesFound, anyObject);
@@ -3751,22 +3755,19 @@ CustomAttrNominalRequest::evaluate(Evaluator &evaluator,
37513755 if (nominal->getDeclContext ()->isModuleScopeContext ()) {
37523756 // Complain, producing module qualification in a Fix-It.
37533757 auto moduleName = nominal->getParentModule ()->getName ();
3754- ctx.Diags .diagnose (typeRepr->getLoc (),
3755- diag::warn_property_wrapper_module_scope,
3756- identTypeRepr->getNameRef (),
3757- moduleName)
3758- .fixItInsert (typeRepr->getLoc (),
3759- moduleName.str ().str () + " ." );
3758+ ctx.Diags
3759+ .diagnose (loc, diag::warn_property_wrapper_module_scope, name,
3760+ moduleName)
3761+ .fixItInsert (loc, moduleName.str ().str () + " ." );
37603762 ctx.Diags .diagnose (assocType, diag::kind_declname_declared_here,
37613763 assocType->getDescriptiveKind (),
37623764 assocType->getName ());
37633765
37643766 auto *baseTR = UnqualifiedIdentTypeRepr::create (
3765- ctx, identTypeRepr-> getNameLoc () , DeclNameRef (moduleName));
3767+ ctx, nameLoc , DeclNameRef (moduleName));
37663768
3767- auto *newTE = new (ctx) TypeExpr (
3768- MemberTypeRepr::create (ctx, baseTR, identTypeRepr->getNameLoc (),
3769- identTypeRepr->getNameRef ()));
3769+ auto *newTE = new (ctx)
3770+ TypeExpr (MemberTypeRepr::create (ctx, baseTR, nameLoc, name));
37703771 attr->resetTypeInformation (newTE);
37713772 return nominal;
37723773 }
0 commit comments