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-5298] Swift 3.2 source breakage on C enum import #47873
Comments
I'm afraid we'll need more context than this. Where is this enum defined? What are the definitions of the IC_* constants on your version of the OS? |
Comment by Florent Bruneau (JIRA) In order to reproduce you can use those three files: module.map:
blah.h: typedef enum ic__ic_priority__t {
IC_PRIORITY_LOW,
IC_PRIORITY_NORMAL,
IC_PRIORITY_HIGH,
} ic__ic_priority__t; and blah.swift: protocol MyEnumWrapper : RawRepresentable {
typealias RawValue = Int32
}
extension ic__ic_priority__t : MyEnumWrapper { } Then run the following command in the directory where you put the three files:
With swift 3.1, this works without any warning.
|
Huh. Thanks, Florent! @swift-ci create |
Okay, as far as I can tell nothing has changed in how we import the enum—i.e. it's always had a UInt32 raw type. So what's changed is that we've gotten better at telling that all your associated types need to be consistent. |
@slavapestov, do you remember where we had this discussion? I found SR-4382, but I remember us talking somewhere else as well. |
Florent, you can confirm that the old behavior used UInt32 with this code:
|
Comment by Florent Bruneau (JIRA) Hi Jordan, You're right, the RawValue is indeed an UInt32 with Swift 3.1
Unless the enum contains some negative values, in which case it switches to Int32. |
Environment
Linux
Additional Detail from JIRA
md5: 358d6880992e49579a58a90bae318431
Issue Description:
I import the following C enum in Swift:
With Swift 3.1, the enum is imported as a RawRepresable with RawValue = Int32, while in Swift 3.2, the RawValue becomes an UInt32 causing compilation error even when enforcing the -swift-version 3 flag.
The text was updated successfully, but these errors were encountered: