swift icon indicating copy to clipboard operation
swift copied to clipboard

[SR-4692] Useless diagnostics calling non-static method

Open NachoSoto opened this issue 9 years ago • 3 comments

Previous ID SR-4692
Radar rdar://problem/31847375
Original Reporter @NachoSoto
Type Bug
Status Resolved
Resolution Done

Environment

Swift version 3.1 (swiftlang-802.0.53 clang-802.0.42)
Target: x86_64-apple-macosx10.9

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

md5: 797b62b171be00fdce6076562bad60e8

Issue Description:

Two similar examples with different (but equally useless) diagnostics

First one:

class D {
    static func b() {
        self.g(x: 3, y: true)
    }

    private func g(x: Int, y: Bool) {
    }
}

Expected result:

Error saying `g` is not `static`.

Actual result:

error: repl.swift:22:25: error: extra argument 'y' in call
        self.g(x: 3, y: true)
                        ^~~~

Second one:

class C {
    static func a() {
        self.f(x: 3, y: true)
    }

    private func f(a: Int, b: Bool, c: String) {
        self.f(x: a, y: b)
    }
    
    private func f(x: Int, y: Bool) {
    }
}

Expected result:

Error saying `f(x:y: )` is not `static`.

Actual result:

error: repl.swift:22:9: error: ambiguous reference to member 'f(a:b:c:)'
        self.f(x: 3, y: true)
        ^~~~

repl.swift:25:18: note: found this candidate
    private func f(a: Int, b: Bool, c: String) {
                 ^

repl.swift:29:18: note: found this candidate
    private func f(x: Int, y: Bool) {
                 ^

NachoSoto avatar Apr 25 '17 19:04 NachoSoto

@swift-ci create

rudkx avatar Apr 26 '17 22:04 rudkx

Fix and test cases from the ticket are included in https://github.com/apple/swift/pull/9376 which has been merged to master. Snapshot should be available soon, so please validate and let me know, resolving this as Done for now.

xedin avatar May 08 '17 00:05 xedin

I can confirm this work now :thumbsup:

NachoSoto avatar Jun 15 '17 22:06 NachoSoto