File: ExternalPathHierarchyResolverTests.swift

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (965 lines) | stat: -rw-r--r-- 62,233 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
/*
 This source file is part of the Swift.org open source project

 Copyright (c) 2023-2024 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
 See https://swift.org/CONTRIBUTORS.txt for Swift project authors
*/

import XCTest
import Markdown
import SymbolKit
@testable @_spi(ExternalLinks) import SwiftDocC
import SwiftDocCTestUtilities

class ExternalPathHierarchyResolverTests: XCTestCase {
    
    private var originalFeatureFlagsState: FeatureFlags!
    
    override func setUp() {
        super.setUp()
        enableFeatureFlag(\.isExperimentalLinkHierarchySerializationEnabled)
    }
    
    // These tests resolve absolute symbol links in both a local and external context to verify that external links work the same local links.
    
    func testUnambiguousAbsolutePaths() throws {
        let linkResolvers = try makeLinkResolversForTestBundle(named: "MixedLanguageFrameworkWithLanguageRefinements")
        
        try linkResolvers.assertSuccessfullyResolves(authoredLink: "/MixedFramework")
        
        // @objc public enum MyEnum: Int {
        //     case firstCase
        //     case secondCase
        //     public func myEnumFunction() { }
        //     public typealias MyEnumTypeAlias = Int
        //     public var myEnumProperty: MyEnumTypeAlias { 0 }
        // }
        try linkResolvers.assertSuccessfullyResolves(authoredLink: "/MixedFramework/MyEnum")
        try linkResolvers.assertSuccessfullyResolves(authoredLink: "/MixedFramework/MyEnum/firstCase")
        try linkResolvers.assertSuccessfullyResolves(authoredLink: "/MixedFramework/MyEnum/secondCase")
        try linkResolvers.assertSuccessfullyResolves(authoredLink: "/MixedFramework/MyEnum/myEnumFunction()")
        try linkResolvers.assertSuccessfullyResolves(authoredLink: "/MixedFramework/MyEnum/MyEnumTypeAlias")
        try linkResolvers.assertSuccessfullyResolves(authoredLink: "/MixedFramework/MyEnum/myEnumProperty")
        
        // public struct MyStruct {
        //     public func myStructFunction() { }
        //     public typealias MyStructTypeAlias = Int
        //     public var myStructProperty: MyStructTypeAlias { 0 }
        //     public static var myStructTypeProperty: MyStructTypeAlias { 0 }
        // }
        try linkResolvers.assertSuccessfullyResolves(authoredLink: "/MixedFramework/MyStruct")
        try linkResolvers.assertSuccessfullyResolves(authoredLink: "/MixedFramework/MyStruct/myStructFunction()")
        try linkResolvers.assertSuccessfullyResolves(authoredLink: "/MixedFramework/MyStruct/MyStructTypeAlias")
        try linkResolvers.assertSuccessfullyResolves(authoredLink: "/MixedFramework/MyStruct/myStructProperty")
        try linkResolvers.assertSuccessfullyResolves(authoredLink: "/MixedFramework/MyStruct/myStructTypeProperty")
        
        // @objc public class MyClass: NSObject {
        //     @objc public func myInstanceMethod() { }
        //     @nonobjc public func mySwiftOnlyInstanceMethod() { }
        //     public typealias MyClassTypeAlias = Int
        //     public var myInstanceProperty: MyClassTypeAlias { 0 }
        //     public static var myClassTypeProperty: MyClassTypeAlias { 0 }
        // }
        try linkResolvers.assertSuccessfullyResolves(authoredLink: "/MixedFramework/MyClass")
        try linkResolvers.assertSuccessfullyResolves(authoredLink: "/MixedFramework/MyClass/myInstanceMethod()")
        try linkResolvers.assertSuccessfullyResolves(authoredLink: "/MixedFramework/MyClass/mySwiftOnlyInstanceMethod()")
        try linkResolvers.assertSuccessfullyResolves(authoredLink: "/MixedFramework/MyClass/MyClassTypeAlias")
        try linkResolvers.assertSuccessfullyResolves(authoredLink: "/MixedFramework/MyClass/myInstanceProperty")
        try linkResolvers.assertSuccessfullyResolves(authoredLink: "/MixedFramework/MyClass/myClassTypeProperty")
        
        // @objc public protocol MyObjectiveCCompatibleProtocol {
        //     func myProtocolMethod()
        //     typealias MyProtocolTypeAlias = MyClass
        //     var myProtocolProperty: MyProtocolTypeAlias { get }
        //     static var myProtocolTypeProperty: MyProtocolTypeAlias { get }
        //     @objc optional func myPropertyOptionalMethod()
        // }
        try linkResolvers.assertSuccessfullyResolves(authoredLink: "/MixedFramework/MyObjectiveCCompatibleProtocol")
        try linkResolvers.assertSuccessfullyResolves(authoredLink: "/MixedFramework/MyObjectiveCCompatibleProtocol/myProtocolMethod()")
        try linkResolvers.assertSuccessfullyResolves(authoredLink: "/MixedFramework/MyObjectiveCCompatibleProtocol/MyProtocolTypeAlias")
        try linkResolvers.assertSuccessfullyResolves(authoredLink: "/MixedFramework/MyObjectiveCCompatibleProtocol/myProtocolProperty")
        try linkResolvers.assertSuccessfullyResolves(authoredLink: "/MixedFramework/MyObjectiveCCompatibleProtocol/myProtocolTypeProperty")
        try linkResolvers.assertSuccessfullyResolves(authoredLink: "/MixedFramework/MyObjectiveCCompatibleProtocol/myPropertyOptionalMethod()")
        
        // public protocol MySwiftProtocol {
        //     func myProtocolMethod()
        //     associatedtype MyProtocolAssociatedType
        //     typealias MyProtocolTypeAlias = MyStruct
        //     var myProtocolProperty: MyProtocolAssociatedType { get }
        //     static var myProtocolTypeProperty: MyProtocolAssociatedType { get }
        // }
        try linkResolvers.assertSuccessfullyResolves(authoredLink: "/MixedFramework/MySwiftProtocol")
        try linkResolvers.assertSuccessfullyResolves(authoredLink: "/MixedFramework/MySwiftProtocol/myProtocolMethod()")
        try linkResolvers.assertSuccessfullyResolves(authoredLink: "/MixedFramework/MySwiftProtocol/MyProtocolAssociatedType")
        try linkResolvers.assertSuccessfullyResolves(authoredLink: "/MixedFramework/MySwiftProtocol/MyProtocolTypeAlias")
        try linkResolvers.assertSuccessfullyResolves(authoredLink: "/MixedFramework/MySwiftProtocol/myProtocolProperty")
        try linkResolvers.assertSuccessfullyResolves(authoredLink: "/MixedFramework/MySwiftProtocol/myProtocolTypeProperty")
        
        // public typealias MyTypeAlias = MyStruct
        try linkResolvers.assertSuccessfullyResolves(authoredLink: "/MixedFramework/MyTypeAlias")
        
        // public func myTopLevelFunction() { }
        // public var myTopLevelVariable = true
        try linkResolvers.assertSuccessfullyResolves(authoredLink: "/MixedFramework/myTopLevelFunction()")
        try linkResolvers.assertSuccessfullyResolves(authoredLink: "/MixedFramework/myTopLevelVariable")
       
        // public protocol MyOtherProtocolThatConformToMySwiftProtocol: MySwiftProtocol {
        //     func myOtherProtocolMethod()
        // }
        try linkResolvers.assertSuccessfullyResolves(authoredLink: "/MixedFramework/MyOtherProtocolThatConformToMySwiftProtocol")
        try linkResolvers.assertSuccessfullyResolves(authoredLink: "/MixedFramework/MyOtherProtocolThatConformToMySwiftProtocol/myOtherProtocolMethod()")
        
        // @objcMembers public class MyClassThatConformToMyOtherProtocol: NSObject, MyOtherProtocolThatConformToMySwiftProtocol {
        //     public func myOtherProtocolMethod() { }
        //     public func myProtocolMethod() { }
        //     public typealias MyProtocolAssociatedType = MyStruct
        //     public var myProtocolProperty: MyStruct { .init() }
        //     public class var myProtocolTypeProperty: MyStruct { .init() }
        // }
        try linkResolvers.assertSuccessfullyResolves(authoredLink: "/MixedFramework/MyClassThatConformToMyOtherProtocol")
        try linkResolvers.assertSuccessfullyResolves(authoredLink: "/MixedFramework/MyClassThatConformToMyOtherProtocol/myOtherProtocolMethod()")
        try linkResolvers.assertSuccessfullyResolves(authoredLink: "/MixedFramework/MyClassThatConformToMyOtherProtocol/myProtocolMethod()")
        try linkResolvers.assertSuccessfullyResolves(authoredLink: "/MixedFramework/MyClassThatConformToMyOtherProtocol/MyProtocolAssociatedType")
        try linkResolvers.assertSuccessfullyResolves(authoredLink: "/MixedFramework/MyClassThatConformToMyOtherProtocol/myProtocolProperty")
        try linkResolvers.assertSuccessfullyResolves(authoredLink: "/MixedFramework/MyClassThatConformToMyOtherProtocol/myProtocolTypeProperty")
        
        // public final class CollisionsWithDifferentCapitalization {
        //     public var something: Int = 0
        //     public var someThing: Int = 0
        // }
        try linkResolvers.assertSuccessfullyResolves(authoredLink: "/MixedFramework/CollisionsWithDifferentCapitalization")
        try linkResolvers.assertSuccessfullyResolves(
            authoredLink: "/MixedFramework/CollisionsWithDifferentCapitalization/something", 
            to: "doc://org.swift.MixedFramework/documentation/MixedFramework/CollisionsWithDifferentCapitalization/something-2c4k6"
        )
        try linkResolvers.assertSuccessfullyResolves(
            authoredLink: "/MixedFramework/CollisionsWithDifferentCapitalization/someThing", 
            to: "doc://org.swift.MixedFramework/documentation/MixedFramework/CollisionsWithDifferentCapitalization/someThing-90i4h"
        )
        
        // public enum CollisionsWithDifferentKinds {
        //     case something
        //     public var something: String { "" }
        //     public typealias Something = Int
        // }
        try linkResolvers.assertSuccessfullyResolves(authoredLink: "/MixedFramework/CollisionsWithDifferentKinds")
        try linkResolvers.assertSuccessfullyResolves(
            authoredLink: "/MixedFramework/CollisionsWithDifferentKinds/something-enum.case", 
            to: "doc://org.swift.MixedFramework/documentation/MixedFramework/CollisionsWithDifferentKinds/something-swift.enum.case"
        )
        try linkResolvers.assertSuccessfullyResolves(
            authoredLink: "/MixedFramework/CollisionsWithDifferentKinds/something-property", 
            to: "doc://org.swift.MixedFramework/documentation/MixedFramework/CollisionsWithDifferentKinds/something-swift.property"
        )
        try linkResolvers.assertSuccessfullyResolves(
            authoredLink: "/MixedFramework/CollisionsWithDifferentKinds/Something", 
            to: "doc://org.swift.MixedFramework/documentation/MixedFramework/CollisionsWithDifferentKinds/Something-swift.typealias"
        )
        
        // public final class CollisionsWithEscapedKeywords {
        //     public subscript() -> Int { 0 }
        //     public func `subscript`() { }
        //     public static func `subscript`() { }
        //
        //     public init() { }
        //     public func `init`() { }
        //     public static func `init`() { }
        // }
        try linkResolvers.assertSuccessfullyResolves(authoredLink: "/MixedFramework/CollisionsWithEscapedKeywords")
        try linkResolvers.assertSuccessfullyResolves(
            authoredLink: "/MixedFramework/CollisionsWithEscapedKeywords/init()-init",
            to: "doc://org.swift.MixedFramework/documentation/MixedFramework/CollisionsWithEscapedKeywords/init()-swift.init"
        )
        try linkResolvers.assertSuccessfullyResolves(
            authoredLink: "/MixedFramework/CollisionsWithEscapedKeywords/init()-method",
            to: "doc://org.swift.MixedFramework/documentation/MixedFramework/CollisionsWithEscapedKeywords/init()-swift.method"
        )
        try linkResolvers.assertSuccessfullyResolves(
            authoredLink: "/MixedFramework/CollisionsWithEscapedKeywords/init()-type.method",
            to: "doc://org.swift.MixedFramework/documentation/MixedFramework/CollisionsWithEscapedKeywords/init()-swift.type.method"
        )
        try linkResolvers.assertSuccessfullyResolves(
            authoredLink: "/MixedFramework/CollisionsWithEscapedKeywords/subscript()-subscript",
            to: "doc://org.swift.MixedFramework/documentation/MixedFramework/CollisionsWithEscapedKeywords/subscript()-swift.subscript"
        )
        try linkResolvers.assertSuccessfullyResolves(
            authoredLink: "/MixedFramework/CollisionsWithEscapedKeywords/subscript()-method",
            to: "doc://org.swift.MixedFramework/documentation/MixedFramework/CollisionsWithEscapedKeywords/subscript()-swift.method"
        )
        try linkResolvers.assertSuccessfullyResolves(
            authoredLink: "/MixedFramework/CollisionsWithEscapedKeywords/subscript()-type.method",
            to: "doc://org.swift.MixedFramework/documentation/MixedFramework/CollisionsWithEscapedKeywords/subscript()-swift.type.method"
        )
        
        // public enum CollisionsWithDifferentFunctionArguments {
        //     public func something(argument: Int) -> Int { 0 }
        //     public func something(argument: String) -> Int { 0 }
        // }
        try linkResolvers.assertSuccessfullyResolves(authoredLink: "/MixedFramework/CollisionsWithDifferentFunctionArguments")
        try linkResolvers.assertSuccessfullyResolves(authoredLink: "/MixedFramework/CollisionsWithDifferentFunctionArguments/something(argument:)-1cyvp")
        try linkResolvers.assertSuccessfullyResolves(authoredLink: "/MixedFramework/CollisionsWithDifferentFunctionArguments/something(argument:)-2vke2")
       
        // public enum CollisionsWithDifferentSubscriptArguments {
        //     public subscript(something: Int) -> Int { 0 }
        //     public subscript(somethingElse: String) -> Int { 0 }
        // }
        try linkResolvers.assertSuccessfullyResolves(authoredLink: "/MixedFramework/CollisionsWithDifferentSubscriptArguments")
        try linkResolvers.assertSuccessfullyResolves(authoredLink: "/MixedFramework/CollisionsWithDifferentSubscriptArguments/subscript(_:)-4fd0l")
        try linkResolvers.assertSuccessfullyResolves(authoredLink: "/MixedFramework/CollisionsWithDifferentSubscriptArguments/subscript(_:)-757cj")
        
        // @objc(MySwiftClassObjectiveCName)
        // public class MySwiftClassSwiftName: NSObject {
        //     @objc(myPropertyObjectiveCName)
        //     public var myPropertySwiftName: Int { 0 }
        //
        //     @objc(myMethodObjectiveCName)
        //     public func myMethodSwiftName() -> Int { 0 }
        // }
        try linkResolvers.assertSuccessfullyResolves(authoredLink: "/MixedFramework/MySwiftClassSwiftName")
        try linkResolvers.assertSuccessfullyResolves(authoredLink: "/MixedFramework/MySwiftClassSwiftName/myPropertySwiftName")
        try linkResolvers.assertSuccessfullyResolves(authoredLink: "/MixedFramework/MySwiftClassSwiftName/myMethodSwiftName()")
        
        try linkResolvers.assertSuccessfullyResolves(
            authoredLink: "/MixedFramework/MySwiftClassObjectiveCName",
            to: "doc://org.swift.MixedFramework/documentation/MixedFramework/MySwiftClassSwiftName"
        )
        try linkResolvers.assertSuccessfullyResolves(
            authoredLink: "/MixedFramework/MySwiftClassObjectiveCName/myPropertyObjectiveCName",
            to: "doc://org.swift.MixedFramework/documentation/MixedFramework/MySwiftClassSwiftName/myPropertySwiftName"
        )
        try linkResolvers.assertSuccessfullyResolves(
            authoredLink: "/MixedFramework/MySwiftClassObjectiveCName/myMethodObjectiveCName",
            to: "doc://org.swift.MixedFramework/documentation/MixedFramework/MySwiftClassSwiftName/myMethodSwiftName()"
        )
        
        // NS_SWIFT_NAME(MyObjectiveCClassSwiftName)
        // @interface MyObjectiveCClassObjectiveCName : NSObject
        //
        // @property (copy, readonly) NSString * myPropertyObjectiveCName NS_SWIFT_NAME(myPropertySwiftName);
        //
        // - (void)myMethodObjectiveCName NS_SWIFT_NAME(myMethodSwiftName());
        // - (void)myMethodWithArgument:(NSString *)argument NS_SWIFT_NAME(myMethod(argument:));
        //
        // @end
        try linkResolvers.assertSuccessfullyResolves(authoredLink: "/MixedFramework/MyObjectiveCClassSwiftName")
        try linkResolvers.assertSuccessfullyResolves(authoredLink: "/MixedFramework/MyObjectiveCClassSwiftName/myPropertySwiftName")
        try linkResolvers.assertSuccessfullyResolves(authoredLink: "/MixedFramework/MyObjectiveCClassSwiftName/myMethodSwiftName()")
        try linkResolvers.assertSuccessfullyResolves(authoredLink: "/MixedFramework/MyObjectiveCClassSwiftName/myMethod(argument:)")
        
        try linkResolvers.assertSuccessfullyResolves(
            authoredLink: "/MixedFramework/MyObjectiveCClassObjectiveCName",
            to: "doc://org.swift.MixedFramework/documentation/MixedFramework/MyObjectiveCClassSwiftName"
        )
        try linkResolvers.assertSuccessfullyResolves(
            authoredLink: "/MixedFramework/MyObjectiveCClassObjectiveCName/myPropertyObjectiveCName",
            to: "doc://org.swift.MixedFramework/documentation/MixedFramework/MyObjectiveCClassSwiftName/myPropertySwiftName"
        )
        try linkResolvers.assertSuccessfullyResolves(
            authoredLink: "/MixedFramework/MyObjectiveCClassObjectiveCName/myMethodObjectiveCName",
            to: "doc://org.swift.MixedFramework/documentation/MixedFramework/MyObjectiveCClassSwiftName/myMethodSwiftName()"
        )
        try linkResolvers.assertSuccessfullyResolves(
            authoredLink: "/MixedFramework/MyObjectiveCClassObjectiveCName/myMethodWithArgument:",
            to: "doc://org.swift.MixedFramework/documentation/MixedFramework/MyObjectiveCClassSwiftName/myMethod(argument:)"
        )
        
        // typedef NS_ENUM(NSInteger, MyObjectiveCEnum) {
        //     MyObjectiveCEnumFirst,
        //     MyObjectiveCEnumSecond NS_SWIFT_NAME(secondCaseSwiftName)
        // };
        try linkResolvers.assertSuccessfullyResolves(authoredLink: "/MixedFramework/MyObjectiveCEnum")
        try linkResolvers.assertSuccessfullyResolves(authoredLink: "/MixedFramework/MyObjectiveCEnum/first")
        try linkResolvers.assertSuccessfullyResolves(authoredLink: "/MixedFramework/MyObjectiveCEnum/secondCaseSwiftName")
        
        try linkResolvers.assertSuccessfullyResolves(
            authoredLink: "/MixedFramework/MyObjectiveCEnum/MyObjectiveCEnumFirst",
            to: "doc://org.swift.MixedFramework/documentation/MixedFramework/MyObjectiveCEnum/first"
        )
        try linkResolvers.assertSuccessfullyResolves(
            authoredLink: "/MixedFramework/MyObjectiveCEnum/MyObjectiveCEnumSecond",
            to: "doc://org.swift.MixedFramework/documentation/MixedFramework/MyObjectiveCEnum/secondCaseSwiftName"
        )
        
        // typedef NS_ENUM(NSInteger, MyObjectiveCEnumObjectiveCName) {
        //     MyObjectiveCEnumObjectiveCNameFirst,
        //     MyObjectiveCEnumObjectiveCNameSecond NS_SWIFT_NAME(secondCaseSwiftName)
        // } NS_SWIFT_NAME(MyObjectiveCEnumSwiftName);
        try linkResolvers.assertSuccessfullyResolves(authoredLink: "/MixedFramework/MyObjectiveCEnumSwiftName")
        try linkResolvers.assertSuccessfullyResolves(authoredLink: "/MixedFramework/MyObjectiveCEnumSwiftName/first")
        try linkResolvers.assertSuccessfullyResolves(authoredLink: "/MixedFramework/MyObjectiveCEnumSwiftName/secondCaseSwiftName")
        
        try linkResolvers.assertSuccessfullyResolves(
            authoredLink: "/MixedFramework/MyObjectiveCEnumObjectiveCName",
            to: "doc://org.swift.MixedFramework/documentation/MixedFramework/MyObjectiveCEnumSwiftName"
        )
        try linkResolvers.assertSuccessfullyResolves(
            authoredLink: "/MixedFramework/MyObjectiveCEnumObjectiveCName/MyObjectiveCEnumObjectiveCNameFirst",
            to: "doc://org.swift.MixedFramework/documentation/MixedFramework/MyObjectiveCEnumSwiftName/first"
        )
        try linkResolvers.assertSuccessfullyResolves(
            authoredLink: "/MixedFramework/MyObjectiveCEnumObjectiveCName/MyObjectiveCEnumObjectiveCNameSecond",
            to: "doc://org.swift.MixedFramework/documentation/MixedFramework/MyObjectiveCEnumSwiftName/secondCaseSwiftName"
        )
        
        // typedef NS_OPTIONS(NSInteger, MyObjectiveCOption) {
        //     MyObjectiveCOptionNone                                      = 0,
        //     MyObjectiveCOptionFirst                                     = 1 << 0,
        //     MyObjectiveCOptionSecond NS_SWIFT_NAME(secondCaseSwiftName) = 1 << 1
        // };
        try linkResolvers.assertSuccessfullyResolves(authoredLink: "/MixedFramework/MyObjectiveCOption")
        try linkResolvers.assertSuccessfullyResolves(authoredLink: "/MixedFramework/MyObjectiveCOption/first")
        try linkResolvers.assertSuccessfullyResolves(authoredLink: "/MixedFramework/MyObjectiveCOption/secondCaseSwiftName")
        
        try linkResolvers.assertSuccessfullyResolves(authoredLink: "/MixedFramework/MyObjectiveCOption/MyObjectiveCOptionNone")
        try linkResolvers.assertSuccessfullyResolves(
            authoredLink: "/MixedFramework/MyObjectiveCOption/MyObjectiveCOptionFirst",
            to: "doc://org.swift.MixedFramework/documentation/MixedFramework/MyObjectiveCOption/first"
        )
        try linkResolvers.assertSuccessfullyResolves(
            authoredLink: "/MixedFramework/MyObjectiveCOption/MyObjectiveCOptionSecond",
            to: "doc://org.swift.MixedFramework/documentation/MixedFramework/MyObjectiveCOption/secondCaseSwiftName"
        )
        
        // typedef NSInteger MyTypedObjectiveCEnum NS_TYPED_ENUM;
        //
        // MyTypedObjectiveCEnum const MyTypedObjectiveCEnumFirst;
        // MyTypedObjectiveCEnum const MyTypedObjectiveCEnumSecond;
        try linkResolvers.assertSuccessfullyResolves(authoredLink: "/MixedFramework/MyTypedObjectiveCEnum")
        try linkResolvers.assertSuccessfullyResolves(authoredLink: "/MixedFramework/MyTypedObjectiveCEnum/first")
        try linkResolvers.assertSuccessfullyResolves(authoredLink: "/MixedFramework/MyTypedObjectiveCEnum/second")
        
        try linkResolvers.assertSuccessfullyResolves(
            authoredLink: "/MixedFramework/MyTypedObjectiveCEnumFirst",
            to: "doc://org.swift.MixedFramework/documentation/MixedFramework/MyTypedObjectiveCEnum/first"
        )
        try linkResolvers.assertSuccessfullyResolves(
            authoredLink: "/MixedFramework/MyTypedObjectiveCEnumSecond",
            to: "doc://org.swift.MixedFramework/documentation/MixedFramework/MyTypedObjectiveCEnum/second"
        )
        
        // typedef NSInteger MyTypedObjectiveCExtensibleEnum NS_TYPED_EXTENSIBLE_ENUM;
        //
        // MyTypedObjectiveCExtensibleEnum const MyTypedObjectiveCExtensibleEnumFirst;
        // MyTypedObjectiveCExtensibleEnum const MyTypedObjectiveCExtensibleEnumSecond;
        try linkResolvers.assertSuccessfullyResolves(authoredLink: "/MixedFramework/MyTypedObjectiveCExtensibleEnum")
        try linkResolvers.assertSuccessfullyResolves(authoredLink: "/MixedFramework/MyTypedObjectiveCExtensibleEnum/first")
        try linkResolvers.assertSuccessfullyResolves(authoredLink: "/MixedFramework/MyTypedObjectiveCExtensibleEnum/second")
        
        try linkResolvers.assertSuccessfullyResolves(
            authoredLink: "/MixedFramework/MyTypedObjectiveCExtensibleEnumFirst",
            to: "doc://org.swift.MixedFramework/documentation/MixedFramework/MyTypedObjectiveCExtensibleEnum/first"
        )
        try linkResolvers.assertSuccessfullyResolves(
            authoredLink: "/MixedFramework/MyTypedObjectiveCExtensibleEnumSecond",
            to: "doc://org.swift.MixedFramework/documentation/MixedFramework/MyTypedObjectiveCExtensibleEnum/second"
        )
    }
    
