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-7871] NSSet bridging to Set fails #50406

Open
swift-ci opened this issue Jun 5, 2018 · 2 comments
Open

[SR-7871] NSSet bridging to Set fails #50406

swift-ci opened this issue Jun 5, 2018 · 2 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself type checker Area → compiler: Semantic analysis

Comments

@swift-ci
Copy link
Collaborator

swift-ci commented Jun 5, 2018

Previous ID SR-7871
Radar None
Original Reporter kdawgwilk (JIRA User)
Type Bug
Environment

macOS 10.14 Mojave

Xcode 10 beta 1

Swift compiler 4.2

Compile using Swift 4 backward compatibility

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

md5: 52f5e28f5e39571ab95184964095f400

Issue Description:

The line

        return Set(behaviors)

from the following snippet

public static var enabledLoggingBehaviors: Set<SDKLoggingBehavior> {
    get {
        let behaviors = FBSDKSettings.loggingBehavior().flatMap { object -> SDKLoggingBehavior? in
            if let value = object as? String {
                return SDKLoggingBehavior(sdkStringValue: value)
            }
            return nil
        }
        return Set(behaviors)
    }
    set {
        let behaviors = newValue.map({ $0.sdkStringValue })
        FBSDKSettings.setLoggingBehavior(Set(behaviors))
    }
}

gives the compiler error:

Argument type 'SDKLoggingBehavior?' does not conform to expected type 'Sequence'

`FBSDKSettings.loggingBehavior()` is typed as:

+ (NSSet *)loggingBehavior;

This compiles just fine on 4.1

Issue on Github: facebookarchive/facebook-swift-sdk#235

@swift-ci
Copy link
Collaborator Author

swift-ci commented Jun 5, 2018

Comment by Kaden Wilkinson (JIRA)

After looking at this some more it seems that this might be related to IUO changes because it seems to work if I add a force unwrap to `.loggingBehavior()!`

@belkadan
Copy link
Contributor

belkadan commented Jun 5, 2018

You can probably switch to compactMap here instead of flatMap. What's happening is that the flatMap is being interpreted as Optional.flatMap rather than Array.flatMap, since both have the same signature. (This is indeed a change that would have come about due to IUO.)

@rudkx, is this a case we can restore to the 4.1 behavior?

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
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 type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

2 participants