11// RUN: %empty-directory(%t)
22// RUN: %target-build-swift %s -module-name SkipsPublicUnderscore -emit-module -emit-module-path %t/
33// RUN: %target-swift-symbolgraph-extract -module-name SkipsPublicUnderscore -I %t -pretty-print -output-dir %t
4- // RUN: %FileCheck %s --input-file %t/SkipsPublicUnderscore.symbols.json
4+ // RUN: %FileCheck %s --input-file %t/SkipsPublicUnderscore.symbols.json --check-prefix PUBLIC
5+
6+ // RUN: %target-swift-symbolgraph-extract -module-name SkipsPublicUnderscore -I %t -pretty-print -output-dir %t -minimum-access-level internal
7+ // RUN: %FileCheck %s --input-file %t/SkipsPublicUnderscore.symbols.json --check-prefix INTERNAL
8+
9+ // RUN: %target-swift-symbolgraph-extract -module-name SkipsPublicUnderscore -I %t -pretty-print -output-dir %t -minimum-access-level private
10+ // RUN: %FileCheck %s --input-file %t/SkipsPublicUnderscore.symbols.json --check-prefix PRIVATE
511
612public protocol PublicProtocol { }
713
8- // CHECK-NOT: precise:{{.*}}_ProtocolShouldntAppear
9- // CHECK-NOT: precise:{{.*}}PublicProtocol
14+ public class SomeClass {
15+ // underscored names marked `internal` or tighter should be considered `private`
16+
17+ // PUBLIC-NOT: "precise": "s:21SkipsPublicUnderscore9SomeClassC12_InternalVarSSvp"
18+ // INTERNAL-NOT: "precise": "s:21SkipsPublicUnderscore9SomeClassC12_InternalVarSSvp"
19+ // PRIVATE: "precise": "s:21SkipsPublicUnderscore9SomeClassC12_InternalVarSSvp"
20+ internal var _InternalVar : String = " "
21+ }
22+
23+ // PUBLIC-NOT: precise:{{.*}}_ProtocolShouldntAppear
24+ // PUBLIC-NOT: precise:{{.*}}PublicProtocol
1025@_show_in_interface
1126public protocol _ProtocolShouldntAppear { }
1227
13- // CHECK-NOT: _ShouldntAppear
28+ // PUBLIC-NOT: _ShouldntAppear
29+ // INTERNAL-DAG: _ShouldntAppear
1430
31+ // INTERNAL-DAG: "precise": "s:21SkipsPublicUnderscore23_ProtocolShouldntAppearP"
1532public struct _ShouldntAppear : PublicProtocol , _ProtocolShouldntAppear {
1633 // Although these are public and not underscored,
1734 // they are inside an underscored type,
1835 // so shouldn't be allowed through.
1936
20- // CHECK-NOT: shouldntAppear
37+ // PUBLIC-NOT: shouldntAppear
38+ // INTERNAL-DAG: shouldntAppear
2139 public var shouldntAppear : Int
2240
23- // CHECK-NOT: InnerShouldntAppear
41+ // PUBLIC-NOT: InnerShouldntAppear
42+ // INTERNAL-DAG: InnerShouldntAppear
2443 public struct InnerShouldntAppear {
2544
26- // CHECK-NOT: InnerInnerShouldntAppear
45+ // PUBLIC-NOT: InnerInnerShouldntAppear
46+ // INTERNAL-DAG: InnerInnerShouldntAppear
2747 public struct InnerInnerShouldntAppear { }
2848 }
2949}
@@ -34,22 +54,27 @@ public struct ShouldAppear: _ProtocolShouldntAppear {}
3454
3555public struct PublicOuter {
3656 // Nor should an "internal" type's relationship to a "public" protocol.
37- // CHECK-NOT: _InnerShouldntAppear
57+ // PUBLIC-NOT: _InnerShouldntAppear
58+ // INTERNAL-DAG: _InnerShouldntAppear
3859 public struct _InnerShouldntAppear : PublicProtocol { }
3960}
4061
4162extension PublicOuter {
42- // CHECK-NOT: _FromExtension
63+ // PUBLIC-NOT: _FromExtension
64+ // INTERNAL-DAG: _FromExtension
4365 public struct _FromExtension : PublicProtocol {
44- // CHECK-NOT: shouldntAppear
66+ // PUBLIC-NOT: shouldntAppear
67+ // INTERNAL-DAG: shouldntAppear
4568 public var shouldntAppear : Int
4669 }
4770}
4871
4972extension _ShouldntAppear {
50- // CHECK-NOT: FromExtension
73+ // PUBLIC-NOT: FromExtension
74+ // INTERNAL-DAG: FromExtension
5175 public struct FromExtension : PublicProtocol {
52- // CHECK-NOT: shouldntAppear
76+ // PUBLIC-NOT: shouldntAppear
77+ // INTERNAL-DAG: shouldntAppear
5378 public var shouldntAppear : Int
5479 }
5580}
@@ -60,4 +85,4 @@ extension _ShouldntAppear.InnerShouldntAppear {
6085
6186extension _ShouldntAppear . InnerShouldntAppear : Equatable { }
6287
63- // CHECK : "relationships": []
88+ // PUBLIC : "relationships": []
0 commit comments