    func testAmbiguousPaths() throws {
        let linkResolvers = try makeLinkResolversForTestBundle(named: "MixedLanguageFrameworkWithLanguageRefinements")
        
        // public enum CollisionsWithDifferentKinds {
        //     case something
        //     public var something: String { "" }
        //     public typealias Something = Int
        // }
        try linkResolvers.assertFailsToResolve(
            authoredLink: "/MixedFramework/CollisionsWithDifferentKinds/something",
            errorMessage: "'something' is ambiguous at '/MixedFramework/CollisionsWithDifferentKinds'",
            solutions: [
                .init(summary: "Insert 'enum.case' for\n'case something'", replacement: ("-enum.case", 54, 54)),
                .init(summary: "Insert 'property' for\n'var something: String { get }'", replacement: ("-property", 54, 54)),
            ]
        )
        
        try linkResolvers.assertFailsToResolve(
            authoredLink: "/MixedFramework/CollisionsWithDifferentKinds/something-class",
            errorMessage: "'class' isn't a disambiguation for 'something' at '/MixedFramework/CollisionsWithDifferentKinds'",
            solutions: [
                .init(summary: "Replace '-class' with '-enum.case' for\n'case something'", replacement: ("-enum.case", 54, 60)),
                .init(summary: "Replace '-class' with '-property' for\n'var something: String { get }'", replacement: ("-property", 54, 60)),
            ]
        )
 
        // public final class CollisionsWithEscapedKeywords {
        //     public subscript() -> Int { 0 }
        //     public func `subscript`() { }
        //     public static func `subscript`() { }
        //
        //     public init() { }
        //     public func `init`() { }
        //     public static func `init`() { }
        // }
        
        try linkResolvers.assertFailsToResolve(
            authoredLink: "/MixedFramework/CollisionsWithEscapedKeywords/init()",
            errorMessage: "'init()' is ambiguous at '/MixedFramework/CollisionsWithEscapedKeywords'",
            solutions: [
                .init(summary: "Insert 'method' for\n'func `init`()'", replacement: ("-method", 52, 52)),
                .init(summary: "Insert 'init' for\n'init()'", replacement: ("-init", 52, 52)),
                .init(summary: "Insert 'type.method' for\n'static func `init`()'", replacement: ("-type.method", 52, 52)),
            ]
        )
        try linkResolvers.assertFailsToResolve(
            authoredLink: "/MixedFramework/CollisionsWithEscapedKeywords/init()-abc123",
            errorMessage: "'abc123' isn't a disambiguation for 'init()' at '/MixedFramework/CollisionsWithEscapedKeywords'",
            solutions: [
                .init(summary: "Replace '-abc123' with '-method' for\n'func `init`()'", replacement: ("-method", 52, 59)),
                .init(summary: "Replace '-abc123' with '-init' for\n'init()'", replacement: ("-init", 52, 59)),
                .init(summary: "Replace '-abc123' with '-type.method' for\n'static func `init`()'", replacement: ("-type.method", 52, 59)),
            ]
        )
        // Providing disambiguation will narrow down the suggestions. Note that `()` is missing in the last path component
        try linkResolvers.assertFailsToResolve(
            authoredLink: "/MixedFramework/CollisionsWithEscapedKeywords/init-method",
            errorMessage: "'init-method' doesn't exist at '/MixedFramework/CollisionsWithEscapedKeywords'",
            solutions: [
                .init(summary: "Replace 'init' with 'init()'", replacement: ("init()", 46, 50)), // The disambiguation is not replaced so the suggested link is unambiguous
            ]
        )
        try linkResolvers.assertFailsToResolve(
            authoredLink: "/MixedFramework/CollisionsWithEscapedKeywords/init-init",
            errorMessage: "'init-init' doesn't exist at '/MixedFramework/CollisionsWithEscapedKeywords'",
            solutions: [
                .init(summary: "Replace 'init' with 'init()'", replacement: ("init()", 46, 50)), // The disambiguation is not replaced so the suggested link is unambiguous
            ]
        )
        try linkResolvers.assertFailsToResolve(
            authoredLink: "/MixedFramework/CollisionsWithEscapedKeywords/init-type.method",
            errorMessage: "'init-type.method' doesn't exist at '/MixedFramework/CollisionsWithEscapedKeywords'",
            solutions: [
                .init(summary: "Replace 'init' with 'init()'", replacement: ("init()", 46, 50)), // The disambiguation is not replaced so the suggested link is unambiguous
            ]
        )
        
        try linkResolvers.assertFailsToResolve(
            authoredLink: "/MixedFramework/CollisionsWithEscapedKeywords/subscript()",
            errorMessage: "'subscript()' is ambiguous at '/MixedFramework/CollisionsWithEscapedKeywords'",
            solutions: [
                .init(summary: "Insert 'method' for\n'func `subscript`()'", replacement: ("-method", 57, 57)),
                .init(summary: "Insert 'type.method' for\n'static func `subscript`()'", replacement: ("-type.method", 57, 57)),
                .init(summary: "Insert 'subscript' for\n'subscript() -> Int { get }'", replacement: ("-subscript", 57, 57)),
            ]
        )
        
        // public enum CollisionsWithDifferentFunctionArguments {
        //     public func something(argument: Int) -> Int { 0 }
        //     public func something(argument: String) -> Int { 0 }
        // }
        try linkResolvers.assertFailsToResolve(
            authoredLink: "/MixedFramework/CollisionsWithDifferentFunctionArguments/something(argument:)",
            errorMessage: "'something(argument:)' is ambiguous at '/MixedFramework/CollisionsWithDifferentFunctionArguments'",
            solutions: [
                .init(summary: "Insert '1cyvp' for\n'func something(argument: Int) -> Int'", replacement: ("-1cyvp", 77, 77)),
                .init(summary: "Insert '2vke2' for\n'func something(argument: String) -> Int'", replacement: ("-2vke2", 77, 77)),
            ]
        )
        try linkResolvers.assertFailsToResolve(
            authoredLink: "/documentation/MixedFramework/CollisionsWithDifferentFunctionArguments/something(argument:)",
            errorMessage: "'something(argument:)' is ambiguous at '/MixedFramework/CollisionsWithDifferentFunctionArguments'",
            solutions: [
                .init(summary: "Insert '1cyvp' for\n'func something(argument: Int) -> Int'", replacement: ("-1cyvp", 91, 91)),
                .init(summary: "Insert '2vke2' for\n'func something(argument: String) -> Int'", replacement: ("-2vke2", 91, 91)),
            ]
        )
        try linkResolvers.assertFailsToResolve(
            authoredLink: "/MixedFramework/CollisionsWithDifferentFunctionArguments/something(argument:)-abc123",
            errorMessage: "'abc123' isn't a disambiguation for 'something(argument:)' at '/MixedFramework/CollisionsWithDifferentFunctionArguments'",
            solutions: [
                .init(summary: "Replace '-abc123' with '-1cyvp' for\n'func something(argument: Int) -> Int'", replacement: ("-1cyvp", 77, 84)),
                .init(summary: "Replace '-abc123' with '-2vke2' for\n'func something(argument: String) -> Int'", replacement: ("-2vke2", 77, 84)),
            ]
        )
        // Providing disambiguation will narrow down the suggestions. Note that `argument` label is missing in the last path component
        try linkResolvers.assertFailsToResolve(
            authoredLink: "/MixedFramework/CollisionsWithDifferentFunctionArguments/something(_:)-1cyvp",
            errorMessage: "'something(_:)-1cyvp' doesn't exist at '/MixedFramework/CollisionsWithDifferentFunctionArguments'",
            solutions: [
                .init(summary: "Replace 'something(_:)' with 'something(argument:)'", replacement: ("something(argument:)", 57, 70)), // The disambiguation is not replaced so the suggested link is unambiguous
            ]
        )
        try linkResolvers.assertFailsToResolve(
            authoredLink: "/MixedFramework/CollisionsWithDifferentFunctionArguments/something(_:)-2vke2",
            errorMessage: "'something(_:)-2vke2' doesn't exist at '/MixedFramework/CollisionsWithDifferentFunctionArguments'",
            solutions: [
                .init(summary: "Replace 'something(_:)' with 'something(argument:)'", replacement: ("something(argument:)", 57, 70)), // The disambiguation is not replaced so the suggested link is unambiguous
            ]
        )
        try linkResolvers.assertFailsToResolve(
            authoredLink: "/MixedFramework/CollisionsWithDifferentFunctionArguments/something(argument:)-method",
            errorMessage: "'something(argument:)-method' is ambiguous at '/MixedFramework/CollisionsWithDifferentFunctionArguments'",
            solutions: [
                .init(summary: "Replace 'method' with '1cyvp' for\n'func something(argument: Int) -> Int'", replacement: ("-1cyvp", 77, 84)),
                .init(summary: "Replace 'method' with '2vke2' for\n'func something(argument: String) -> Int'", replacement: ("-2vke2", 77, 84)),
            ]
        )
        try linkResolvers.assertFailsToResolve(
            authoredLink: "/documentation/MixedFramework/CollisionsWithDifferentFunctionArguments/something(argument:)-method",
            errorMessage: "'something(argument:)-method' is ambiguous at '/MixedFramework/CollisionsWithDifferentFunctionArguments'",
            solutions: [
                .init(summary: "Replace 'method' with '1cyvp' for\n'func something(argument: Int) -> Int'", replacement: ("-1cyvp", 91, 98)),
                .init(summary: "Replace 'method' with '2vke2' for\n'func something(argument: String) -> Int'", replacement: ("-2vke2", 91, 98)),
            ]
        )
        
        // public enum CollisionsWithDifferentSubscriptArguments {
        //     public subscript(something: Int) -> Int { 0 }
        //     public subscript(somethingElse: String) -> Int { 0 }
        // }
        try linkResolvers.assertFailsToResolve(
            authoredLink: "/MixedFramework/CollisionsWithDifferentSubscriptArguments/subscript(_:)",
            errorMessage: "'subscript(_:)' is ambiguous at '/MixedFramework/CollisionsWithDifferentSubscriptArguments'",
            solutions: [
                .init(summary: "Insert '4fd0l' for\n'subscript(something: Int) -> Int { get }'", replacement: ("-4fd0l", 71, 71)),
                .init(summary: "Insert '757cj' for\n'subscript(somethingElse: String) -> Int { get }'", replacement: ("-757cj", 71, 71)),
            ]
        )
        try linkResolvers.assertFailsToResolve(
            authoredLink: "/MixedFramework/CollisionsWithDifferentSubscriptArguments/subscript(_:)-subscript",
            errorMessage: "'subscript(_:)-subscript' is ambiguous at '/MixedFramework/CollisionsWithDifferentSubscriptArguments'",
            solutions: [
                .init(summary: "Replace 'subscript' with '4fd0l' for\n'subscript(something: Int) -> Int { get }'", replacement: ("-4fd0l", 71, 81)),
                .init(summary: "Replace 'subscript' with '757cj' for\n'subscript(somethingElse: String) -> Int { get }'", replacement: ("-757cj", 71, 81)),
            ]
        )
    }
    
