Skip to content

0.3.0

Latest

Choose a tag to compare

@WendellXY WendellXY released this 25 Sep 05:35

Custom properties move to a new @DescribableProperties macro. This fixes a failure that 0.2.0 introduced on types whose Equatable conformance can't be synthesized. This release also removes optional-interpolation warnings from member-path placeholders.

.package(url: "https://github.com/WendellXY/Description.git", from: "0.3.0")

Fixed

  • Equatable failure with @Describable (0.2.0 regression). On a type whose Equatable conformance can't be synthesized, such as an enum with a closure payload and a hand-written ==, adding @Describable failed with "type does not conform to protocol 'Equatable'" and the same == listed twice. The cause is a compiler bug triggered by macros that declare arbitrary member names, which 0.2.0 added so it could generate custom properties. @Describable now declares only its fixed names, and the case from the report is kept as a regression test.
  • Optional-interpolation warnings from member paths. Placeholders such as {locator.storeType}, and raw expressions such as {_0.productType}, no longer produce "string interpolation produces a debug description for an optional value" when the property at the end of the path is optional. The printed text is unchanged.

Breaking change

Custom properties (@Description("name", …) or .property("name")) now need @DescribableProperties next to @Describable:

@Describable
@DescribableProperties
enum Screen: AnalyticsNaming {
    @Description("analyticsName", "chat_room")
    case chat(roomId: Int)
}

Without it, the compiler reports "custom description property 'analyticsName' requires @DescribableProperties", with a fix-it that adds the macro. Types without custom properties need no changes.

Requirements: Swift 6.0 or later, and swift-syntax 600 through 604. Tested on macOS and on Linux with Swift 6.0, 6.1, and 6.2.