Skip to content
VIRAJ

Case OS · Open source / Swift

Swift Compiler

A printed setter should keep its access level

  • SWIFT
  • COMPILER
  • MERGED

The issue

Module interfaces hide a less accessible setter by leaving it out of the accessor list. But when the setter was still printed — @inlinable, @usableFromInline, or a package(set) setter in a package interface — its access modifier was dropped. Clients building against the .swiftinterface could call an internal(set) setter that the binary .swiftmodule rejects, and public internal(set) var x { get; @usableFromInline set } produced an interface that failed verification. Tracked as swift#93893.

The fix

ASTPrinter now prints the setter's access level whenever the setter appears in the accessor list. Simply stored properties are unchanged and still print as { get }. Tests extend ModuleInterface/access-filter.swift and ModuleInterface/package_interface.swift.

Technology

  • Swift
  • C++
  • ASTPrinter
  • Module interfaces