    func testRedundantDisambiguations() throws {
        let linkResolvers = try makeLinkResolversForTestBundle(named: "MixedLanguageFrameworkWithLanguageRefinements")
        
        try linkResolvers.assertSuccessfullyResolves(authoredLink: "/MixedFramework")
        
        // @objc public enum MyEnum: Int {
        //     case firstCase
        //     case secondCase
        //     public func myEnumFunction() { }
        //     public typealias MyEnumTypeAlias = Int
        //     public var myEnumProperty: MyEnumTypeAlias { 0 }
        // }
        try linkResolvers.assertSuccessfullyResolves(
            authoredLink: "/MixedFramework-module-9r7pl/MyEnum-enum-1m96o",
            to: "doc://org.swift.MixedFramework/documentation/MixedFramework/MyEnum"
        )
        try linkResolvers.assertSuccessfullyResolves(
            authoredLink: "/MixedFramework-module-9r7pl/MyEnum-enum-1m96o/firstCase-enum.case-5ocr4",
            to: "doc://org.swift.MixedFramework/documentation/MixedFramework/MyEnum/firstCase"
        )
        try linkResolvers.assertSuccessfullyResolves(
            authoredLink: "/MixedFramework-module-9r7pl/MyEnum-enum-1m96o/secondCase-enum.case-ihyt",
            to: "doc://org.swift.MixedFramework/documentation/MixedFramework/MyEnum/secondCase"
        )
        try linkResolvers.assertSuccessfullyResolves(
            authoredLink: "/MixedFramework-module-9r7pl/MyEnum-enum-1m96o/myEnumFunction()-method-2pa9q",
            to: "doc://org.swift.MixedFramework/documentation/MixedFramework/MyEnum/myEnumFunction()"
        )
        try linkResolvers.assertSuccessfullyResolves(
            authoredLink: "/MixedFramework-module-9r7pl/MyEnum-enum-1m96o/MyEnumTypeAlias-typealias-5ejt4",
            to: "doc://org.swift.MixedFramework/documentation/MixedFramework/MyEnum/MyEnumTypeAlias"
        )
        try linkResolvers.assertSuccessfullyResolves(
            authoredLink: "/MixedFramework-module-9r7pl/MyEnum-enum-1m96o/myEnumProperty-property-6cz2q",
            to: "doc://org.swift.MixedFramework/documentation/MixedFramework/MyEnum/myEnumProperty"
        )
        
        // public struct MyStruct {
        //     public func myStructFunction() { }
        //     public typealias MyStructTypeAlias = Int
        //     public var myStructProperty: MyStructTypeAlias { 0 }
        //     public static var myStructTypeProperty: MyStructTypeAlias { 0 }
        // }
        try linkResolvers.assertSuccessfullyResolves(
            authoredLink: "/MixedFramework-module-9r7pl/MyStruct-struct-23xcd",
            to: "doc://org.swift.MixedFramework/documentation/MixedFramework/MyStruct"
        )
        try linkResolvers.assertSuccessfullyResolves(
            authoredLink: "/MixedFramework-module-9r7pl/MyStruct-struct-23xcd/myStructFunction()-method-9p92r",
            to: "doc://org.swift.MixedFramework/documentation/MixedFramework/MyStruct/myStructFunction()"
        )
        try linkResolvers.assertSuccessfullyResolves(
            authoredLink: "/MixedFramework-module-9r7pl/MyStruct-struct-23xcd/MyStructTypeAlias-typealias-630hf",
            to: "doc://org.swift.MixedFramework/documentation/MixedFramework/MyStruct/MyStructTypeAlias"
        )
        try linkResolvers.assertSuccessfullyResolves(
            authoredLink: "/MixedFramework-module-9r7pl/MyStruct-struct-23xcd/myStructProperty-property-5ywbx",
            to: "doc://org.swift.MixedFramework/documentation/MixedFramework/MyStruct/myStructProperty"
        )
        try linkResolvers.assertSuccessfullyResolves(
            authoredLink: "/MixedFramework-module-9r7pl/MyStruct-struct-23xcd/myStructTypeProperty-type.property-8ti6m",
            to: "doc://org.swift.MixedFramework/documentation/MixedFramework/MyStruct/myStructTypeProperty"
        )
        
        // public protocol MySwiftProtocol {
        //     func myProtocolMethod()
        //     associatedtype MyProtocolAssociatedType
        //     typealias MyProtocolTypeAlias = MyStruct
        //     var myProtocolProperty: MyProtocolAssociatedType { get }
        //     static var myProtocolTypeProperty: MyProtocolAssociatedType { get }
        // }
        try linkResolvers.assertSuccessfullyResolves(
            authoredLink: "/MixedFramework-module-9r7pl/MySwiftProtocol-protocol-xmee",
            to: "doc://org.swift.MixedFramework/documentation/MixedFramework/MySwiftProtocol"
        )
        try linkResolvers.assertSuccessfullyResolves(
            authoredLink: "/MixedFramework-module-9r7pl/MySwiftProtocol-protocol-xmee/myProtocolMethod()-method-6srz6",
            to: "doc://org.swift.MixedFramework/documentation/MixedFramework/MySwiftProtocol/myProtocolMethod()"
        )
        try linkResolvers.assertSuccessfullyResolves(
            authoredLink: "/MixedFramework-module-9r7pl/MySwiftProtocol-protocol-xmee/MyProtocolAssociatedType-associatedtype-33siz",
            to: "doc://org.swift.MixedFramework/documentation/MixedFramework/MySwiftProtocol/MyProtocolAssociatedType"
        )
        try linkResolvers.assertSuccessfullyResolves(
            authoredLink: "/MixedFramework-module-9r7pl/MySwiftProtocol-protocol-xmee/MyProtocolTypeAlias-typealias-9rpv6",
            to: "doc://org.swift.MixedFramework/documentation/MixedFramework/MySwiftProtocol/MyProtocolTypeAlias"
        )
        try linkResolvers.assertSuccessfullyResolves(
            authoredLink: "/MixedFramework-module-9r7pl/MySwiftProtocol-protocol-xmee/myProtocolProperty-property-qer2",
            to: "doc://org.swift.MixedFramework/documentation/MixedFramework/MySwiftProtocol/myProtocolProperty"
        )
        try linkResolvers.assertSuccessfullyResolves(
            authoredLink: "/MixedFramework-module-9r7pl/MySwiftProtocol-protocol-xmee/myProtocolTypeProperty-type.property-8h7hm",
            to: "doc://org.swift.MixedFramework/documentation/MixedFramework/MySwiftProtocol/myProtocolTypeProperty"
        )
        
        // public func myTopLevelFunction() { }
        // public var myTopLevelVariable = true
        try linkResolvers.assertSuccessfullyResolves(
            authoredLink: "/MixedFramework-module-9r7pl/myTopLevelFunction()-func-55lhl",
            to: "doc://org.swift.MixedFramework/documentation/MixedFramework/myTopLevelFunction()"
        )
        try linkResolvers.assertSuccessfullyResolves(
            authoredLink: "/MixedFramework-module-9r7pl/myTopLevelVariable-var-520ez",
            to: "doc://org.swift.MixedFramework/documentation/MixedFramework/myTopLevelVariable"
        )
    }
    
