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-3319] Casting CGFloat to NSNumber in map closure using $0 broken in DEVELOPMENT-SNAPSHOT-2016-11-29-a #45907

Closed
swift-ci opened this issue Dec 2, 2016 · 3 comments
Assignees
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 Dec 2, 2016

Previous ID SR-3319
Radar rdar://problem/29496775
Original Reporter benasher44 (JIRA User)
Type Bug
Status Closed
Resolution Done
Environment

Swift 3 DEVELOPMENT-SNAPSHOT-2016-11-29-a, macOS Sierra

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, 3.1Regression, TypeChecker
Assignee @DougGregor
Priority Medium

md5: 47b01355234a41f0e3f7e012e9bb98de

Issue Description:

I recently tried out Swift 3 DEVELOPMENT-SNAPSHOT-2016-11-29-a, and the following breaks on that snapshot but works fine in Xcode 8.1 and Xcode 8.2 beta 2:

import Foundation

let f: CGFloat = 4.0
let _ = [f].map { $0 as NSNumber }

In this snapshot, I get the following error:

test.swift:4:17: error: cannot convert value of type '(CGFloat) -> NSNumber' to expected argument type '(CGFloat) -> _'

@swift-ci
Copy link
Collaborator Author

swift-ci commented Dec 2, 2016

Comment by Ben A (JIRA)

The only way to fix it seems to be fully qualifying the closure like this:

let _ = [f].map { (f: CGFloat) -> NSNumber in f as NSNumber }

@slavapestov
Copy link
Member

The core of the problem is the array literal. You can also fix the problem by writing:

let a = [f]
let _ = a.map { $0 as NSNumber }

@DougGregor
Copy link
Member

8afeadc

@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 type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

3 participants