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-609] 'Cannot call value of non-function type' error when calling initializer of class with same name as enum case #43226

Closed
swift-ci opened this issue Jan 24, 2016 · 0 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior.

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-609
Radar None
Original Reporter cargath (JIRA User)
Type Bug
Status Resolved
Resolution Duplicate

Attachment: Download

Environment

OS X 10.11.3 (15D21)
Xcode 7.2 (7C68)
Swift 2.1.1 (swiftlang-700.1.101.15 clang-700.1.81)

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

md5: 78af40aa7804f90ffce679e3c44e0652

duplicates:

  • SR-456 Confusing build error when calling 'max' function within 'extension Int'

Issue Description:

When a class uses the same name as an enum case, you can't call the initializer of the class from a function on the enum anymore, because the compiler is confused and shows an 'Cannot call value of non-function type' error.

e.g.:

class Base {}
class Foo: Base {}
class Bra: Base {}

enum Foobar {
    case Foo
    case Bar
}

extension Foobar {
    func make() -> Base {
        switch self {
            case .Foo: return Foo() // error
            case .Bar: return Bra() // works
        }
    }
}

I guess some people would consider this a bad naming scheme anyway. But since Swift uses namespaces so we don't need to prefix names like in Objective C anymore, i think this should be treated as a bug.

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

No branches or pull requests

1 participant