Files
swift-mirror/test/Constraints/super_constructor.swift
Jordan Rose fac5a83bbf Allow capturing super in explicit closures and nested functions.
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
2015-02-07 03:56:11 +00:00

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}}
}
}