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

[SR-7784] apinotes doesn't support anonymous enum typedefs #50323

Open
nevil opened this issue May 26, 2018 · 2 comments
Open

[SR-7784] apinotes doesn't support anonymous enum typedefs #50323

nevil opened this issue May 26, 2018 · 2 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself

Comments

@nevil
Copy link

nevil commented May 26, 2018

Previous ID SR-7784
Radar rdar://problem/40617284
Original Reporter @nevil
Type Bug

Attachment: Download

Environment

macOS
Xcode 9.3.1 (9E501)
swift-4.2-DEVELOPMENT-SNAPSHOT-2018-05-23

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, ClangImporter
Assignee None
Priority Medium

md5: 6198e29c2d62b8455f6f1cc5dc1a55fc

Issue Description:

I have a 3rd party objc framework with an anonymous enum typedef.

typedef enum {
  AnonymousEnumA = 1,
  AnonymousEnumB
} AnonymousEnum;

Using an apinotes file the goal is to import this as a closed enum in swift. Something like:

enum AnonymousEnum: Int32 {
    case a
    case b
}

The below apinotes works for a non-anonymous enum, but not for the anonymous typedef enum.

Tags:
- Name: AnonymousEnum
  EnumKind: NSEnum

Enumerators:
- Name: AnonymousEnumA
  SwiftName: AnonymousEnum.a
- Name: AnonymousEnumB
  SwiftName: AnonymousEnum.b

Build the attached (SR-7784.zip) sample project using:
swiftc -c -F . -framework VersionedKit.framework main.swift

It will fail with error:

main.swift:4:7: error: type 'AnonymousEnum' has no member 'a'
print(AnonymousEnum.a)

More information in this thread:
https://forums.swift.org/t/help-with-apinotes/12954

@belkadan
Copy link
Contributor

@swift-ci create

@DougGregor
Copy link
Member

Finally fixed!

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. compiler The Swift compiler in itself
Projects
None yet
Development

No branches or pull requests

3 participants