    func testSymbolLinksInDeclarationsAndRelationships() throws {
        // Build documentation for the dependency first
        let symbols = [("First", .class), ("Second", .protocol), ("Third", .struct), ("Fourth", .enum)].map { (name: String, kind: SymbolGraph.Symbol.KindIdentifier) in
            return SymbolGraph.Symbol(
                identifier: .init(precise: "dependency-\(name.lowercased())-symbol-id", interfaceLanguage: SourceLanguage.swift.id),
                names: .init(title: name, navigator: nil, subHeading: nil, prose: nil),
                pathComponents: [name],
                docComment: nil,
                accessLevel: .public,
                kind: .init(parsedIdentifier: kind, displayName: "Kind Display Name"),
                mixins: [:]
            )
        }
        
        let (dependencyBundle, dependencyContext) = try loadBundle(
            catalog: Folder(name: "Dependency.docc", content: [
                InfoPlist(identifier: "com.example.dependency"), // This isn't necessary but makes it easier to distinguish the identifier from the module name in the external references.
                JSONFile(name: "Dependency.symbols.json", content: makeSymbolGraph(moduleName: "Dependency", symbols: symbols))
            ])
        )
        
        // Retrieve the link information from the dependency, as if '--enable-experimental-external-link-support' was passed to DocC
        let dependencyConverter = DocumentationContextConverter(bundle: dependencyBundle, context: dependencyContext, renderContext: .init(documentationContext: dependencyContext, bundle: dependencyBundle))
        
        let linkSummaries: [LinkDestinationSummary] = try dependencyContext.knownPages.flatMap { reference in
            let entity = try dependencyContext.entity(with: reference)
            let renderNode = try XCTUnwrap(dependencyConverter.renderNode(for: entity, at: nil))
            
            return entity.externallyLinkableElementSummaries(context: dependencyContext, renderNode: renderNode, includeTaskGroups: false)
        }
        let linkResolutionInformation = try dependencyContext.linkResolver.localResolver.prepareForSerialization(bundleID: dependencyBundle.identifier)
        
        XCTAssertEqual(linkResolutionInformation.pathHierarchy.nodes.count - linkResolutionInformation.nonSymbolPaths.count, 5 /* 4 symbols & 1 module */)
        XCTAssertEqual(linkSummaries.count, 5 /* 4 symbols & 1 module */)
        
        // After building the dependency,
        let (mainBundle, mainContext) = try loadBundle(
            catalog: Folder(name: "Main.docc", content: [
                JSONFile(name: "Main.symbols.json", content: makeSymbolGraph(
                    moduleName: "Main",
                    symbols: [
                        // import Dependency
                        //
                        // public class SomeClass: Dependency.First, Dependency.Second {
                        //     public func someFunction(parameter: Dependency.Third) -> Dependency.Fourth {}
                        // }
                        SymbolGraph.Symbol(
                            identifier: .init(precise: "main-container-symbol-id", interfaceLanguage: SourceLanguage.swift.id),
                            names: .init(title: "SomeClass", navigator: nil, subHeading: nil, prose: nil),
                            pathComponents: ["SomeClass"],
                            docComment: nil,
                            accessLevel: .public,
                            kind: .init(parsedIdentifier: .class, displayName: "Kind Display Name"),
                            mixins: [
                                // "class SomeClass"
                                SymbolGraph.Symbol.DeclarationFragments.mixinKey: SymbolGraph.Symbol.DeclarationFragments(declarationFragments: [
                                    .init(kind: .keyword, spelling: "class", preciseIdentifier: nil),
                                    .init(kind: .text, spelling: " ", preciseIdentifier: nil),
                                    .init(kind: .identifier, spelling: "SomeClass", preciseIdentifier: nil),
                                ])
                            ]
                        ),
                        SymbolGraph.Symbol(
                            identifier: .init(precise: "main-member-symbol-id", interfaceLanguage: SourceLanguage.swift.id),
                            names: .init(title: "someFunction(parameter:)", navigator: nil, subHeading: nil, prose: nil),
                            pathComponents: ["SomeClass", "someFunction(parameter:)"],
                            docComment: nil,
                            accessLevel: .public,
                            kind: .init(parsedIdentifier: .func, displayName: "Kind Display Name"),
                            mixins: [
                                // "func someFunction(parameter: Third) -> Fourth"
                                SymbolGraph.Symbol.DeclarationFragments.mixinKey: SymbolGraph.Symbol.DeclarationFragments(declarationFragments: [
                                    .init(kind: .keyword, spelling: "func", preciseIdentifier: nil),
                                    .init(kind: .text, spelling: " ", preciseIdentifier: nil),
                                    .init(kind: .identifier, spelling: "someFunction", preciseIdentifier: nil),
                                    .init(kind: .text, spelling: "(", preciseIdentifier: nil),
                                    .init(kind: .externalParameter, spelling: "paramater", preciseIdentifier: nil),
                                    .init(kind: .text, spelling: ": ", preciseIdentifier: nil),
                                    .init(kind: .typeIdentifier, spelling: "Third", preciseIdentifier: "dependency-third-symbol-id"),
                                    .init(kind: .text, spelling: ") -> ", preciseIdentifier: nil),
                                    .init(kind: .typeIdentifier, spelling: "Fourth", preciseIdentifier: "dependency-fourth-symbol-id"),
                                ])
                            ]
                        ),
                    ],
                    relationships: [
                        // 'someFunction(parameter:)' is a member of 'SomeClass'
                        .init(source: "main-member-symbol-id", target: "main-container-symbol-id", kind: .memberOf, targetFallback: nil),
                        // 'SomeClass' inherits from 'Dependency.First'
                        .init(source: "main-container-symbol-id", target: "dependency-first-symbol-id", kind: .inheritsFrom, targetFallback: "Dependency.First"),
                        // 'SomeClass' conforms to 'Dependency.Second'
                        .init(source: "main-container-symbol-id", target: "dependency-second-symbol-id", kind: .conformsTo, targetFallback: "Dependency.Second"),
                    ]
                ))
            ]),
            otherFileSystemDirectories: [
                Folder(name: "Dependency.doccarchive", content: [
                    JSONFile(name: "linkable-entities.json", content: linkSummaries),
                    JSONFile(name: "link-hierarchy.json", content: linkResolutionInformation),
                ])
            ],
            configureContext: {
                $0.linkResolver.dependencyArchives = [URL(fileURLWithPath: "/Dependency.doccarchive")]
            }
        )
        
        XCTAssertEqual(mainContext.knownPages.count, 3 /* 2 symbols & 1 module*/)
        
        let mainConverter = DocumentationContextConverter(bundle: mainBundle, context: mainContext, renderContext: .init(documentationContext: mainContext, bundle: mainBundle))
        
        // Check the relationships of 'SomeClass'
        do {
            let reference = ResolvedTopicReference(bundleIdentifier: mainBundle.identifier, path: "/documentation/Main/SomeClass", sourceLanguage: .swift)
            let entity = try mainContext.entity(with: reference)
            let renderNode = try XCTUnwrap(mainConverter.renderNode(for: entity, at: nil))
            
            XCTAssertEqual(renderNode.relationshipSections.count, 2)
            let inheritsFromSection = try XCTUnwrap(renderNode.relationshipSections.first)
            XCTAssertEqual(inheritsFromSection.title, "Inherits From")
            XCTAssertEqual(inheritsFromSection.identifiers, ["doc://com.example.dependency/documentation/Dependency/First"])
            
            let conformsToSection = try XCTUnwrap(renderNode.relationshipSections.last)
            XCTAssertEqual(conformsToSection.title, "Conforms To")
            XCTAssertEqual(conformsToSection.identifiers, ["doc://com.example.dependency/documentation/Dependency/Second"])
            
            let firstReference = try XCTUnwrap(renderNode.references["doc://com.example.dependency/documentation/Dependency/First"] as? TopicRenderReference)
            XCTAssertEqual(firstReference.title, "First")
            XCTAssertEqual(firstReference.role, RenderMetadata.Role.symbol.rawValue)
            
            let secondReference = try XCTUnwrap(renderNode.references["doc://com.example.dependency/documentation/Dependency/Second"] as? TopicRenderReference)
            XCTAssertEqual(secondReference.title, "Second")
            XCTAssertEqual(secondReference.role, RenderMetadata.Role.symbol.rawValue)
        }
        
        // Check the declaration of 'someFunction'
        do {
            let reference = ResolvedTopicReference(bundleIdentifier: mainBundle.identifier, path: "/documentation/Main/SomeClass/someFunction(parameter:)", sourceLanguage: .swift)
            let entity = try mainContext.entity(with: reference)
            let renderNode = try XCTUnwrap(mainConverter.renderNode(for: entity, at: nil))
            
            XCTAssertEqual(renderNode.primaryContentSections.count, 1)
            let declarationSection = try XCTUnwrap(renderNode.primaryContentSections.first as? DeclarationsRenderSection)
            XCTAssertEqual(declarationSection.declarations.count, 1)
            XCTAssertEqual(declarationSection.declarations.first?.tokens, [
                .init(text: "func", kind: .keyword),
                .init(text: " ", kind: .text),
                .init(text: "someFunction", kind: .identifier),
                .init(text: "(", kind: .text),
                .init(text: "paramater", kind: .externalParam),
                .init(text: ": ", kind: .text),
                .init(text: "Third", kind: .typeIdentifier, identifier: "doc://com.example.dependency/documentation/Dependency/Third", preciseIdentifier: "dependency-third-symbol-id"),
                .init(text: ") -> ", kind: .text),
                .init(text: "Fourth", kind: .typeIdentifier, identifier: "doc://com.example.dependency/documentation/Dependency/Fourth", preciseIdentifier: "dependency-fourth-symbol-id"),
            ])
            
            let thirdReference = try XCTUnwrap(renderNode.references["doc://com.example.dependency/documentation/Dependency/Third"] as? TopicRenderReference)
            XCTAssertEqual(thirdReference.title, "Third")
            XCTAssertEqual(thirdReference.role, RenderMetadata.Role.symbol.rawValue)
            
            let fourthReference = try XCTUnwrap(renderNode.references["doc://com.example.dependency/documentation/Dependency/Fourth"] as? TopicRenderReference)
            XCTAssertEqual(fourthReference.title, "Fourth")
            XCTAssertEqual(fourthReference.role, RenderMetadata.Role.symbol.rawValue)
        }
    }

