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-7715] FileManager.DirectoryEnumerator from enumerator(at:includingPropertiesForKeys:options:errorHandler:) enumerates Any instead of URL #3704

Open
swift-ci opened this issue May 17, 2018 · 2 comments

Comments

@swift-ci
Copy link
Contributor

Previous ID SR-7715
Radar None
Original Reporter benasher44 (JIRA User)
Type Bug
Status In Progress
Resolution
Environment

macOS 10.13.4
Xcode 9.3.1 (App Store version)
Swift 4.1

Additional Detail from JIRA
Votes 0
Component/s Foundation
Labels Bug
Assignee karthikkeyan.balan (JIRA)
Priority Medium

md5: 8de604f693ab96b710ff8291d6d964d5

Issue Description:

I'd expect this to return a enumerator over URL, but instead it's an enumerator over Any:

Consider the following Swift:

import Foundation

let enumerator = FileManager.default.enumerator(at: URL(fileURLWithPath: NSTemporaryDirectory()), includingPropertiesForKeys: nil)!
for url in enumerator {
    print("\(url.path)")
}

This results in the following compiler error:

enumerator.swift:5:14: error: value of type 'Any' has no member 'path'
    print("\(url.path)")
             ^~~ ~~~~
enumerator.swift:5:14: note: cast 'Any' to 'AnyObject' or use 'as!' to force downcast to a more specific type to access members
    print("\(url.path)")
             ^
             (   as AnyObject)

It'd be nice if there were a Swift overlay/shim that could improve this here. The situation today is that you have to have to force cast to `URL`.

@swift-ci
Copy link
Contributor Author

swift-ci commented Feb 1, 2019

@millenomi
Copy link
Contributor

We can't break source compatibility, but I'm keeping this issue to see if we can make use of this feedback.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants