Skip to content

Commit d766707

Browse files
committed
Tests: Add a MemberImportVisibility test case for rdar://162130647.
1 parent 782af00 commit d766707

File tree

4 files changed

+35
-0
lines changed

4 files changed

+35
-0
lines changed

test/NameLookup/Inputs/MemberImportVisibility/members_A.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,9 @@ public protocol ProtocolInA {
7979
extension ProtocolInA {
8080
public func defaultedRequirementInA() { }
8181
}
82+
83+
public struct EquatableInA: Equatable {
84+
public static func ==(_: Self, _: Self) -> Bool {
85+
false
86+
}
87+
}

test/NameLookup/Inputs/MemberImportVisibility/members_B.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,9 @@ open class DerivedClassInB: BaseClassInA {
5959
extension ProtocolInA {
6060
public func defaultedRequirementInB() { }
6161
}
62+
63+
public struct EquatableInB: Equatable {
64+
public static func ==(_: EquatableInB, _: EquatableInB) -> Bool {
65+
false
66+
}
67+
}

test/NameLookup/Inputs/MemberImportVisibility/members_C.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,15 @@ open class DerivedClassInC: DerivedClassInB {
5252
extension ProtocolInA {
5353
public func defaultedRequirementInC() { }
5454
}
55+
56+
public struct EquatableInC: Equatable {
57+
public static func ==(_: EquatableInC, _: EquatableInC) -> Bool {
58+
false
59+
}
60+
}
61+
62+
public struct HasEquatableMembers {
63+
public var a: EquatableInA
64+
public var b: EquatableInB
65+
public var c: EquatableInC
66+
}

test/NameLookup/member_import_visibility.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,3 +167,14 @@ func testLeadingDotSyntax() {
167167
takesP(.zInC)
168168
takesP(.zAmbiguous)
169169
}
170+
171+
func testConformanceMember(_ h1: HasEquatableMembers, _ h2: HasEquatableMembers) {
172+
_ = h1.a == h2.a
173+
// Technically, this references the EquatableInB.== member that hasn't been
174+
// imported. However, the conformance of EquatableInB: Equatable is visible
175+
// here because conformances are not yet subject to import visibility rules.
176+
// As a result, the == requirement is technically visible and therefore there
177+
// should be no diagnostic with MemberImportVisibility enabled.
178+
_ = h1.b == h2.b
179+
_ = h1.c == h2.c
180+
}

0 commit comments

Comments
 (0)