@@ -1276,34 +1276,14 @@ swift::expandConformances(CustomAttr *attr, MacroDecl *macro,
12761276 if (!extension)
12771277 continue ;
12781278
1279- auto &extensionCtx = extension->getASTContext ();
1280-
12811279 // Bind the extension to the original nominal type.
12821280 extension->setExtendedNominal (nominal);
1281+ nominal->addExtension (extension);
12831282
1284- // Resolve the protocol type.
1285- assert (extension->getInherited ().size () == 1 );
1286- auto inheritedType = evaluateOrDefault (
1287- extensionCtx.evaluator ,
1288- InheritedTypeRequest{extension, 0 , TypeResolutionStage::Interface},
1289- Type ());
1290-
1291- if (!inheritedType || inheritedType->hasError ())
1292- continue ;
1293-
1294- auto protocolType = inheritedType->getAs <ProtocolType>();
1295- if (!protocolType)
1296- continue ;
1297-
1298- // Create a synthesized conformance and register it with the nominal type.
1299- auto conformance = extensionCtx.getConformance (
1300- nominal->getDeclaredInterfaceType (), protocolType->getDecl (),
1301- nominal->getLoc (), extension, ProtocolConformanceState::Incomplete,
1302- /* isUnchecked=*/ false );
1303- conformance->setSourceKindAndImplyingConformance (
1304- ConformanceEntryKind::Synthesized, nullptr );
1305-
1306- nominal->registerProtocolConformance (conformance, /* synthesized=*/ true );
1283+ // Make it accessible to getTopLevelDecls()
1284+ if (auto file = dyn_cast<FileUnit>(
1285+ decl->getDeclContext ()->getModuleScopeContext ()))
1286+ file->getOrCreateSynthesizedFile ().addTopLevelDecl (extension);
13071287 }
13081288
13091289 return macroSourceFile->getBufferID ();
0 commit comments