swiftshield icon indicating copy to clipboard operation
swiftshield copied to clipboard

Public static var/func not identified as public if exported to objc

Open strfn opened this issue 3 years ago • 3 comments

Given a protocol defined as

@objc public protocol AProtocol {
   static func pubfunction()
   static var pubvariable: Int { get }
}

SourceKit do not reports the right ACL in the attributes list. The right ACL is resported instead in key.effective_access

key.entities: [
        {
          key.kind: source.lang.swift.decl.function.method.static,
          key.name: "decision()",
          key.usr: "c:@M@Module@objc(pl)Name(cm)pubfunction",
          key.line: 23,
          key.column: 17,
          key.attributes: [
            {
              key.attribute: source.decl.attribute.objc
            }
          ],
          key.effective_access: source.decl.effective_access.public
        },
......

This MR try to address this behaviour looking into the effective_access property to identify public entities in SDK mode.

strfn avatar Jun 07 '21 13:06 strfn

@rockbruno Any idea why this is failing ? Tests are green on MacOS Apple Swift version 5.4 (swiftlang-1205.0.26.9 clang-1205.0.19.55) Target: x86_64-apple-darwin20.5.0

Maybe a difference in SourceKit ?

strfn avatar Jun 08 '21 09:06 strfn

The CI here is configured for Xcode 12.4 (Swift 5.3, I think?), so this feature likely changed recently in SourceKit

rockbruno avatar Jun 08 '21 09:06 rockbruno

FYI tests are green now

strfn avatar Jun 21 '22 11:06 strfn