Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions Sources/SymbolKit/SymbolGraph/Module.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
This source file is part of the Swift.org open source project

Copyright (c) 2021 Apple Inc. and the Swift project authors
Copyright (c) 2021-2025 Apple Inc. and the Swift project authors
Licensed under Apache License v2.0 with Runtime Library Exception

See https://swift.org/LICENSE.txt for license information
Expand Down Expand Up @@ -40,7 +40,9 @@ extension SymbolGraph {
public init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
self.name = try container.decode(String.self, forKey: .name)
self.bystanders = try container.decodeIfPresent([String].self, forKey: .bystanders)
if let bystanders = try container.decodeIfPresent([String].self, forKey: .bystanders) {
self.bystanders = bystanders.isEmpty ? nil : bystanders
}
self.platform = try container.decode(Platform.self, forKey: .platform)
self.version = try container.decodeIfPresent(SemanticVersion.self, forKey: .version)
self.isVirtual = try container.decodeIfPresent(Bool.self, forKey: .isVirtual) ?? false
Expand Down
7 changes: 7 additions & 0 deletions Tests/SymbolKitTests/SymbolGraph/ModuleTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ class ModuleTests: XCTestCase {
let decodedModule = try module.roundTripDecode()
XCTAssertEqual(["A"], decodedModule.bystanders)
}

do {
// bystanders = []
let module = SymbolGraph.Module(name: "Test", platform: ModuleTests.platform, bystanders: [])
let decodedModule = try module.roundTripDecode()
XCTAssertNil(decodedModule.bystanders)
}
}

func testOptionalIsVirtual() throws {
Expand Down