forked from swiftlang/swift
-
Notifications
You must be signed in to change notification settings - Fork 0
/
super_constructor.swift
55 lines (42 loc) · 1.07 KB
/
super_constructor.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// 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{{argument labels '(_:)' do not match any available overloads}}
// 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{{cannot convert value of type '()' to specified type '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}}
}
}