Skip to content

Commit a2b59b2

Browse files
committed
Tests: Add operator lookup tests to extensions_transitive.swift.
1 parent 6500751 commit a2b59b2

File tree

4 files changed

+27
-1
lines changed

4 files changed

+27
-1
lines changed

test/NameLookup/Inputs/extensions_A.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,18 @@ extension Y: P where T: P { }
88

99
public struct Z: P { }
1010

11+
infix operator <<<
12+
infix operator >>>
13+
infix operator <>
14+
1115
extension X {
1216
public func XinA() { }
17+
18+
public static func <<<(a: Self, b: Self) -> Self { a }
1319
}
1420

1521
extension Y {
1622
public func YinA() { }
23+
24+
public static func <<<(a: Self, b: Self) -> Self { a }
1725
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
import extensions_A
22

3+
34
extension X {
45
public func XinB() { }
6+
7+
public static func >>>(a: Self, b: Self) -> Self { b }
58
}
69

710
extension Y {
811
public func YinB() { }
12+
13+
public static func >>>(a: Self, b: Self) -> Self { b }
914
}
1015

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
@_exported import extensions_A
22
import extensions_B
33

4+
45
extension X {
56
public func XinC() { }
7+
8+
public static func <>(a: Self, b: Self) -> Self { a }
69
}
710

811
extension Y {
912
public func YinC() { }
10-
}
1113

14+
public static func <>(a: Self, b: Self) -> Self { a }
15+
}

test/NameLookup/extensions_transitive.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,21 @@
77
import extensions_C
88
// expected-note 2{{add import of module 'extensions_B'}}{{1-1=import extensions_B\n}}
99
func test(x: X, y: Y<Z>) {
10+
// Declared in extensions_A
1011
x.XinA()
1112
y.YinA()
13+
_ = x <<< x
14+
_ = y <<< y
1215

16+
// Declared in extensions_B
1317
x.XinB() // expected-error{{instance method 'XinB()' is not available due to missing import of defining module 'extensions_B'}}
1418
y.YinB() // expected-error{{instance method 'YinB()' is not available due to missing import of defining module 'extensions_B'}}
19+
_ = x >>> x // expected-error{{cannot find operator '>>>' in scope}}
20+
_ = y >>> y // expected-error{{cannot find operator '>>>' in scope}}
1521

22+
// Declared in extensions_C
1623
x.XinC()
1724
y.YinC()
25+
_ = x <> x
26+
_ = y <> y
1827
}

0 commit comments

Comments
 (0)