File tree Expand file tree Collapse file tree 2 files changed +11
-2
lines changed
Sources/SymbolKit/SymbolGraph
Tests/SymbolKitTests/SymbolGraph Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change 11/*
22 This source file is part of the Swift.org open source project
33
4- Copyright (c) 2021 Apple Inc. and the Swift project authors
4+ Copyright (c) 2021-2025 Apple Inc. and the Swift project authors
55 Licensed under Apache License v2.0 with Runtime Library Exception
66
77 See https://swift.org/LICENSE.txt for license information
@@ -40,7 +40,9 @@ extension SymbolGraph {
4040 public init ( from decoder: Decoder ) throws {
4141 let container = try decoder. container ( keyedBy: CodingKeys . self)
4242 self . name = try container. decode ( String . self, forKey: . name)
43- self . bystanders = try container. decodeIfPresent ( [ String ] . self, forKey: . bystanders)
43+ if let bystanders = try container. decodeIfPresent ( [ String ] . self, forKey: . bystanders) {
44+ self . bystanders = bystanders. isEmpty ? nil : bystanders
45+ }
4446 self . platform = try container. decode ( Platform . self, forKey: . platform)
4547 self . version = try container. decodeIfPresent ( SemanticVersion . self, forKey: . version)
4648 self . isVirtual = try container. decodeIfPresent ( Bool . self, forKey: . isVirtual) ?? false
Original file line number Diff line number Diff line change @@ -44,6 +44,13 @@ class ModuleTests: XCTestCase {
4444 let decodedModule = try module. roundTripDecode ( )
4545 XCTAssertEqual ( [ " A " ] , decodedModule. bystanders)
4646 }
47+
48+ do {
49+ // bystanders = []
50+ let module = SymbolGraph . Module ( name: " Test " , platform: ModuleTests . platform, bystanders: [ ] )
51+ let decodedModule = try module. roundTripDecode ( )
52+ XCTAssertNil ( decodedModule. bystanders)
53+ }
4754 }
4855
4956 func testOptionalIsVirtual( ) throws {
You can’t perform that action at this time.
0 commit comments