Skip to content

Commit 7691569

Browse files
committed
[SourceKit] Update completion cancellation test to a harder type checking example
#63585 will resolve rdar://80582770 and the type checker performance problem that we were relying on. Use a harder example (stolen from https://github.com/swiftlang/swift/blob/main/unittests/SourceKit/SwiftLang/CloseTest.cpp#L131-L151), that’s unlikely to get a significant performance improvement soon.
1 parent 586ac09 commit 7691569

File tree

1 file changed

+23
-7
lines changed

1 file changed

+23
-7
lines changed

test/SourceKit/CodeComplete/cancellation.swift

+23-7
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,34 @@
11
// Try and schedule the cancel the cancellation as fast as possible to cancel during the first pass
2-
// RUN: not %sourcekitd-test -req=complete -pos 15:35 %s -id=complete -async -- %s == -cancel=complete 2>&1 | %FileCheck --check-prefix=CANCEL_NO_CACHE %s
2+
// RUN: not %sourcekitd-test -req=complete -pos 31:57 %s -id=complete -async -- %s == -cancel=complete 2>&1 | %FileCheck --check-prefix=CANCEL_NO_CACHE %s
33

4-
// Wait 1 second for the first pass to complete and try to cancel during the second pass. This relies on the fact that the expression in line 12 is slow to type check (rdar://80582770)
5-
// RUN: not %sourcekitd-test -req=complete -pos 15:35 %s -id=complete -async -- %s == -shell -- sleep 1 == -cancel=complete 2>&1 | %FileCheck --check-prefix=CANCEL_NO_CACHE %s
4+
// Wait 1 second for the first pass to complete and try to cancel during the second pass. This relies on the fact that the expression in line 31 is slow to type check.
5+
// RUN: not %sourcekitd-test -req=complete -pos 31:57 %s -id=complete -async -- %s == -shell -- sleep 1 == -cancel=complete 2>&1 | %FileCheck --check-prefix=CANCEL_NO_CACHE %s
66

77
// Built an AST inside `fast(a:)` then complete the slow operation and try to cancel it.
8-
// RUN: not %sourcekitd-test -req=complete -pos 23:7 %s -- %s == -req=complete -pos 15:35 %s -id=complete -async -- %s == -cancel=complete 2>&1 | %FileCheck --check-prefix=CANCEL_CACHED %s
8+
// RUN: not %sourcekitd-test -req=complete -pos 39:7 %s -- %s == -req=complete -pos 31:57 %s -id=complete -async -- %s == -cancel=complete 2>&1 | %FileCheck --check-prefix=CANCEL_CACHED %s
99

1010
// Same as above but sleep 1 second before cancelling to make sure we are actually cancelling during the second pass.
11-
// RUN: not %sourcekitd-test -req=complete -pos 23:7 %s -- %s == -req=complete -pos 15:35 %s -id=complete -async -- %s == -shell -- sleep 1 == -cancel=complete 2>&1 | %FileCheck --check-prefix=CANCEL_CACHED %s
11+
// RUN: not %sourcekitd-test -req=complete -pos 39:7 %s -- %s == -req=complete -pos 31:57 %s -id=complete -async -- %s == -shell -- sleep 1 == -cancel=complete 2>&1 | %FileCheck --check-prefix=CANCEL_CACHED %s
12+
13+
struct A: ExpressibleByIntegerLiteral { init(integerLiteral value: Int) {} }
14+
struct B: ExpressibleByIntegerLiteral { init(integerLiteral value: Int) {} }
15+
struct C: ExpressibleByIntegerLiteral { init(integerLiteral value: Int) {} }
16+
17+
func + (lhs: A, rhs: B) -> A { fatalError() }
18+
func + (lhs: B, rhs: C) -> A { fatalError() }
19+
func + (lhs: C, rhs: A) -> A { fatalError() }
20+
21+
func + (lhs: B, rhs: A) -> B { fatalError() }
22+
func + (lhs: C, rhs: B) -> B { fatalError() }
23+
func + (lhs: A, rhs: C) -> B { fatalError() }
24+
25+
func + (lhs: C, rhs: B) -> C { fatalError() }
26+
func + (lhs: B, rhs: C) -> C { fatalError() }
27+
func + (lhs: A, rhs: A) -> C { fatalError() }
1228

1329
class Foo {
14-
func slow(x: Invalid1, y: Invalid2) {
15-
x / y / x / y / x / y / x / y.
30+
func slow() {
31+
let x: C = 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + // don't trim
1632
}
1733

1834
struct Foo {

0 commit comments

Comments
 (0)