Skip to content

Commit c69d459

Browse files
gjcairothomasvl
authored andcommitted
Return error if implementationOnlyImports is enabled with public visibility
1 parent 6b33e90 commit c69d459

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

Sources/protoc-gen-swift/FileGenerator.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,15 @@ class FileGenerator {
9090

9191
p.print("\(comments)import Foundation")
9292

93+
if self.generatorOptions.implementationOnlyImports,
94+
self.generatorOptions.visibility == .public {
95+
errorString = """
96+
Cannot use @_implementationOnly imports when the proto visibility is public.
97+
Either change the visibility to internal, or disable @_implementationOnly imports.
98+
"""
99+
return
100+
}
101+
93102
// Import all other imports as @_implementationOnly if the visiblity is
94103
// internal and the option is set, to avoid exposing internal types to users.
95104
let visibilityAnnotation: String = {

0 commit comments

Comments
 (0)