Files
swift-mirror/test/Parse/super.swift
Kathy Gray 5e407bce89 Diagnostics change for ambiguous overloads previously specifying 'this'
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
2025-10-10 17:46:22 +01:00

54 lines
1.6 KiB
Swift

// RUN: %target-typecheck-verify-swift
class B {
var foo: Int
func bar() {}
init() {} // expected-note {{found candidate with type '() -> B'}}
init(x: Int) {} // expected-note {{found candidate with type '(Int) -> B'}}
subscript(x: Int) -> Int {
get {}
set {}
}
}
class D : B {
override init() {
super.init()
super.init(42)
// expected-error@-1 {{missing argument label 'x:' in call}}
}
override init(x:Int) {
let _: () -> B = super.init // expected-error {{cannot reference 'super.init' initializer chain as function value}}
}
convenience init(y:Int) {
let _: () -> D = self.init // expected-error {{cannot reference 'self.init' initializer delegation as function value}}
}
init(z: Int) {
super
.init(x: z)
}
func super_calls() {
super.foo // expected-warning {{property is accessed but result is unused}}
super.foo.bar // expected-error {{value of type 'Int' has no member 'bar'}}
super.bar // expected-error {{function is unused}}
super.bar()
// FIXME: should also say "'super.init' cannot be referenced outside of an initializer"
super.init // expected-error{{no exact matches in reference to initializer}}
super.init() // expected-error{{'super.init' cannot be called outside of an initializer}}
super.init(0) // expected-error{{'super.init' cannot be called outside of an initializer}} // expected-error {{missing argument label 'x:' in call}}
super[0] // expected-warning {{subscript is accessed but result is unused}}
super
.bar()
}
func bad_super_1() {
super.$0 // expected-error{{expected identifier or 'init'}}
}
}