mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
The previous commit enabled this; now it's just about removing the restriction in the parser and tightening up code completion. Using 'super' in a closure where 'self' is captured weak or unowned still doesn't work; the reference to 'self' within the closure is treated as strong regardless of how it's declared. Fixing this requires a cascade of effort, so instead I just cloned rdar://problem/19755221. rdar://problem/14883824 Swift SVN r25065
59 lines
980 B
Swift
59 lines
980 B
Swift
// RUN: %target-parse-verify-swift -parse-as-library -enable-character-literals
|
|
|
|
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(e:Int) {
|
|
super.init('x') // expected-error{{could not find an overload for 'init' that accepts the supplied arguments}}
|
|
}
|
|
|
|
init(f:Int) {
|
|
super.init(a: "x")
|
|
}
|
|
|
|
init(g:Int) {
|
|
super.init("aoeu") // expected-error{{}}
|
|
}
|
|
|
|
init(h:Int) {
|
|
var y : B = super.init() // expected-error{{}}
|
|
}
|
|
|
|
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}}
|
|
}
|
|
}
|
|
|