From f4b911d3148dbdab54ab8ffec012db51b1f676f8 Mon Sep 17 00:00:00 2001 From: Gus Cairo Date: Wed, 3 May 2023 16:50:23 +0100 Subject: [PATCH] Return error if implementationOnlyImports is enabled with public visibility --- Sources/protoc-gen-swift/FileGenerator.swift | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Sources/protoc-gen-swift/FileGenerator.swift b/Sources/protoc-gen-swift/FileGenerator.swift index 3aa749359..90fd06a69 100644 --- a/Sources/protoc-gen-swift/FileGenerator.swift +++ b/Sources/protoc-gen-swift/FileGenerator.swift @@ -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 = {