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-5387] AnySequence.flatMap does not compile in Swift 4.0 #47961

Closed
swift-ci opened this issue Jul 6, 2017 · 5 comments
Closed

[SR-5387] AnySequence.flatMap does not compile in Swift 4.0 #47961

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

Comments

@swift-ci
Copy link
Collaborator

swift-ci commented Jul 6, 2017

Previous ID SR-5387
Radar rdar://problem/33043106
Original Reporter Bernd Ohr (JIRA User)
Type Bug
Status Resolved
Resolution Done
Environment

Xcode Version 9.0 beta 2 (9M137d)
Toolchain: Swift 4.0 Snapshot 2017-07-04 (a)
MacOS Sierra Version 10.12.5 (16F73)

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

md5: f94b14d3683b5ba65c69f508e4beff3d

is blocked by:

  • SR-5462 AnySequence's with tuple elements can not be joined
  • SR-5429 first(where:) on AnySequence no longer compiles

Issue Description:

func isMagic(_: Int) -> Bool? {
    return false
}

func foo1(s: AnySequence<Int>) {
    _ = s.flatMap(isMagic) //  error: cannot convert value of type '(Int) -> Bool?' to expected argument type '((Int)) -> _'
    _ = s.flatMap { _ -> Bool? in // error: declared closure result 'Bool?' is incompatible with contextual type 'String'
        return false
    }
}

func foo2(s: AnySequence<Int>) {
    let a = Array(s) // ??? oops, type is Array<(Int)>
    _ = a.flatMap(isMagic) // error: cannot convert value of type '(Int) -> Bool?' to expected argument type '((Int)) -> String?'
    _ = a.flatMap { _ -> Bool? in // error: declared closure result 'Bool?' is incompatible with contextual type 'String'
        return false
    }
}

func foo3(s: AnySequence<Int>) {
    let a: Array<Int> = Array(s)
    _ = a.flatMap(isMagic) // works
    _ = a.flatMap { _ -> Bool? in // works
        return false
    }
}

func foo4(s: AnySequence<Int>) {
    let a = s.map { $0 }
    _ = a.flatMap(isMagic) // works
    _ = a.flatMap { _ -> Bool? in // works
        return false
    }
}
@belkadan
Copy link
Contributor

belkadan commented Jul 6, 2017

Looks like another SE-0110-like problem. @rudkx?

@belkadan
Copy link
Contributor

belkadan commented Jul 6, 2017

@swift-ci create

@rudkx
Copy link
Member

rudkx commented Jul 10, 2017

Yes, it's unfortunate fall-out from #10414

@rudkx
Copy link
Member

rudkx commented Jul 10, 2017

By the way, I am not seeing this behavior with Xcode 9.0 beta 2. Did someone actually reproduce this in that build?

@rudkx
Copy link
Member

rudkx commented Jul 11, 2017

Merged to master: 9f68dee

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

No branches or pull requests

4 participants