mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Updates the message to use the type or ValueDecl instead of this on previous 'Found this candidate' messages Note: doees not yet change all test cases so more tests are failing Improve Diagnostic message on overload ambiguitiy Remove messages that say 'found this candidate' in favour of providing the type for the candidate to aid in selection when the candidates are presented in a dialogue window. Fix more tests
62 lines
1.6 KiB
Swift
62 lines
1.6 KiB
Swift
// RUN: %target-typecheck-verify-swift
|
|
|
|
func valid1() {
|
|
func inner(_: Int) {}
|
|
func inner(_: String) {}
|
|
|
|
func inner(label: Int) {}
|
|
func inner(label: String) {}
|
|
|
|
inner(123)
|
|
inner("hello")
|
|
|
|
inner(label: 123)
|
|
inner(label: "hello")
|
|
}
|
|
|
|
func valid2() {
|
|
func inner(_: Int = 0) {}
|
|
func inner() -> Bool {}
|
|
func inner(first: Int, second: Int = 0) {}
|
|
|
|
let _: Bool = inner()
|
|
let _ = inner()
|
|
|
|
inner(first: 123)
|
|
}
|
|
|
|
func invalid1() {
|
|
func inner(_: Int) {}
|
|
// expected-note@-1 {{'inner' previously declared here}}
|
|
func inner(_: Int) {}
|
|
// expected-error@-1 {{invalid redeclaration of 'inner'}}
|
|
}
|
|
|
|
func invalid2() {
|
|
func inner(_: Int) {}
|
|
// expected-note@-1 {{candidate expects value of type 'Int' for parameter #1}}
|
|
// expected-note@-2 {{found candidate with type '(Int) -> ()'}}
|
|
// expected-note@-3 {{did you mean 'inner'?}}
|
|
func inner(_: String) {}
|
|
// expected-note@-1 {{candidate expects value of type 'String' for parameter #1}}
|
|
// expected-note@-2 {{found candidate with type '(String) -> ()'}}
|
|
|
|
func inner(label: Int) {}
|
|
// expected-note@-1 {{found candidate with type '(Int) -> ()'}}
|
|
|
|
inner([])
|
|
// expected-error@-1 {{no exact matches in call to local function 'inner'}}
|
|
|
|
inner(label: "hi")
|
|
// expected-error@-1 {{cannot convert value of type 'String' to expected argument type 'Int'}}
|
|
|
|
_ = inner
|
|
// expected-error@-1 {{ambiguous use of 'inner'}}
|
|
|
|
_ = inner(label:) // no-error
|
|
|
|
// FIXME: This isn't as good as in the non-local function case?
|
|
_ = inner(invalidLabel:)
|
|
// expected-error@-1 {{cannot find 'inner(invalidLabel:)' in scope}}
|
|
}
|