Skip to content

[C++ interop] SWIFT_COMPUTED_PROPERTY imports the original function as available #82575

Closed as not planned
@AnthonyLatsis

Description

@AnthonyLatsis

Description

The macro doc suggests that the method is imported as a computed property:

/// Specifies that a specific C++ method should be imported as a computed
/// property. If this macro is specified on a getter, a getter will be
/// synthesized. If this macro is specified on a setter, both a getter and
/// setter will be synthesized.
///
/// For example:
///  ```
///    int getX() SWIFT_COMPUTED_PROPERTY;
///  ```
/// Will be imported as `var x: CInt {...}`.

In actuality a computed property is imported in addition to the method.

Reproduction

https://github.com/swiftlang/swift/blob/0775d254c773aa0dcafe7d9e89d832ad5e244b6c/test/Interop/Cxx/ergonomics/explicit-computed-properties.swift

Expected behavior

It was brought to my understanding that importing both is an expected implementation detail, but since one can actually use the imported method, we should either change the implementation to annotate it as unavailable or update the documentation to point out the actual behavior.

Environment

Swift version 6.2-dev (LLVM 017432c08540af8, Swift 9488df1)

Additional information

No response

Metadata

Metadata

Assignees

Labels

bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.c++ interopFeature: Interoperability with C++clang importerArea → compiler: The clang importercompilerThe Swift compiler itselfswift 6.2unexpected behaviorBug: Unexpected behavior or incorrect output

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions