diff --git a/Sources/JExtractSwift/CDeclLowering/Swift2JavaTranslator+FunctionLowering.swift b/Sources/JExtractSwift/CDeclLowering/Swift2JavaTranslator+FunctionLowering.swift index 9dbcb510..4ab28e2c 100644 --- a/Sources/JExtractSwift/CDeclLowering/Swift2JavaTranslator+FunctionLowering.swift +++ b/Sources/JExtractSwift/CDeclLowering/Swift2JavaTranslator+FunctionLowering.swift @@ -50,8 +50,8 @@ extension Swift2JavaTranslator { } /// Lower the given variable decl to a C-compatible entrypoint, - /// providing all of the mappings between the parameter and result types - /// of the original function and its `@_cdecl` counterpart. + /// providing the mappings between the `self` and value type of the variable + /// and its `@_cdecl` counterpart. @_spi(Testing) public func lowerFunctionSignature( _ decl: VariableDeclSyntax, @@ -297,7 +297,7 @@ struct CdeclLowering { } } - /// Lower a Swift result type to cdecl parameters and return type. + /// Lower a Swift result type to cdecl out parameters and return type. /// /// - Parameters: /// - type: The return type. diff --git a/Sources/JExtractSwift/SwiftTypes/SwiftFunctionSignature.swift b/Sources/JExtractSwift/SwiftTypes/SwiftFunctionSignature.swift index db427767..cd4dbf7a 100644 --- a/Sources/JExtractSwift/SwiftTypes/SwiftFunctionSignature.swift +++ b/Sources/JExtractSwift/SwiftTypes/SwiftFunctionSignature.swift @@ -227,26 +227,17 @@ extension VariableDeclSyntax { case .getter: return [.get] case .accessors(let accessors): - var hasGetter = false - var hasSetter = false - for accessor in accessors { - switch accessor.accessorSpecifier { - case .keyword(.get), .keyword(._read), .keyword(.unsafeAddress): - hasGetter = true - case .keyword(.set), .keyword(._modify), .keyword(.unsafeMutableAddress): - hasSetter = true + switch accessor.accessorSpecifier.tokenKind { + // Existence of any write accessor or observer implies this supports read/write. + case .keyword(.set), .keyword(._modify), .keyword(.unsafeMutableAddress), + .keyword(.willSet), .keyword(.didSet): + return [.get, .set] default: // Ignore willSet/didSet and unknown accessors. break } } - - switch (hasGetter, hasSetter) { - case (true, true): return [.get, .set] - case (true, false): return [.get] - case (false, true): return [.set] - case (false, false): break - } + return [.get] } }