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