Skip to content

Commit f86ebde

Browse files
authored
Fix exponential-time handling of @This in CalledMethodsChecker (#7043)
1 parent 181e962 commit f86ebde

2 files changed

Lines changed: 164 additions & 1 deletion

File tree

checker/src/main/java/org/checkerframework/checker/calledmethods/CalledMethodsAnnotatedTypeFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ filterTree, collectionsSingletonList, getProcessingEnv())) {
293293
* At a fluent method call (which returns {@code this}), add the method to the type of the return
294294
* value.
295295
*/
296-
private class CalledMethodsTreeAnnotator extends AccumulationTreeAnnotator {
296+
private class CalledMethodsTreeAnnotator extends TreeAnnotator {
297297
/**
298298
* Creates an instance of this tree annotator for the given type factory.
299299
*
Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
// Earlier versions of the Checker Framework exhibited exponentially-long run time on this code due
2+
// to the long chain of `@This` methods.
3+
4+
import org.checkerframework.common.returnsreceiver.qual.*;
5+
6+
class ReturnsReceiverPerformance {
7+
8+
static class Builder {
9+
@This Builder m01() {
10+
return this;
11+
}
12+
13+
@This Builder m02() {
14+
return this;
15+
}
16+
17+
@This Builder m03() {
18+
return this;
19+
}
20+
21+
@This Builder m04() {
22+
return this;
23+
}
24+
25+
@This Builder m05() {
26+
return this;
27+
}
28+
29+
@This Builder m06() {
30+
return this;
31+
}
32+
33+
@This Builder m07() {
34+
return this;
35+
}
36+
37+
@This Builder m08() {
38+
return this;
39+
}
40+
41+
@This Builder m09() {
42+
return this;
43+
}
44+
45+
@This Builder m10() {
46+
return this;
47+
}
48+
49+
@This Builder m11() {
50+
return this;
51+
}
52+
53+
@This Builder m12() {
54+
return this;
55+
}
56+
57+
@This Builder m13() {
58+
return this;
59+
}
60+
61+
@This Builder m14() {
62+
return this;
63+
}
64+
65+
@This Builder m15() {
66+
return this;
67+
}
68+
69+
@This Builder m16() {
70+
return this;
71+
}
72+
73+
@This Builder m17() {
74+
return this;
75+
}
76+
77+
@This Builder m18() {
78+
return this;
79+
}
80+
81+
@This Builder m19() {
82+
return this;
83+
}
84+
85+
@This Builder m20() {
86+
return this;
87+
}
88+
89+
@This Builder m21() {
90+
return this;
91+
}
92+
93+
@This Builder m22() {
94+
return this;
95+
}
96+
97+
@This Builder m23() {
98+
return this;
99+
}
100+
101+
@This Builder m24() {
102+
return this;
103+
}
104+
105+
@This Builder m25() {
106+
return this;
107+
}
108+
109+
@This Builder m26() {
110+
return this;
111+
}
112+
113+
@This Builder m27() {
114+
return this;
115+
}
116+
117+
@This Builder m28() {
118+
return this;
119+
}
120+
121+
@This Builder m29() {
122+
return this;
123+
}
124+
125+
Object build() {
126+
return new Object();
127+
}
128+
}
129+
130+
Object go() {
131+
return new Builder()
132+
.m01()
133+
.m02()
134+
.m03()
135+
.m04()
136+
.m05()
137+
.m06()
138+
.m07()
139+
.m08()
140+
.m09()
141+
.m10()
142+
.m11()
143+
.m12()
144+
.m13()
145+
.m14()
146+
.m15()
147+
.m16()
148+
.m17()
149+
.m18()
150+
.m19()
151+
.m20()
152+
.m21()
153+
.m22()
154+
.m23()
155+
.m24()
156+
.m25()
157+
.m26()
158+
.m27()
159+
.m28()
160+
.m29()
161+
.build();
162+
}
163+
}

0 commit comments

Comments
 (0)