File tree Expand file tree Collapse file tree 3 files changed +35
-3
lines changed Expand file tree Collapse file tree 3 files changed +35
-3
lines changed Original file line number Diff line number Diff line change @@ -1715,6 +1715,10 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
1715
1715
inFlight.fixItInsert (ID->getStartLoc (),
1716
1716
" @_implementationOnly " );
1717
1717
}
1718
+
1719
+ static bool treatAsError = getenv (" ENABLE_PUBLIC_IMPORT_OF_PRIVATE_AS_ERROR" );
1720
+ if (!treatAsError)
1721
+ inFlight.limitBehavior (DiagnosticBehavior::Warning);
1718
1722
}
1719
1723
}
1720
1724
}
Original file line number Diff line number Diff line change
1
+ /// Same test as implementation-only-import-suggestion upgrading warnings to
2
+ /// errors. We can remove this test when this becomes the default behavior.
3
+
4
+ // RUN: %empty-directory(%t)
5
+ // REQUIRES: VENDOR=apple
6
+
7
+ /// Prepare the SDK.
8
+ // RUN: cp -r %S/Inputs/public-private-sdk %t/sdk
9
+ // RUN: %target-swift-frontend -emit-module -module-name PublicSwift \
10
+ // RUN: %t/sdk/System/Library/Frameworks/PublicSwift.framework/Modules/PublicSwift.swiftmodule/source.swift \
11
+ // RUN: -o %t/sdk/System/Library/Frameworks/PublicSwift.framework/Modules/PublicSwift.swiftmodule/%target-swiftmodule-name
12
+ // RUN: %target-swift-frontend -emit-module -module-name PrivateSwift \
13
+ // RUN: %t/sdk/System/Library/PrivateFrameworks/PrivateSwift.framework/Modules/PrivateSwift.swiftmodule/source.swift \
14
+ // RUN: -o %t/sdk/System/Library/PrivateFrameworks/PrivateSwift.framework/Modules/PrivateSwift.swiftmodule/%target-swiftmodule-name
15
+
16
+ /// Expect errors when building a public client.
17
+ // RUN: env ENABLE_PUBLIC_IMPORT_OF_PRIVATE_AS_ERROR=1 \
18
+ // RUN: %target-swift-frontend -typecheck -sdk %t/sdk -module-cache-path %t %s \
19
+ // RUN: -F %t/sdk/System/Library/PrivateFrameworks/ \
20
+ // RUN: -library-level api -verify
21
+
22
+ import PublicSwift
23
+ import PrivateSwift // expected-error{{private module 'PrivateSwift' is imported publicly from the public module 'main'}}
24
+
25
+ import PublicClang
26
+ import PublicClang_Private // expected-error{{private module 'PublicClang_Private' is imported publicly from the public module 'main'}}
27
+ import FullyPrivateClang // expected-error{{private module 'FullyPrivateClang' is imported publicly from the public module 'main'}}
28
+ import main // expected-warning{{'implementation-only-import-suggestion-as-error.swift' is part of module 'main'; ignoring import}}
Original file line number Diff line number Diff line change 34
34
// RUN: -library-level other -D PUBLIC_IMPORTS
35
35
#if PUBLIC_IMPORTS
36
36
import PublicSwift
37
- import PrivateSwift // expected-error {{private module 'PrivateSwift' is imported publicly from the public module 'main'}}
37
+ import PrivateSwift // expected-warning {{private module 'PrivateSwift' is imported publicly from the public module 'main'}}
38
38
39
39
import PublicClang
40
- import PublicClang_Private // expected-error {{private module 'PublicClang_Private' is imported publicly from the public module 'main'}}
41
- import FullyPrivateClang // expected-error {{private module 'FullyPrivateClang' is imported publicly from the public module 'main'}}
40
+ import PublicClang_Private // expected-warning {{private module 'PublicClang_Private' is imported publicly from the public module 'main'}}
41
+ import FullyPrivateClang // expected-warning {{private module 'FullyPrivateClang' is imported publicly from the public module 'main'}}
42
42
import main // expected-warning{{'implementation-only-import-suggestion.swift' is part of module 'main'; ignoring import}}
43
43
44
44
/// Expect no warnings with implementation-only imports.
You can’t perform that action at this time.
0 commit comments