Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ObjC BOOL Property Getter Mismatch #78257

Open
jay18001 opened this issue Dec 17, 2024 · 0 comments
Open

ObjC BOOL Property Getter Mismatch #78257

jay18001 opened this issue Dec 17, 2024 · 0 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels

Comments

@jay18001
Copy link

Description

When using an Objective-C BOOL property that has a custom getter method, the compiler uses the getter method's name directly instead of the property name. This behavior seems to be specific to BOOL properties and doesn't seem to occur with other property types, such as C99 bool.

Reproduction

If we have this ObjC class.

@interface SomeClass : NSObject

@property (nonatomic, getter=getIsChecked, readonly) BOOL isChecked;

@end

The compiler will generate this swift interface

open class SomeClass : NSObject {

    open var getIsChecked: Bool { get }
}

Expected behavior

Using the ObjC class the output should be

open class SomeClass : NSObject {

    open var isChecked: Bool { get }
}

Environment

swift-driver version: 1.115 Apple Swift version 6.0 (swiftlang-6.0.0.9.10 clang-1600.0.26.2)
Target: arm64-apple-macosx15.0

Additional information

Using custom getters like are relatively rare in ObjC.

There are a few different workarounds:

  1. Use NS_SWIFT_NAME()
  2. Use a typedef of BOOL
  3. Use C99 bool
@jay18001 jay18001 added bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels labels Dec 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels
Projects
None yet
Development

No branches or pull requests

1 participant