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
SuperClassconforms toCodableand a new classSubClassthat inherits fromSuperClass, has an extension macro that generatesCodableconformances. In this case will the macro generate new conformance orprotocolsarray received inexpansionAPI 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 theconformances: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.
SE-0402 has been accepted; thank you all for participating in this review.
John McCall
Review Manager