@@ -2658,23 +2658,38 @@ namespace {
26582658 if (conformsToAttr == clangDecl->getAttrs ().end ())
26592659 return ;
26602660
2661- auto name = cast<clang::SwiftAttrAttr>(*conformsToAttr)
2662- ->getAttribute ()
2663- .drop_front (StringRef (" conforms_to:" ).size ())
2664- .str ();
2665-
2666- for (auto &module : Impl.SwiftContext .getLoadedModules ()) {
2667- module .second ->lookupValue (Impl.SwiftContext .getIdentifier (name),
2668- NLKind::UnqualifiedLookup, results);
2661+ auto conformsToValue = cast<clang::SwiftAttrAttr>(*conformsToAttr)
2662+ ->getAttribute ()
2663+ .drop_front (StringRef (" conforms_to:" ).size ())
2664+ .str ();
2665+ auto names = StringRef (conformsToValue).split (' .' );
2666+ auto moduleName = names.first ;
2667+ auto protocolName = names.second ;
2668+ if (protocolName.empty ()) {
2669+ HeaderLoc attrLoc ((*conformsToAttr)->getLocation ());
2670+ Impl.diagnose (attrLoc, diag::conforms_to_missing_dot, conformsToValue);
2671+ return ;
26692672 }
26702673
2674+ auto *mod = Impl.SwiftContext .getModuleByIdentifier (
2675+ Impl.SwiftContext .getIdentifier (moduleName));
2676+ if (!mod) {
2677+ HeaderLoc attrLoc ((*conformsToAttr)->getLocation ());
2678+ Impl.diagnose (attrLoc, diag::cannot_find_conforms_to_module,
2679+ conformsToValue, moduleName);
2680+ return ;
2681+ }
2682+ mod->lookupValue (Impl.SwiftContext .getIdentifier (protocolName),
2683+ NLKind::UnqualifiedLookup, results);
26712684 if (results.empty ()) {
26722685 HeaderLoc attrLoc ((*conformsToAttr)->getLocation ());
2673- Impl.diagnose (attrLoc, diag::cannot_find_conforms_to, name);
2686+ Impl.diagnose (attrLoc, diag::cannot_find_conforms_to, protocolName,
2687+ moduleName);
26742688 return ;
26752689 } else if (results.size () != 1 ) {
26762690 HeaderLoc attrLoc ((*conformsToAttr)->getLocation ());
2677- Impl.diagnose (attrLoc, diag::conforms_to_ambiguous, name);
2691+ Impl.diagnose (attrLoc, diag::conforms_to_ambiguous, protocolName,
2692+ moduleName);
26782693 return ;
26792694 }
26802695
@@ -2684,7 +2699,8 @@ namespace {
26842699 new (Impl.SwiftContext ) SynthesizedProtocolAttr (protocol, &Impl, false ));
26852700 } else {
26862701 HeaderLoc attrLoc ((*conformsToAttr)->getLocation ());
2687- Impl.diagnose (attrLoc, diag::conforms_to_not_protocol, name);
2702+ Impl.diagnose (attrLoc, diag::conforms_to_not_protocol,
2703+ result->getDescriptiveKind (), result, conformsToValue);
26882704 }
26892705 }
26902706
0 commit comments