Skip to content

Commit 563aebc

Browse files
committed
Unified: Add more static name binding tests
1 parent 9837879 commit 563aebc

1 file changed

Lines changed: 50 additions & 7 deletions

File tree

‎unified/ql/test/library-tests/static-name-binding/inheritance.swift‎

Lines changed: 50 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,61 @@ class A {
22
class B {
33
class C {}
44
}
5+
6+
static func f() {}
7+
}
8+
9+
class D: A { // $ access=A
10+
static func f(x: Int) {} // $ access=Int
11+
}
12+
class E: D.B { // $ access=D access=A.B
13+
override init() {}
14+
}
15+
16+
class F {
17+
private init() {}
18+
}
19+
20+
class G: F { // $ access=F
21+
public init() {}
22+
}
23+
24+
class H: G { // $ access=G
25+
public init(x: String) {} // $ access=String
526
}
627

7-
class D: A {} // $ access=A
8-
class E: D.B {} // $ access=D access=A.B
28+
class I: H {} // $ access=H
29+
30+
class J: I { // $ access=I
31+
convenience init() {
32+
self.init(x: "")
33+
}
34+
}
935

1036
// Members of base classes can be accessed through derived classes
1137
func t1() {
12-
let x1: D = nil; // $ access=D
13-
let x2: D.B = nil; // $ access=D access=A.B
14-
let x3: D.B.C = nil; // $ access=D access=A.B access=A.B.C
38+
let x1: D = D() // $ access=D
39+
let x2: D.B = D.B() // $ access=D access=A.B
40+
let x3: D.B.C = D.B.C() // $ access=D access=A.B access=A.B.C
1541

1642
// The base class of 'E' is itself resolved through inheritance
17-
let x4: E = nil; // $ access=E
18-
let x5: E.C = nil; // $ access=E access=A.B.C
43+
let x4: E = E() // $ access=E
44+
let x5: E.C = E.C() // $ access=E access=A.B.C
45+
46+
let x6 = A.init() // $ access=A access=A.init
47+
let x7 = D.init() // $ access=D $ MISSING: access=A.init $ SPURIOUS: access=D.init
48+
49+
let x8 = A.f() // $ access=A access=A.f
50+
let x9 = D.f() // $ access=D access=D.f -- type inference should filter away the `D.f` target $ MISSING: access=A.f
51+
let x10 = D.f(x: 0) // $ access=D access=D.f $ MISSING: access=A.f -- type inference should filter away the `A.f` target
52+
53+
let x11 = E.init() // $ access=E access=E.init
54+
55+
let x12 = G.init() // $ access=G access=G.init
56+
57+
let x13 = H.init(x: "String") // $ access=H access=H.init
58+
59+
let x14 = I.init(x: "String") // $ access=I $ MISSING: access=H.init $ SPURIOUS: access=I.init
60+
61+
let x15 = J.init() // $ access=J access=J.init $ MISSING: access=H.init -- type inference should filter away the `H.init` target
1962
}

0 commit comments

Comments
 (0)