@@ -1398,8 +1398,24 @@ final class BackgroundIndexingTests: XCTestCase {
1398
1398
_ = try await SwiftPMTestProject (
1399
1399
files: [
1400
1400
" Test.swift " : """
1401
- func slow(x: Invalid1, y: Invalid2) {
1402
- x / y / x / y / x / y / x / y
1401
+ struct A: ExpressibleByIntegerLiteral { init(integerLiteral value: Int) {} }
1402
+ struct B: ExpressibleByIntegerLiteral { init(integerLiteral value: Int) {} }
1403
+ struct C: ExpressibleByIntegerLiteral { init(integerLiteral value: Int) {} }
1404
+
1405
+ func + (lhs: A, rhs: B) -> A { fatalError() }
1406
+ func + (lhs: B, rhs: C) -> A { fatalError() }
1407
+ func + (lhs: C, rhs: A) -> A { fatalError() }
1408
+
1409
+ func + (lhs: B, rhs: A) -> B { fatalError() }
1410
+ func + (lhs: C, rhs: B) -> B { fatalError() }
1411
+ func + (lhs: A, rhs: C) -> B { fatalError() }
1412
+
1413
+ func + (lhs: C, rhs: B) -> C { fatalError() }
1414
+ func + (lhs: B, rhs: C) -> C { fatalError() }
1415
+ func + (lhs: A, rhs: A) -> C { fatalError() }
1416
+
1417
+ func slow() {
1418
+ let x: C = 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10
1403
1419
}
1404
1420
"""
1405
1421
] ,
@@ -1408,10 +1424,10 @@ final class BackgroundIndexingTests: XCTestCase {
1408
1424
)
1409
1425
// Creating the `SwiftPMTestProject` implicitly waits for background indexing to finish.
1410
1426
// Preparation of `Test.swift` should finish instantly because it doesn't type check the function body.
1411
- // Type-checking the body relies on rdar://80582770, which makes the line hard to type check. We should hit the
1412
- // timeout of 1s. Adding another 2s to escalate a SIGINT (to which swift-frontend doesn't respond) to a SIGKILL mean
1413
- // that the initial indexing should be done in ~3s. 30s should be enough to always finish within this time while
1414
- // also testing that we don't wait for type checking of Test.swift to finish.
1427
+ // Type-checking of `slow()` should be slow because the expression has exponential complexity in the type checker.
1428
+ // We should hit the timeout of 1s. Adding another 2s to escalate a SIGINT (to which swift-frontend doesn't respond)
1429
+ // to a SIGKILL mean that the initial indexing should be done in ~3s. 30s should be enough to always finish within
1430
+ // this time while also testing that we don't wait for type checking of Test.swift to finish.
1415
1431
XCTAssert ( Date ( ) . timeIntervalSince ( dateStarted) < 30 )
1416
1432
}
1417
1433
0 commit comments