Skip to content

Commit

Permalink
Return error if implementationOnlyImports is enabled with public visi…
Browse files Browse the repository at this point in the history
…bility
  • Loading branch information
gjcairo authored and thomasvl committed Jun 2, 2023
1 parent e6112f7 commit f4b911d
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Sources/protoc-gen-swift/FileGenerator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,15 @@ class FileGenerator {

p.print("import Foundation\n")

if self.generatorOptions.implementationOnlyImports,
self.generatorOptions.visibility == .public {
errorString = """
Cannot use @_implementationOnly imports when the proto visibility is public.
Either change the visibility to internal, or disable @_implementationOnly imports.
"""
return
}

// Import all other imports as @_implementationOnly if the visiblity is
// internal and the option is set, to avoid exposing internal types to users.
let visibilityAnnotation: String = {
Expand Down

0 comments on commit f4b911d

Please sign in to comment.