forked from swiftlang/swift
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsuper_constructor.swift
58 lines (44 loc) · 970 Bytes
/
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
55
56
57
// RUN: %swift %s -parse-as-library -verify -enable-character-literals
struct S {
init() {
super.init() // expected-error{{'super' members cannot be referenced in a non-class type}}
}
}
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{{'()' does not conform to protocol 'CharacterLiteralConvertible'}}
}
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}}
}
}