Skip to content

Commit bdb8925

Browse files
authored
Merge pull request #26318 from nkcsgexi/52982457
AST: avoid unnecessarily calling getStartLoc() to avoid exponential growth of the stack trace
2 parents 6a30d45 + 2f9d871 commit bdb8925

File tree

2 files changed

+119
-2
lines changed

2 files changed

+119
-2
lines changed

include/swift/AST/Expr.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2422,8 +2422,9 @@ class UnresolvedDotExpr : public Expr {
24222422
}
24232423

24242424
SourceLoc getStartLoc() const {
2425-
if (SubExpr->getStartLoc().isValid())
2426-
return SubExpr->getStartLoc();
2425+
auto SubLoc = SubExpr->getStartLoc();
2426+
if (SubLoc.isValid())
2427+
return SubLoc;
24272428
else if (DotLoc.isValid())
24282429
return DotLoc;
24292430
else

test/IDE/coloring_52982457.swift

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
// To ensure walking the long chained call expression doesn't take long time to finish
2+
// RUN: %target-swift-ide-test -syntax-coloring -source-filename %s | %FileCheck %s
3+
// RUN: %target-swift-ide-test -syntax-coloring -typecheck -source-filename %s | %FileCheck %s
4+
5+
func migrate() -> EitherIO<Error, Prelude.Unit> {
6+
// CHECK: <kw>func</kw> migrate() -> <type>EitherIO</type><<type>Error</type>, <type>Prelude</type>.<type>Unit</type>> {
7+
return self.execute(
8+
"""
9+
"""
10+
)
11+
.flatMap(const(execute(
12+
"""
13+
"""
14+
)))
15+
.flatMap(const(execute(
16+
"""
17+
"""
18+
)))
19+
.flatMap(const(execute(
20+
"""
21+
"""
22+
)))
23+
.flatMap(const(execute(
24+
"""
25+
"""
26+
)))
27+
.flatMap(const(execute(
28+
"""
29+
"""
30+
)))
31+
.flatMap(const(execute(
32+
"""
33+
"""
34+
)))
35+
.flatMap(const(execute(
36+
"""
37+
"""
38+
)))
39+
.flatMap(const(execute(
40+
"""
41+
"""
42+
)))
43+
.flatMap(const(execute(
44+
"""
45+
"""
46+
)))
47+
.flatMap(const(execute(
48+
"""
49+
"""
50+
)))
51+
.flatMap(const(execute(
52+
"""
53+
"""
54+
)))
55+
.flatMap(const(execute(
56+
"""
57+
"""
58+
)))
59+
.flatMap(const(execute(
60+
"""
61+
"""
62+
)))
63+
.flatMap(const(execute(
64+
"""
65+
"""
66+
)))
67+
.flatMap(const(execute(
68+
"""
69+
"""
70+
)))
71+
.flatMap(const(execute(
72+
"""
73+
"""
74+
)))
75+
.flatMap(const(execute(
76+
"""
77+
"""
78+
)))
79+
.flatMap(const(execute(
80+
"""
81+
"""
82+
)))
83+
.flatMap(const(execute(
84+
"""
85+
"""
86+
)))
87+
.flatMap(const(execute(
88+
"""
89+
"""
90+
)))
91+
.flatMap(const(execute(
92+
"""
93+
"""
94+
)))
95+
.flatMap(const(execute(
96+
"""
97+
"""
98+
)))
99+
.flatMap(const(execute(
100+
"""
101+
"""
102+
)))
103+
.flatMap(const(execute(
104+
"""
105+
"""
106+
)))
107+
.flatMap(const(execute(
108+
"""
109+
"""
110+
)))
111+
.flatMap(const(execute(
112+
"""
113+
"""
114+
)))
115+
.map(const(unit))
116+
}

0 commit comments

Comments
 (0)