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-3144] wrong error message from compiler for "resourceValues(forKeys keys: Set<URLResourceKey>)" #45732

Closed
swift-ci opened this issue Nov 5, 2016 · 6 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself SDKOverlay

Comments

@swift-ci
Copy link
Collaborator

swift-ci commented Nov 5, 2016

Previous ID SR-3144
Radar rdar://problem/29160392
Original Reporter ingconti (JIRA User)
Type Bug
Status Resolved
Resolution Done

Attachment: Download

Environment

Xcode Version 8.1 (8B62) / OS 10.12.2 Beta (16C32f)

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

md5: eb2aee6bd6c1c311b2ad5652b9b921e3

Issue Description:

If You write:

let attributes = try f.resourceValues(forKeys: [URLResourceKey.contentModificationDateKey])

it works, if You use a var:

let keys = [URLResourceKey.contentModificationDateKey]
let attributes = try f.resourceValues(forKeys: keys )

You got:

.../main.swift:38:27: 'resourceValues(forKeys:)' is unavailable: Use struct URLResourceValues and URL.resourceValues(forKeys:) instead

see OSX sample in attach,

fulle code:

let path  = "/Users/ingconti/Desktop/2013-14-15-16-Piatto-quadro-Joia/Images"

let fm = FileManager.default
let url = URL(fileURLWithPath: path)

let optionMask: FileManager.DirectoryEnumerationOptions = [
//  .skipsSubdirectoryDescendants,
//  .skipsPackageDescendants,
    //ADC: previous are not allowed.
    .skipsHiddenFiles
]

let keys = [URLResourceKey.contentModificationDateKey]

do{
    let fm = FileManager.default
    let files = try fm.contentsOfDirectory(at: url,
                                           includingPropertiesForKeys : keys,
                                           options: optionMask )
    
    for f : URL in files {
        print(f)
        do {
//          let attributes = try f.resourceValues(forKeys: [URLResourceKey.contentModificationDateKey])
            let attributes = try f.resourceValues(forKeys: keys )
        }
        catch _{
            
        }
    }
    
    
} catch let err {
    
    print(err)
}
@belkadan
Copy link
Contributor

belkadan commented Nov 7, 2016

cc @parkera

@parkera
Copy link
Member

parkera commented Nov 8, 2016

see also <rdar://problem/28735270>

@belkadan
Copy link
Contributor

belkadan commented Nov 8, 2016

That's not quite the same issue. In this case the problem is that the argument is an Array rather than a Set. The handwritten "unavailable" message in the Foundation overlay obscures that fact.

@parkera
Copy link
Member

parkera commented Nov 8, 2016

A different client wrote a bug up about this and it was duped to that one. If you have a problem with the dupe status then feel free to write another one.

@belkadan
Copy link
Contributor

belkadan commented Nov 8, 2016

It looks like both Radars are the same issue—which is a compiler-side issue—but this one is not. I'll clone this one into Radar.

@belkadan
Copy link
Contributor

Fixed in Xcode 9!

@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 SDKOverlay
Projects
None yet
Development

No branches or pull requests

3 participants