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 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155
|
var globV: Int
class CC0 {
var x: Int = 0
}
class CC {
var instV: CC0
func meth() {}
func instanceFunc0(_ a: Int, b: Float) -> Int {
return 0
}
func instanceFunc1(a x: Int, b y: Float) -> Int {
return 0
}
class func smeth() {}
init() {
instV = CC0()
}
}
func +(a : CC, b: CC0) -> CC {
return a
}
struct S {
func meth() {}
static func smeth() {}
}
enum E {
case EElem
}
protocol Prot {
func protMeth(_ a: Prot)
}
func foo(_ a: CC, b: E) {
var b = b
_ = b
globV = 0
_ = a + a.instV
a.meth()
CC.smeth()
b = E.EElem
var _: CC
class LocalCC {}
var _: LocalCC
}
typealias CCAlias = CC
extension CC : Prot {
func meth2(_ x: CCAlias) {}
func protMeth(_ a: Prot) {}
var extV : Int { return 0 }
}
class SubCC : CC {}
var globV2: SubCC
class ComputedProperty {
var value : Int {
get {
let result = 0
return result
}
set(newVal) {
// completely ignore it!
}
}
var readOnly : Int { return 0 }
}
class BC2 {
func protMeth(_ a: Prot) {}
}
class SubC2 : BC2, Prot {
override func protMeth(_ a: Prot) {}
}
class CC2 {
subscript (i : Int) -> Int {
get {
return i
}
set(vvv) {
_ = vvv+1
}
}
}
func test1(_ cp: ComputedProperty, sub: CC2) {
var x = cp.value
x = cp.readOnly
cp.value = x
cp.value += 1
x = sub[0]
sub[0] = x
sub[0] += 1
}
struct S2 {
func sfoo() {}
}
var globReadOnly : S2 {
get {
return S2();
}
}
func test2() {
globReadOnly.sfoo()
}
class B1 {
func foo() {}
}
class SB1 : B1 {
override func foo() {
foo()
self.foo()
super.foo()
}
}
func test3(_ c: SB1, s: S2) {
test2()
c.foo()
s.sfoo()
}
func test4(_ a: inout Int) {}
protocol Prot2 {
associatedtype Element
var p : Int { get }
func foo()
}
struct S1 : Prot2 {
typealias Element = Int
var p : Int = 0
func foo() {}
}
func genfoo<T : Prot2>(_ x: T) where T.Element == Int {}
protocol Prot3 {
static func +(x: Self, y: Self)
}
|