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

**URL:** <https://forums.swift.org/t/se-0402-generalize-conformance-macros-as-extension-macros/65965>\
**Category:** Proposal Reviews\
**Tags:** macros\
**Created:** [July 3, 2023, 7:48pm UTC](https://forums.swift.org/t/se-0402-generalize-conformance-macros-as-extension-macros/65965 "2023-07-03T19:48:38Z")\
**Posts on this page:** 5\
**Page:** 2

<div class="post-metadata">

**Author:** ![hborla](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/hborla/32/27563_2.png) [@hborla](https://forums.swift.org/u/hborla)\
**Post date:** [July 14, 2023, 5:02pm UTC](https://forums.swift.org/t/se-0402-generalize-conformance-macros-as-extension-macros/65965/21 "2023-07-14T17:02:27Z")

</div>

> [@soumyamahunt](#):
>
> If in previous case macro generates `Codable` conformances, will it have any context regarding `SuperClass` implementations i.e macro will be able to override `SuperClass` implementation and invoke `super` implementations in the overrides.

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

---

<div class="post-metadata">

**Author:** ![soumyamahunt](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/soumyamahunt/32/23427_2.png) [@soumyamahunt](https://forums.swift.org/u/soumyamahunt)\
**Post date:** [July 17, 2023, 3:54am UTC](https://forums.swift.org/t/se-0402-generalize-conformance-macros-as-extension-macros/65965/22 "2023-07-17T03:54:24Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![hborla](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/hborla/32/27563_2.png) [@hborla](https://forums.swift.org/u/hborla)\
**Post date:** [July 17, 2023, 5:25am UTC](https://forums.swift.org/t/se-0402-generalize-conformance-macros-as-extension-macros/65965/23 "2023-07-17T05:25:21Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![John\_McCall](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/john_mccall/32/1351_2.png) [@John\_McCall](https://forums.swift.org/u/John_McCall)\
**Post date:** [July 20, 2023, 7:37pm UTC](https://forums.swift.org/t/se-0402-generalize-conformance-macros-as-extension-macros/65965/24 "2023-07-20T19:37:41Z")

</div>

SE-0402 has been [accepted](https://forums.swift.org/t/accepted-se-0402-generalize-conformance-macros-as-extension-macros/66276); thank you all for participating in this review.

John McCall  
Review Manager

---

<div class="post-metadata">

**Author:** ![John\_McCall](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/john_mccall/32/1351_2.png) [@John\_McCall](https://forums.swift.org/u/John_McCall)\
**Post date:** [July 20, 2023, 7:37pm UTC](https://forums.swift.org/t/se-0402-generalize-conformance-macros-as-extension-macros/65965/25 "2023-07-20T19:37:47Z")

</div>

Closed on July 20, 2023, 7:37pm UTC



[Previous page](https://forums.swift.org/t/se-0402-generalize-conformance-macros-as-extension-macros/65965.md?page=1)
