mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[Macros] Allow extension macros to suppress conformances that are already
stated in the original source. If an extension macro can introduce protocol conformances, macro expansion will check which of those protocols already have a stated conformance in the original source. The protocols that don't will be passed as arguments to extension macro expansion, indicating to the macro that it should only add conformances to those protocols.
This commit is contained in:
@@ -1961,6 +1961,17 @@ LookupConformanceInModuleRequest::evaluate(
|
||||
if (!nominal || isa<ProtocolDecl>(nominal))
|
||||
return ProtocolConformanceRef::forMissingOrInvalid(type, protocol);
|
||||
|
||||
// Expand conformances added by extension macros.
|
||||
//
|
||||
// FIXME: This expansion should only be done if the
|
||||
// extension macro can generate a conformance to the
|
||||
// given protocol, but conformance macros do not specify
|
||||
// that information upfront.
|
||||
(void)evaluateOrDefault(
|
||||
ctx.evaluator,
|
||||
ExpandExtensionMacros{nominal},
|
||||
{ });
|
||||
|
||||
// Find the (unspecialized) conformance.
|
||||
SmallVector<ProtocolConformance *, 2> conformances;
|
||||
if (!nominal->lookupConformance(protocol, conformances)) {
|
||||
|
||||
Reference in New Issue
Block a user