Skip to content

Commit 2472e76

Browse files
committed
Move SwiftProtobufTests to using package visibility.
The fuzz testing uses an older SwiftPM manifest version that predates the addition of `package` visibility, but it appears that things still build because we're using a newer toolchain version with the support. Fixes #1784
1 parent a2f2b46 commit 2472e76

14 files changed

+23
-25
lines changed

Sources/SwiftProtobuf/Enum.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ extension Enum {
4949
///
5050
/// Since the text format and JSON names are always identical, we don't need
5151
/// to distinguish them.
52-
internal var name: _NameMap.Name? {
52+
package var name: _NameMap.Name? {
5353
guard let nameProviding = Self.self as? any _ProtoNameProviding.Type else {
5454
return nil
5555
}

Sources/SwiftProtobuf/FieldTag.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,21 @@
1919
/// improper field number (such as zero) or wire format (such as 6 or 7) to
2020
/// exist. In other words, a `FieldTag`'s properties never need to be tested
2121
/// for validity because they are guaranteed correct at initialization time.
22-
internal struct FieldTag: RawRepresentable {
22+
package struct FieldTag: RawRepresentable {
2323

24-
typealias RawValue = UInt32
24+
package typealias RawValue = UInt32
2525

2626
/// The raw numeric value of the tag, which contains both the field number and
2727
/// wire format.
28-
let rawValue: UInt32
28+
package let rawValue: UInt32
2929

3030
/// The field number component of the tag.
31-
var fieldNumber: Int {
31+
package var fieldNumber: Int {
3232
Int(rawValue >> 3)
3333
}
3434

3535
/// The wire format component of the tag.
36-
var wireFormat: WireFormat {
36+
package var wireFormat: WireFormat {
3737
// This force-unwrap is safe because there are only two initialization
3838
// paths: one that takes a WireFormat directly (and is guaranteed valid at
3939
// compile-time), or one that takes a raw value but which only lets valid
@@ -43,15 +43,15 @@ internal struct FieldTag: RawRepresentable {
4343

4444
/// A helper property that returns the number of bytes required to
4545
/// varint-encode this tag.
46-
var encodedSize: Int {
46+
package var encodedSize: Int {
4747
Varint.encodedSize(of: rawValue)
4848
}
4949

5050
/// Creates a new tag from its raw numeric representation.
5151
///
5252
/// Note that if the raw value given here is not a valid tag (for example, it
5353
/// has an invalid wire format), this initializer will fail.
54-
init?(rawValue: UInt32) {
54+
package init?(rawValue: UInt32) {
5555
// Verify that the field number and wire format are valid and fail if they
5656
// are not.
5757
guard rawValue & ~0x07 != 0,
@@ -63,7 +63,7 @@ internal struct FieldTag: RawRepresentable {
6363
}
6464

6565
/// Creates a new tag by composing the given field number and wire format.
66-
init(fieldNumber: Int, wireFormat: WireFormat) {
66+
package init(fieldNumber: Int, wireFormat: WireFormat) {
6767
self.rawValue = UInt32(truncatingIfNeeded: fieldNumber) << 3 | UInt32(wireFormat.rawValue)
6868
}
6969
}

Sources/SwiftProtobuf/NameMap.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public struct _NameMap: ExpressibleByDictionaryLiteral {
8888
/// block of UTF-8 data) where possible. In cases where the string
8989
/// has to be computed, it caches the UTF-8 bytes in an
9090
/// unmovable and immutable heap area.
91-
internal struct Name: Hashable, CustomStringConvertible {
91+
package struct Name: Hashable, CustomStringConvertible {
9292
// This should not be used outside of this file, as it requires
9393
// coordinating the lifecycle with the lifecycle of the pool
9494
// where the raw UTF8 gets interned.

Sources/SwiftProtobuf/SimpleExtensionMap.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public struct SimpleExtensionMap: ExtensionMap, ExpressibleByArrayLiteral {
1717
public typealias Element = AnyMessageExtension
1818

1919
// Since type objects aren't Hashable, we can't do much better than this...
20-
internal var fields = [Int: [any AnyMessageExtension]]()
20+
package var fields = [Int: [any AnyMessageExtension]]()
2121

2222
public init() {}
2323

Sources/SwiftProtobuf/SwiftProtobufError.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public struct SwiftProtobufError: Error, @unchecked Sendable {
6060
}
6161

6262
/// A message describing what went wrong and how it may be remedied.
63-
internal var message: String {
63+
package var message: String {
6464
get { self.storage.message }
6565
set {
6666
self.ensureStorageIsUnique()

Sources/SwiftProtobuf/UnknownStorage.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public struct UnknownStorage: Equatable, Sendable {
2929

3030
public init() {}
3131

32-
internal mutating func append(protobufData: Data) {
32+
package mutating func append(protobufData: Data) {
3333
data.append(protobufData)
3434
}
3535

Sources/SwiftProtobuf/Varint.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313
// -----------------------------------------------------------------------------
1414

1515
/// Contains helper methods to varint-encode and decode integers.
16-
internal enum Varint {
16+
package enum Varint {
1717

1818
/// Computes the number of bytes that would be needed to store a 32-bit varint.
1919
///
2020
/// - Parameter value: The number whose varint size should be calculated.
2121
/// - Returns: The size, in bytes, of the 32-bit varint.
22-
static func encodedSize(of value: UInt32) -> Int {
22+
package static func encodedSize(of value: UInt32) -> Int {
2323
if (value & (~0 << 7)) == 0 {
2424
return 1
2525
}
@@ -40,7 +40,7 @@ internal enum Varint {
4040
///
4141
/// - Parameter value: The number whose varint size should be calculated.
4242
/// - Returns: The size, in bytes, of the 32-bit varint.
43-
static func encodedSize(of value: Int32) -> Int {
43+
package static func encodedSize(of value: Int32) -> Int {
4444
if value >= 0 {
4545
return encodedSize(of: UInt32(bitPattern: value))
4646
} else {

Sources/SwiftProtobuf/WireFormat.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// -----------------------------------------------------------------------------
1414

1515
/// Denotes the wire format by which a value is encoded in binary form.
16-
internal enum WireFormat: UInt8 {
16+
package enum WireFormat: UInt8 {
1717
case varint = 0
1818
case fixed64 = 1
1919
case lengthDelimited = 2

Tests/SwiftProtobufTests/Data+TestHelpers.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
import Foundation
1212

13-
@testable import SwiftProtobuf
13+
import SwiftProtobuf
1414

1515
/// Helpers for building up wire encoding in tests.
1616
extension Data {

Tests/SwiftProtobufTests/TestHelpers.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import Foundation
1616
import XCTest
1717

18-
@testable import SwiftProtobuf
18+
import SwiftProtobuf
1919

2020
typealias XCTestFileArgType = StaticString
2121

0 commit comments

Comments
 (0)