@@ -2317,6 +2317,114 @@ final class DeclarationTests: ParserTestCase {
2317
2317
)
2318
2318
)
2319
2319
2320
+ assertParse (
2321
+ """
2322
+ let _: any ~Copyable = 0
2323
+ """ ,
2324
+ substructure: SomeOrAnyTypeSyntax (
2325
+ someOrAnySpecifier: . keyword( . any) ,
2326
+ constraint: SuppressedTypeSyntax (
2327
+ withoutTilde: . prefixOperator( " ~ " ) ,
2328
+ type: TypeSyntax ( stringLiteral: " Copyable " )
2329
+ )
2330
+ )
2331
+ )
2332
+
2333
+ assertParse (
2334
+ """
2335
+ typealias Z = ~Copyable.Type
2336
+ """ ,
2337
+ substructure: SuppressedTypeSyntax (
2338
+ withoutTilde: . prefixOperator( " ~ " ) ,
2339
+ type: MetatypeTypeSyntax (
2340
+ baseType: TypeSyntax ( stringLiteral: " Copyable " ) ,
2341
+ metatypeSpecifier: . keyword( . Type)
2342
+ )
2343
+ )
2344
+ )
2345
+
2346
+ assertParse (
2347
+ """
2348
+ typealias Z = ~A.B.C
2349
+ """ ,
2350
+ substructure: SuppressedTypeSyntax (
2351
+ withoutTilde: . prefixOperator( " ~ " ) ,
2352
+ type: MemberTypeSyntax (
2353
+ baseType: MemberTypeSyntax (
2354
+ baseType: TypeSyntax ( stringLiteral: " A " ) ,
2355
+ name: . identifier( " B " )
2356
+ ) ,
2357
+ name: . identifier( " C " )
2358
+ )
2359
+ )
2360
+ )
2361
+
2362
+ assertParse (
2363
+ """
2364
+ typealias Z = ~A?
2365
+ """ ,
2366
+ substructure: SuppressedTypeSyntax (
2367
+ withoutTilde: . prefixOperator( " ~ " ) ,
2368
+ type: OptionalTypeSyntax (
2369
+ wrappedType: IdentifierTypeSyntax ( name: . identifier( " A " ) )
2370
+ )
2371
+ )
2372
+ )
2373
+
2374
+ assertParse (
2375
+ """
2376
+ typealias Z = ~A<T>
2377
+ """ ,
2378
+ substructure: SuppressedTypeSyntax (
2379
+ withoutTilde: . prefixOperator( " ~ " ) ,
2380
+ type: IdentifierTypeSyntax (
2381
+ name: . identifier( " A " ) ,
2382
+ genericArgumentClause: GenericArgumentClauseSyntax (
2383
+ arguments: GenericArgumentListSyntax ( [
2384
+ GenericArgumentSyntax (
2385
+ argument:
2386
+ IdentifierTypeSyntax ( name: . identifier( " T " ) )
2387
+ )
2388
+ ] )
2389
+ )
2390
+ )
2391
+ )
2392
+ )
2393
+
2394
+ assertParse (
2395
+ """
2396
+ struct Hello<T: ~Copyable> {}
2397
+ """ ,
2398
+ substructure: GenericParameterListSyntax ( [
2399
+ GenericParameterSyntax (
2400
+ attributes: AttributeListSyntax ( [ ] ) ,
2401
+ name: . identifier( " T " ) ,
2402
+ colon: . colonToken( ) ,
2403
+ inheritedType: SuppressedTypeSyntax (
2404
+ withoutTilde: . prefixOperator( " ~ " ) ,
2405
+ type: TypeSyntax ( stringLiteral: " Copyable " )
2406
+ )
2407
+ )
2408
+ ] )
2409
+ )
2410
+
2411
+ assertParse (
2412
+ """
2413
+ func henlo<T: ~Copyable>(_ t: T) {}
2414
+ """ ,
2415
+ substructure: GenericParameterListSyntax ( [
2416
+ GenericParameterSyntax (
2417
+ attributes: AttributeListSyntax ( [ ] ) ,
2418
+ name: . identifier( " T " ) ,
2419
+ colon: . colonToken( ) ,
2420
+ inheritedType: SuppressedTypeSyntax (
2421
+ withoutTilde: . prefixOperator( " ~ " ) ,
2422
+ type: TypeSyntax ( stringLiteral: " Copyable " )
2423
+ )
2424
+ )
2425
+ ] )
2426
+ )
2427
+
2320
2428
assertParse (
2321
2429
"""
2322
2430
enum Whatever: Int, ~ Hashable, Equatable {}
@@ -2342,7 +2450,7 @@ final class DeclarationTests: ParserTestCase {
2342
2450
2343
2451
assertParse (
2344
2452
"""
2345
- typealias T = ~1️⃣Int 2️⃣-> Bool
2453
+ typealias T = 1️⃣~Int 2️⃣-> Bool
2346
2454
""" ,
2347
2455
diagnostics: [
2348
2456
DiagnosticSpec (
@@ -2357,20 +2465,24 @@ final class DeclarationTests: ParserTestCase {
2357
2465
) ,
2358
2466
] ,
2359
2467
fixedSource: """
2360
- typealias T = ~( Int) -> Bool
2468
+ typealias T = (~ Int) -> Bool
2361
2469
"""
2362
2470
)
2363
2471
2364
2472
assertParse (
2365
2473
"""
2366
- typealias T = ~( Int) -> Bool
2474
+ typealias T = (~ Int) -> Bool
2367
2475
""" ,
2368
- substructure: SuppressedTypeSyntax (
2369
- withoutTilde: . prefixOperator( " ~ " ) ,
2370
- type: FunctionTypeSyntax (
2371
- parameters: [ TupleTypeElementSyntax ( type: TypeSyntax ( " Int " ) ) ] ,
2372
- returnClause: ReturnClauseSyntax ( type: TypeSyntax ( " Bool " ) )
2373
- )
2476
+ substructure: FunctionTypeSyntax (
2477
+ parameters: [
2478
+ TupleTypeElementSyntax (
2479
+ type: SuppressedTypeSyntax (
2480
+ withoutTilde: . prefixOperator( " ~ " ) ,
2481
+ type: IdentifierTypeSyntax ( name: . identifier( " Int " ) )
2482
+ )
2483
+ )
2484
+ ] ,
2485
+ returnClause: ReturnClauseSyntax ( type: TypeSyntax ( " Bool " ) )
2374
2486
)
2375
2487
)
2376
2488
}
0 commit comments