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-4587] No "inaccessible" diagnostic for property if the base name is shared with methods #47164

Open
NachoSoto opened this issue Apr 14, 2017 · 1 comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself diagnostics QoI Bug: Diagnostics Quality of Implementation

Comments

@NachoSoto
Copy link
Contributor

Previous ID SR-4587
Radar None
Original Reporter @NachoSoto
Type Bug
Environment

Swift version 3.1 (swiftlang-802.0.51 clang-802.0.41)

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

md5: 603d618afc7c8a743b9229059634fcec

relates to:

  • SR-9916 Variable name same as function name
  • SR-1775 Better handling of property/method name clashes

Issue Description:

Code

class A {
    let backgroundColor: Int = 0
}

class C {
        // Note: changing this to something other than tableView (since that's the prefix in all the methods) does produce the correct diagnostic.
    private let tableView = A()
}

protocol P {
    func numberOfSections(in tableView: A)
    func tableView(_ tableView: A, numberOfRowsInSection section: Int)
    func tableView(_ tableView: A, cellForRowAt indexPath: Int)
}

extension C: P {
    func numberOfSections(in tableView: A) { }

    func tableView(_ tableView: A, numberOfRowsInSection section: Int) {}

    func tableView(_ tableView: A, cellForRowAt indexPath: Int) {
        print(self.tableView.backgroundColor)
    }
}

Expected result

Suggestion to make `tableView` `fileprivate`

Actual result

error: ambiguous reference to member 'tableView(_:numberOfRowsInSection:)'
        print(self.tableView.backgroundColor)
              ^~~~

repl.swift:18:10: note: found this candidate
    func tableView(_ tableView: A, numberOfRowsInSection section: Int) {}
         ^

repl.swift:20:10: note: found this candidate
    func tableView(_ tableView: A, cellForRowAt indexPath: Int) {
@CodaFi
Copy link
Member

CodaFi commented Aug 29, 2017

As of SE-0169, to reproduce this the extension must be in a different file.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
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 diagnostics QoI Bug: Diagnostics Quality of Implementation
Projects
None yet
Development

No branches or pull requests

2 participants