google / google/j2objc

Swift name should only be set if it's different than the Objective C name

Open
#1,236 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
6k
Forks
999
Avg merge
19h 20m
Merged PRs (30d)
14

Description

Class properties and enums are now declared with NS_SWIFT_NAME, such as this constant:
```
@property (readonly, class) jint FOO NS_SWIFT_NAME(FOO);
@property (readonly, class) jint EOF_ NS_SWIFT_NAME(EOF_);
```
There are two problems with the above. First, there's no reason to define an NS_SWIFT_NAME, since it's the same name. Second, the Java name is EOF, but the trailing underscore is necessary because it's a preprocessor constant from a common system header. Since Swift doesn't use the preprocessor, the Swift name just be the Java name (unless it's a Swift reserved word). So better code would look like:
```
@property (readonly, class) jint FOO;
@property (readonly, class) jint EOF_ NS_SWIFT_NAME(EOF);
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.