SE-0402: Generalize `conformance` macros as `extension` macros

Superclass methods cannot be overridden in subclass extensions, so extension macros are not the right tool for overriding.

That's a good point, extensions can't have override declarations, but what about the first point:

Lets suppose a class SuperClass conforms to Codable and a new class SubClass that inherits from SuperClass , has an extension macro that generates Codable conformances. In this case will the macro generate new conformance or protocols array received in expansion API will be empty here?

What will be the behaviour in this scenario?

From the proposal:

The conformingTo: argument array will contain only the protocols from the conformances: list in @attached(extension conformances:) that the type does not already conform to in the original source code, including through implied conformances or class inheritance.

So, if you have a class SuperClass that states a conformance to Codable, and you attach an extension macro that specifies conformances: Codable to an extension of a class SubClass that inherits from SuperClass, the conformingTo: argument will be empty because both Encodable and Decodable are implied through inheritance.

1 Like

SE-0402 has been accepted; thank you all for participating in this review.

John McCall
Review Manager

2 Likes