    func testOverloadGroupSymbolsResolveWithoutHash() throws {
        enableFeatureFlag(\.isExperimentalOverloadedSymbolPresentationEnabled)

        let linkResolvers = try makeLinkResolversForTestBundle(named: "OverloadedSymbols")

        // The enum case should continue to resolve by kind, since it has no hash collision
        try linkResolvers.assertSuccessfullyResolves(authoredLink: "/ShapeKit/OverloadedEnum/firstTestMemberName(_:)-swift.enum.case")

        // The overloaded enum method should now be able to resolve by kind, which will point to the overload group
        try linkResolvers.assertSuccessfullyResolves(
            authoredLink: "/ShapeKit/OverloadedEnum/firstTestMemberName(_:)-method",
            to: "doc://com.shapes.ShapeKit/documentation/ShapeKit/OverloadedEnum/firstTestMemberName(_:)-8v5g7"
        )

        // This overloaded protocol method should be able to resolve without a suffix at all, since it doesn't conflict with anything
        try linkResolvers.assertSuccessfullyResolves(
            authoredLink: "/ShapeKit/OverloadedProtocol/fourthTestMemberName(test:)",
            to: "doc://com.shapes.ShapeKit/documentation/ShapeKit/OverloadedProtocol/fourthTestMemberName(test:)-9b6be"
        )
    }
    
    func testBetaInformationPreserved() throws {
        let platformMetadata = [
            "macOS": PlatformVersion(VersionTriplet(1, 0, 0), beta: true),
            "watchOS": PlatformVersion(VersionTriplet(2, 0, 0), beta: true),
            "tvOS": PlatformVersion(VersionTriplet(3, 0, 0), beta: true),
            "iOS": PlatformVersion(VersionTriplet(4, 0, 0), beta: true),
            "Mac Catalyst": PlatformVersion(VersionTriplet(4, 0, 0), beta: true),
            "iPadOS": PlatformVersion(VersionTriplet(4, 0, 0), beta: true),
        ]
        let linkResolvers = try makeLinkResolversForTestBundle(named: "AvailabilityBetaBundle") { context in
            context.externalMetadata.currentPlatforms = platformMetadata
        }
        
        // MyClass is only available on beta platforms (macos=1.0.0, watchos=2.0.0, tvos=3.0.0, ios=4.0.0)
        try linkResolvers.assertBetaStatus(authoredLink: "/MyKit/MyClass", isBeta: true)
        
        // MyOtherClass is available on some beta platforms (macos=1.0.0, watchos=2.0.0, tvos=3.0.0, ios=3.0.0)
        try linkResolvers.assertBetaStatus(authoredLink: "/MyKit/MyOtherClass", isBeta: false)
        
        // MyThirdClass has no platform availability information
        try linkResolvers.assertBetaStatus(authoredLink: "/MyKit/MyThirdClass", isBeta: false)

    }

    // MARK: Test helpers
    
    struct LinkResolvers {
        let localResolver: PathHierarchyBasedLinkResolver
        let externalResolver: ExternalPathHierarchyResolver
        let context: DocumentationContext
        
        func assertResults(authoredLink: String, verification: (TopicReferenceResolutionResult, String) throws -> Void) throws {
            let unresolvedReference = try XCTUnwrap(ValidatedURL(parsingAuthoredLink: authoredLink).map(UnresolvedTopicReference.init(topicURL:)))
            let rootModule = try XCTUnwrap(context.soleRootModuleReference)
            
            let linkResolver = LinkResolver()
            linkResolver.localResolver = localResolver
            let localResult = linkResolver.resolve(unresolvedReference, in: rootModule, fromSymbolLink: true, context: context)
            let externalResult = externalResolver.resolve(unresolvedReference, fromSymbolLink: true)
            
            try verification(localResult, "local")
            try verification(externalResult, "external")
        }
        
        func assertSuccessfullyResolves(
            authoredLink: String,
            to absoluteReferenceString: String? = nil,
            file: StaticString = #file,
            line: UInt = #line
        ) throws {
            let expectedAbsoluteReferenceString = absoluteReferenceString ?? {
                context.soleRootModuleReference!.url
                    .deletingLastPathComponent() // Remove the module name
                    .appendingPathComponent(authoredLink.trimmingCharacters(in: ["/"])) // Append the authored link, without leading slashes
                    .absoluteString
            }()
            
            try assertResults(authoredLink: authoredLink) { result, label in
                switch result {
                case .success(let resolved):
                    XCTAssertEqual(resolved.absoluteString, expectedAbsoluteReferenceString, label, file: file, line: line)
                case .failure(_, let errorInfo):
                    XCTFail("Unexpectedly failed to resolve \(label) link: \(errorInfo.message) \(errorInfo.solutions.map(\.summary).joined(separator: ", "))", file: file, line: line)
                }
            }
        }
        
