Skip to content

Commit 3f5ed1e

Browse files
authored
Merge pull request #72969 from tshortli/extension-import-visibility-tests
Tests: Add more tests for ExtensionImportVisibility
2 parents d898001 + 0cf2428 commit 3f5ed1e

10 files changed

+52
-5
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// Intentionally empty

test/NameLookup/Inputs/Categories/Categories_D.swift

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import Categories_C
2+
import Categories_D.Submodule
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
@import Categories_A;
2+
3+
@interface X (SubmoduleOfD)
4+
- (void)fromSubmoduleOfD;
5+
@end

test/NameLookup/Inputs/Categories/module.modulemap

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,14 @@ module Categories_C {
1212
header "Categories_C.h"
1313
export *
1414
}
15+
16+
module Categories_D {
17+
header "Categories_D.h"
18+
export *
19+
20+
explicit module Submodule {
21+
header "Submodule.h"
22+
export *
23+
}
24+
}
25+

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
}

test/NameLookup/extensions_transitive_objc.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,24 @@
22
// RUN: %target-swift-frontend -emit-module -I %t -I %S/Inputs/Categories -o %t %S/Inputs/Categories/Categories_A.swift
33
// RUN: %target-swift-frontend -emit-module -I %t -I %S/Inputs/Categories -o %t %S/Inputs/Categories/Categories_B.swift
44
// RUN: %target-swift-frontend -emit-module -I %t -I %S/Inputs/Categories -o %t %S/Inputs/Categories/Categories_C.swift
5-
// RUN: %target-swift-frontend -emit-module -I %t -I %S/Inputs/Categories -o %t %S/Inputs/Categories/Categories_D.swift
5+
// RUN: %target-swift-frontend -emit-module -I %t -I %S/Inputs/Categories -o %t %S/Inputs/Categories/Categories_E.swift
66
// RUN: %target-swift-frontend -typecheck %s -I %t -I %S/Inputs/Categories -verify -enable-experimental-feature ExtensionImportVisibility
77

88
// REQUIRES: objc_interop
99

1010
import Categories_B
11-
import Categories_D
12-
// expected-note 2 {{add import of module 'Categories_C'}}{{1-1=import Categories_C\n}}
11+
import Categories_E
12+
13+
// expected-note@-1 2 {{add import of module 'Categories_C'}}{{1-1=import Categories_C\n}}
14+
// expected-note@-2 {{add import of module 'Categories_D'}}{{1-1=import Categories_D\n}}
1315
func test(x: X) {
1416
x.fromA()
1517
x.fromOverlayForA()
1618
x.fromB()
1719
x.fromOverlayForB()
1820
x.fromC() // expected-error {{class method 'fromC()' is not available due to missing import of defining module 'Categories_C'}}
1921
x.fromOverlayForC() // expected-error {{instance method 'fromOverlayForC()' is not available due to missing import of defining module 'Categories_C'}}
22+
x.fromSubmoduleOfD() // expected-error {{class method 'fromSubmoduleOfD()' is not available due to missing import of defining module 'Categories_D'}}
2023
}
2124

2225
func testAnyObject(a: AnyObject) {

0 commit comments

Comments
 (0)