@@ -226,29 +226,28 @@ struct LinkResolution
226
226
id: id) )
227
227
}
228
228
229
- // Scoped tests
230
229
tables. resolving ( with: . init( origin: nil ,
231
230
namespace: nil ,
232
231
context: . init( id: " ThisModule " ) ,
233
232
scope: [ " A " ] ) )
234
233
{
235
- #expect( nil != $0. outline (
236
- reference : . lexical ( ucf: Self . _string ( " f(_:)-((Int,[Int?]))->String " ) ) ) )
237
- #expect( nil != $0. outline (
238
- reference : . lexical ( ucf: Self . _string ( " f(_:)-(String)->(Int,Int) " ) ) ) )
239
- #expect( nil != $0. outline (
240
- reference : . lexical ( ucf: Self . _string ( " f(_:)-(Int)->() " ) ) ) )
241
- #expect( nil != $0. outline (
242
- reference : . lexical ( ucf: Self . _string ( " f(_:)-(String)->() " ) ) ) )
243
-
244
- #expect( nil != $0. outline (
245
- reference : . lexical ( ucf: Self . _string ( " A.f(_:)->_ " ) ) ) )
246
- #expect( nil != $0. outline (
247
- reference : . lexical ( ucf: Self . _string ( " A.f(_:)->(_,_) " ) ) ) )
248
- #expect( nil != $0. outline (
249
- reference : . lexical ( ucf: Self . _string ( " A.f(_:)-(Int) " ) ) ) )
250
- #expect( nil != $0. outline (
251
- reference : . lexical ( ucf: Self . _string ( " A.f(_:)-(String)->() " ) ) ) )
234
+ #expect( nil != $0. outline ( reference : . lexical (
235
+ ucf: Self . _string ( " f(_:)-((Int,[Int?]))->String " ) ) ) )
236
+ #expect( nil != $0. outline ( reference : . lexical (
237
+ ucf: Self . _string ( " f(_:)-(String)->(Int,Int) " ) ) ) )
238
+ #expect( nil != $0. outline ( reference : . lexical (
239
+ ucf: Self . _string ( " f(_:)-(Int)->() " ) ) ) )
240
+ #expect( nil != $0. outline ( reference : . lexical (
241
+ ucf: Self . _string ( " f(_:)-(String)->() " ) ) ) )
242
+
243
+ #expect( nil != $0. outline ( reference : . lexical (
244
+ ucf: Self . _string ( " A.f(_:)->_ " ) ) ) )
245
+ #expect( nil != $0. outline ( reference : . lexical (
246
+ ucf: Self . _string ( " A.f(_:)->(_,_) " ) ) ) )
247
+ #expect( nil != $0. outline ( reference : . lexical (
248
+ ucf: Self . _string ( " A.f(_:)-(Int) " ) ) ) )
249
+ #expect( nil != $0. outline ( reference : . lexical (
250
+ ucf: Self . _string ( " A.f(_:)-(String)->() " ) ) ) )
252
251
253
252
#expect( $0. outlines ( ) == [
254
253
. vertex( 3 , text: " f(_:) " ) ,
@@ -263,4 +262,69 @@ struct LinkResolution
263
262
] )
264
263
}
265
264
}
265
+
266
+ @Test
267
+ static func RequirementDisambiguation( )
268
+ {
269
+ var tables : SSGC . Linker . Tables = . init( )
270
+
271
+ for (i, ( name, ( inputs, output) , kinks) ) :
272
+ ( Int , ( String , ( [ String ] , [ String ] ) , Phylum . Decl . Kinks ) ) in [
273
+ ( " f(_:) " , ( [ " String " ] , [ ] ) , [ ] ) ,
274
+ ( " f(_:) " , ( [ " String " ] , [ ] ) , [ . required] ) ,
275
+ ( " f(_:) " , ( [ " Int " ] , [ ] ) , [ ] ) ,
276
+ ( " f(_:) " , ( [ " Int " ] , [ ] ) , [ . required] ) ,
277
+ ] . enumerated ( )
278
+ {
279
+ let id : Symbol . Decl = . init( . s, ascii: " \( i) " )
280
+ tables. packageLinks [ " ThisModule " , . init( [ " A " ] , name) ] . append ( . init(
281
+ phylum: . func( . instance) ,
282
+ kinks: kinks,
283
+ decl: Int32 . init ( i) ,
284
+ heir: nil ,
285
+ hash: . init( hashing: " \( id) " ) ,
286
+ documented: true ,
287
+ autograph: . init( inputs: inputs, output: output) ,
288
+ id: id) )
289
+ }
290
+
291
+ // Scoped tests
292
+ tables. resolving ( with: . init( origin: nil ,
293
+ namespace: nil ,
294
+ context: . init( id: " ThisModule " ) ,
295
+ scope: [ " A " ] ) )
296
+ {
297
+ #expect( nil == $0. outline ( reference: . lexical(
298
+ ucf: Self . _string ( " f(_:) (String) -> () [static func, requirement] " ) ) ) )
299
+ #expect( nil == $0. outline ( reference: . lexical(
300
+ ucf: Self . _string ( " f(_:) (String) -> () [static func, requirement: false] " ) ) ) )
301
+
302
+ #expect( nil != $0. outline ( reference: . lexical(
303
+ ucf: Self . _string ( " f(_:) (String) -> () [requirement] " ) ) ) )
304
+ #expect( nil != $0. outline ( reference: . lexical(
305
+ ucf: Self . _string ( " f(_:) (String) -> () [requirement: false] " ) ) ) )
306
+
307
+ #expect( nil != $0. outline ( reference: . lexical(
308
+ ucf: Self . _string ( " f(_:) (Int) -> () [requirement, func] " ) ) ) )
309
+ #expect( nil != $0. outline ( reference: . lexical(
310
+ ucf: Self . _string ( " f(_:) (Int) -> () [requirement: false, func] " ) ) ) )
311
+
312
+ #expect( nil == $0. outline ( reference: . lexical(
313
+ ucf: Self . _string ( " f(_:) (String) -> () [func] " ) ) ) )
314
+ #expect( nil == $0. outline ( reference: . lexical(
315
+ ucf: Self . _string ( " f(_:) (String) -> () [func] " ) ) ) )
316
+
317
+ #expect( nil == $0. outline ( reference: . lexical(
318
+ ucf: Self . _string ( " f(_:) (Int) -> () " ) ) ) )
319
+ #expect( nil == $0. outline ( reference: . lexical(
320
+ ucf: Self . _string ( " f(_:) (Int) -> () " ) ) ) )
321
+
322
+ #expect( $0. outlines ( ) == [
323
+ . vertex( 1 , text: " f(_:) " ) ,
324
+ . vertex( 0 , text: " f(_:) " ) ,
325
+ . vertex( 3 , text: " f(_:) " ) ,
326
+ . vertex( 2 , text: " f(_:) " ) ,
327
+ ] )
328
+ }
329
+ }
266
330
}
0 commit comments