        func assertBetaStatus(
            authoredLink: String,
            isBeta: Bool,
            file: StaticString = #file,
            line: UInt = #line
        ) throws {
            try assertResults(authoredLink: authoredLink) { result, label in
                switch result {
                case .success(let resolved):
                    let entity = externalResolver.entity(resolved)
                    XCTAssertEqual(entity.topicRenderReference.isBeta, isBeta, file: file, line: line)
                case .failure(_, let errorInfo):
                    XCTFail("Unexpectedly failed to resolve \(label) link: \(errorInfo.message) \(errorInfo.solutions.map(\.summary).joined(separator: ", "))", file: file, line: line)
                }
            }
        }
        
        func assertFailsToResolve(
            authoredLink: String,
            errorMessage: String,
            solutions: [Solution],
            file: StaticString = #file,
            line: UInt = #line
        ) throws {
           try assertResults(authoredLink: authoredLink) { result, label in
                switch result {
                case .success:
                    XCTFail("Unexpectedly resolved link with wrong module name for \(label)", file: file, line: line)
                case .failure(_, let errorInfo):
                    XCTAssertEqual(errorInfo.message, errorMessage, label, file: file, line: line)
                    XCTAssertEqual(errorInfo.solutions.count, solutions.count, "Unexpected number of solutions for \(label) link", file: file, line: line)
                    for (actualSolution, expectedSolution) in zip(errorInfo.solutions, solutions) {
                        XCTAssertEqual(actualSolution.summary, expectedSolution.summary, label, file: file, line: line)
                        let replacement = try XCTUnwrap(actualSolution.replacements.first)
                        
                        XCTAssertEqual(replacement.replacement, expectedSolution.replacement.0, label, file: file, line: line)
                        XCTAssertEqual(replacement.range.lowerBound.column, expectedSolution.replacement.1, label, file: file, line: line)
                        XCTAssertEqual(replacement.range.upperBound.column, expectedSolution.replacement.2, label, file: file, line: line)
                    }
                }
            }
        }
        
        struct Solution {
            var summary: String
            var replacement: (String, Int, Int)
        }
    }
    
    private func makeLinkResolversForTestBundle(named testBundleName: String, configureContext: ((DocumentationContext) throws -> Void)? = nil) throws -> LinkResolvers {
        let bundleURL = try XCTUnwrap(Bundle.module.url(forResource: testBundleName, withExtension: "docc", subdirectory: "Test Bundles"))
        let (_, bundle, context) = try loadBundle(from: bundleURL, configureContext: configureContext)
        
        let localResolver = try XCTUnwrap(context.linkResolver.localResolver)
        
        let resolverInfo = try localResolver.prepareForSerialization(bundleID: bundle.identifier)
        let resolverData = try JSONEncoder().encode(resolverInfo)
        let roundtripResolverInfo = try JSONDecoder().decode(SerializableLinkResolutionInformation.self, from: resolverData)
        
        var entitySummaries = [LinkDestinationSummary]()
        let converter = DocumentationNodeConverter(bundle: bundle, context: context)
        for reference in context.knownPages {
            let node = try context.entity(with: reference)
            let renderNode = try converter.convert(node, at: nil)
            entitySummaries.append(contentsOf: node.externallyLinkableElementSummaries(context: context, renderNode: renderNode, includeTaskGroups: false))
        }
        
        let externalResolver = ExternalPathHierarchyResolver(
            linkInformation: roundtripResolverInfo,
            entityInformation: entitySummaries
        )
        
        return LinkResolvers(localResolver: localResolver, externalResolver: externalResolver, context: context)
    }
}