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

[stdlib] Backward compatibility fix for a flatMap on [String] #9466

Merged
merged 2 commits into from May 11, 2017

Conversation

Projects
None yet
3 participants
@moiseev
Member

moiseev commented May 10, 2017

Since String started to conform to Collection, the flatMap with a
sequence returning closure is now a better match than the one that
relies on the optional promotion in this code:

[""].flatMap { $0 }

which results in the default type of this expression changing from
[String] to [Character].

Restoring the old behavior in Swift 3 mode by adding a very explicit
overload.

Fixes: rdar://problem/32024978

@moiseev

This comment has been minimized.

Show comment
Hide comment
@moiseev
Member

moiseev commented May 10, 2017

@moiseev

This comment has been minimized.

Show comment
Hide comment
@moiseev

moiseev May 10, 2017

Member

@swift-ci Please test

Member

moiseev commented May 10, 2017

@swift-ci Please test

@moiseev

This comment has been minimized.

Show comment
Hide comment
@moiseev

moiseev May 10, 2017

Member

@swift-ci Please Test Source Compatibility

Member

moiseev commented May 10, 2017

@swift-ci Please Test Source Compatibility

[stdlib] Backward compatibility fix for a flatMap on [String]
Since String started to conform to Collection, the flatMap with a
sequence returning closure is now a better match that the one that
relies on the optional promotion in this code:

[""].flatMap { $0 }

which results in the default type of this expression changing from
[String] to [Character].

Restoring the old behavior in Swift 3 mode by adding a very explicit
overload.

Fixes: <rdar://problem/32024978>
@moiseev

This comment has been minimized.

Show comment
Hide comment
@moiseev

moiseev May 11, 2017

Member

@swift-ci Please smoke test

Member

moiseev commented May 11, 2017

@swift-ci Please smoke test

@moiseev

This comment has been minimized.

Show comment
Hide comment
@moiseev

moiseev May 11, 2017

Member

@swift-ci Please Test Source Compatibility

Member

moiseev commented May 11, 2017

@swift-ci Please Test Source Compatibility

@moiseev

This comment has been minimized.

Show comment
Hide comment
@moiseev

moiseev May 11, 2017

Member

@swift-ci Please Test Source Compatibility

Member

moiseev commented May 11, 2017

@swift-ci Please Test Source Compatibility

@moiseev

This comment has been minimized.

Show comment
Hide comment
@moiseev

moiseev May 11, 2017

Member

@swift-ci Please smoke test

Member

moiseev commented May 11, 2017

@swift-ci Please smoke test

@airspeedswift airspeedswift merged commit 31f7dfe into apple:master May 11, 2017

2 checks passed

Swift Test Linux Platform (smoke test)
Details
Swift Test OS X Platform (smoke test)
Details

@moiseev moiseev deleted the moiseev:flatmap-string branch May 11, 2017

@Coeur

This comment has been minimized.

Show comment
Hide comment
@Coeur

Coeur Jun 25, 2017

Contributor

Fixes: rdar://problem/32024978

Can someone fill http://www.openradar.me/32024978 or provide a public resource?

Contributor

Coeur commented Jun 25, 2017

Fixes: rdar://problem/32024978

Can someone fill http://www.openradar.me/32024978 or provide a public resource?

@moiseev

This comment has been minimized.

Show comment
Hide comment
@moiseev

moiseev Jun 26, 2017

Member

@Coeur The description of this PR explains it, doesn't it?

The following code:

struct S { var p: String }

func f(xs: [S]) -> [String] {
   return xs.flatMap { $0.p }
}

would not compile once String becomes Collection without this fix, with the error being something like 'cannot convert [Character] to return type [String]'.

Member

moiseev commented Jun 26, 2017

@Coeur The description of this PR explains it, doesn't it?

The following code:

struct S { var p: String }

func f(xs: [S]) -> [String] {
   return xs.flatMap { $0.p }
}

would not compile once String becomes Collection without this fix, with the error being something like 'cannot convert [Character] to return type [String]'.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment