mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
conversion failures, making a bunch of diagnostics more specific and useful. UnavoidableFailures can be very helpful, but they can also be the first constraint failure that the system happened to come across... which is not always the most meaningful one. CSDiag's expr processing machinery has a generally better way of narrowing down which ones make the most sense. Swift SVN r30647
56 lines
1.1 KiB
Swift
56 lines
1.1 KiB
Swift
// RUN: %target-parse-verify-swift -parse-as-library
|
|
|
|
struct S {
|
|
init() {
|
|
super.init() // expected-error{{'super' cannot be used outside of class members}}
|
|
}
|
|
}
|
|
|
|
class D : B {
|
|
func foo() {
|
|
super.init() // expected-error{{'super.init' cannot be called outside of an initializer}}
|
|
}
|
|
|
|
init(a:Int) {
|
|
super.init()
|
|
}
|
|
|
|
init(f:Int) {
|
|
super.init(a: "x")
|
|
}
|
|
|
|
init(g:Int) {
|
|
super.init("aoeu") // expected-error{{cannot invoke 'B.init' with an argument list of type '(String)'}}
|
|
// expected-note @-1 {{overloads for 'B.init' exist with these partially matching parameter lists: (x: Int), (a: UnicodeScalar), (b: UnicodeScalar), (z: Float)}}
|
|
}
|
|
|
|
init(h:Int) {
|
|
var _ : B = super.init() // expected-error{{'()' is not convertible to 'B'}}
|
|
}
|
|
|
|
init(d:Double) {
|
|
super.init()
|
|
}
|
|
}
|
|
|
|
class B {
|
|
var foo : Int
|
|
func bar() {}
|
|
|
|
init() {
|
|
}
|
|
|
|
init(x:Int) {
|
|
}
|
|
|
|
init(a:UnicodeScalar) {
|
|
}
|
|
init(b:UnicodeScalar) {
|
|
}
|
|
|
|
init(z:Float) {
|
|
super.init() // expected-error{{'super' members cannot be referenced in a root class}}
|
|
}
|
|
}
|
|
|