Skip to content

1.4.0

Latest

Choose a tag to compare

@yysskk yysskk released this 17 Jul 21:33
a7dba1a

This release surfaces the initializer that the generated copying method depends on: a warning — with a Fix-It that writes it for you — when the annotated type declares no matching initializer, or declares one that is init?, throwing, or async. It also publishes the API documentation to GitHub Pages.

Added

  • The rendered API documentation is now published to GitHub Pages at https://yysskk.github.io/swift-copying/documentation/copying, built from the DocC catalog on every push to main.
  • A warning that names the initializer copying needs, such as init(id:username:isActive:), when the annotated declaration does not appear to declare one. Forgetting it previously surfaced only as an argument-label error inside the generated code, which did not say what was wrong. A class or actor is always checked, and so is a struct that suppresses its memberwise initializer by declaring an initializer of its own. It is a warning rather than an error because an initializer added in an extension or inherited from a superclass also satisfies the call but is invisible to a macro.
  • A warning on an initializer that takes the copied properties but is init?, throwing, or async, since copying calls it as a plain expression. This too previously surfaced only inside the generated code, as an unwrapping, try, or await error. An init! is accepted: its result unwraps implicitly, so the call compiles.
  • A Fix-It on the warning above that writes the missing initializer into the declaration, assigning each copied property and matching the access level of the generated method. It is offered only when no initializer is visible: an initializer that takes the right arguments but is init? or throwing has to be changed rather than joined by another, since Swift rejects a plain overload of one as a redeclaration.

Full Changelog: 1.3.0...1.4.0