Skip to content

Expressions, Extensions, and a Better Renderer

Choose a tag to compare

@theoriginalbit theoriginalbit released this 21 Oct 09:45
· 10 commits to main since this release

Note

The package now requires Swift tools version 6.1 to be available.

New source-generation capabilities

  • Describe extensions, including added conformances, generic where requirements, members, and default access levels.
  • Represent new expressions; tuple, member-access, function calls, and if/else if/else expressions.
  • Render try, await, throw, break, and continue statements.
  • Add generic parameters to typealiases.

Tweaks

  • Initialisers and conveniences for guard, if, and return that were erroneously internal have now been made public.

More correct and consistent output

  • Render special Double values such as infinity and NaN as valid Swift expressions.
  • Sanitise identifiers according to their syntactic position, improving output for keywords and other special identifiers.
  • Improve whitespace and punctuation handling, including compacting empty blocks, and fix protocol subscript rendering.
  • Remove duplicate generic parameters, conformances, type constraints, type-alias composition types, and attributes while preserving their first occurrence.
  • Rendering hot paths are now more efficient.

Migration notes

  • The dependency on swift-collections has been removed1.
    • Public collection APIs that used OrderedSet now use arrays; duplicate entries are still omitted from rendered output.
  • TypeMemberDescriptor and TypeMembersBuilder are replaced by DeclarationDescriptor and DeclarationBuilder.
  • SwiftFile.declarations now uses TopLevelDeclarationDescriptor so it can include extensions which are only valid at the file scope; update code that explicitly constructs or switches over these values.
  • Replace .stored(isMutable: true, ...) / .stored(isMutable: false, ...) with .stored(.var, ...) / .stored(.let, ...).
  • Replace ProtocolAssociatedtypeDescriptor(..., sameTypeAs: ...) with defaultType: for associated-type defaults.
  • AccessModifierDescriptor.open was removed until class descriptors are added.

  1. Generic parameters, conformances, and type compositions have changed from OrderedSet to Array. ↩