Skip to content

Commit 96bcae5

Browse files
authored
Handle @captureSuggestions in the harness (#1237)
1 parent 8073250 commit 96bcae5

File tree

3 files changed

+112
-178
lines changed

3 files changed

+112
-178
lines changed

internal/testutil/harnessutil/harnessutil.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,9 @@ func compileFilesWithHost(
581581
if config.CompilerOptions().GetEmitDeclarations() {
582582
diagnostics = append(diagnostics, program.GetDeclarationDiagnostics(ctx, nil)...)
583583
}
584+
if harnessOptions.CaptureSuggestions {
585+
diagnostics = append(diagnostics, program.GetSuggestionDiagnostics(ctx, nil)...)
586+
}
584587
emitResult := program.Emit(compiler.EmitOptions{})
585588

586589
return newCompilationResult(config.CompilerOptions(), program, emitResult, diagnostics, harnessOptions)

testdata/baselines/reference/submodule/compiler/overshifts.errors.txt

Lines changed: 109 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,39 @@
1+
overshifts.ts(2,1): suggestion TS6807: This operation can be simplified. This shift is identical to `1 << 0`.
2+
overshifts.ts(3,1): suggestion TS6807: This operation can be simplified. This shift is identical to `1 << 27`.
3+
overshifts.ts(4,1): suggestion TS6807: This operation can be simplified. This shift is identical to `1 << 0`.
4+
overshifts.ts(6,1): suggestion TS6807: This operation can be simplified. This shift is identical to `1 << 0`.
5+
overshifts.ts(7,1): suggestion TS6807: This operation can be simplified. This shift is identical to `1 << -27`.
6+
overshifts.ts(8,1): suggestion TS6807: This operation can be simplified. This shift is identical to `1 << 0`.
7+
overshifts.ts(11,1): suggestion TS6807: This operation can be simplified. This shift is identical to `0xFF_FF_FF_FF >> 0`.
8+
overshifts.ts(12,1): suggestion TS6807: This operation can be simplified. This shift is identical to `0xFF_FF_FF_FF >> 27`.
9+
overshifts.ts(13,1): suggestion TS6807: This operation can be simplified. This shift is identical to `0xFF_FF_FF_FF >> 0`.
10+
overshifts.ts(15,1): suggestion TS6807: This operation can be simplified. This shift is identical to `0xFF_FF_FF_FF >> 0`.
11+
overshifts.ts(16,1): suggestion TS6807: This operation can be simplified. This shift is identical to `0xFF_FF_FF_FF >> -27`.
12+
overshifts.ts(17,1): suggestion TS6807: This operation can be simplified. This shift is identical to `0xFF_FF_FF_FF >> 0`.
13+
overshifts.ts(20,1): suggestion TS6807: This operation can be simplified. This shift is identical to `0xFF_FF_FF_FF >>> 0`.
14+
overshifts.ts(21,1): suggestion TS6807: This operation can be simplified. This shift is identical to `0xFF_FF_FF_FF >>> 27`.
15+
overshifts.ts(22,1): suggestion TS6807: This operation can be simplified. This shift is identical to `0xFF_FF_FF_FF >>> 0`.
16+
overshifts.ts(24,1): suggestion TS6807: This operation can be simplified. This shift is identical to `0xFF_FF_FF_FF >>> 0`.
17+
overshifts.ts(25,1): suggestion TS6807: This operation can be simplified. This shift is identical to `0xFF_FF_FF_FF >>> -27`.
18+
overshifts.ts(26,1): suggestion TS6807: This operation can be simplified. This shift is identical to `0xFF_FF_FF_FF >>> 0`.
19+
overshifts.ts(30,1): suggestion TS6807: This operation can be simplified. This shift is identical to `x <<= 0`.
20+
overshifts.ts(31,1): suggestion TS6807: This operation can be simplified. This shift is identical to `x <<= 27`.
21+
overshifts.ts(32,1): suggestion TS6807: This operation can be simplified. This shift is identical to `x <<= 0`.
22+
overshifts.ts(34,1): suggestion TS6807: This operation can be simplified. This shift is identical to `x <<= 0`.
23+
overshifts.ts(35,1): suggestion TS6807: This operation can be simplified. This shift is identical to `x <<= -27`.
24+
overshifts.ts(36,1): suggestion TS6807: This operation can be simplified. This shift is identical to `x <<= 0`.
25+
overshifts.ts(39,1): suggestion TS6807: This operation can be simplified. This shift is identical to `x >>= 0`.
26+
overshifts.ts(40,1): suggestion TS6807: This operation can be simplified. This shift is identical to `x >>= 27`.
27+
overshifts.ts(41,1): suggestion TS6807: This operation can be simplified. This shift is identical to `x >>= 0`.
28+
overshifts.ts(43,1): suggestion TS6807: This operation can be simplified. This shift is identical to `x >>= 0`.
29+
overshifts.ts(44,1): suggestion TS6807: This operation can be simplified. This shift is identical to `x >>= -27`.
30+
overshifts.ts(45,1): suggestion TS6807: This operation can be simplified. This shift is identical to `x >>= 0`.
31+
overshifts.ts(48,1): suggestion TS6807: This operation can be simplified. This shift is identical to `x >>>= 0`.
32+
overshifts.ts(49,1): suggestion TS6807: This operation can be simplified. This shift is identical to `x >>>= 27`.
33+
overshifts.ts(50,1): suggestion TS6807: This operation can be simplified. This shift is identical to `x >>>= 0`.
34+
overshifts.ts(52,1): suggestion TS6807: This operation can be simplified. This shift is identical to `x >>>= 0`.
35+
overshifts.ts(53,1): suggestion TS6807: This operation can be simplified. This shift is identical to `x >>>= -27`.
36+
overshifts.ts(54,1): suggestion TS6807: This operation can be simplified. This shift is identical to `x >>>= 0`.
137
overshifts.ts(58,9): error TS6807: This operation can be simplified. This shift is identical to `1 << 0`.
238
overshifts.ts(59,9): error TS6807: This operation can be simplified. This shift is identical to `1 << 27`.
339
overshifts.ts(60,9): error TS6807: This operation can be simplified. This shift is identical to `1 << 0`.
@@ -18,61 +54,133 @@ overshifts.ts(85,9): error TS6807: This operation can be simplified. This shift
1854
overshifts.ts(86,9): error TS6807: This operation can be simplified. This shift is identical to `0xFF_FF_FF_FF >>> 0`.
1955

2056

21-
==== overshifts.ts (18 errors) ====
57+
==== overshifts.ts (54 errors) ====
2258
1 << 1; // ok
2359
1 << 32; // overshift
60+
~~~~~~~
61+
!!! suggestion TS6807: This operation can be simplified. This shift is identical to `1 << 0`.
2462
1 << 123;
63+
~~~~~~~~
64+
!!! suggestion TS6807: This operation can be simplified. This shift is identical to `1 << 27`.
2565
1 << 1024;
66+
~~~~~~~~~
67+
!!! suggestion TS6807: This operation can be simplified. This shift is identical to `1 << 0`.
2668
1 << -1; // OK-ish
2769
1 << -32; // backwards overshift
70+
~~~~~~~~
71+
!!! suggestion TS6807: This operation can be simplified. This shift is identical to `1 << 0`.
2872
1 << -123;
73+
~~~~~~~~~
74+
!!! suggestion TS6807: This operation can be simplified. This shift is identical to `1 << -27`.
2975
1 << -1024;
76+
~~~~~~~~~~
77+
!!! suggestion TS6807: This operation can be simplified. This shift is identical to `1 << 0`.
3078

3179
0xFF_FF_FF_FF >> 1; // ok
3280
0xFF_FF_FF_FF >> 32; // overshift
81+
~~~~~~~~~~~~~~~~~~~
82+
!!! suggestion TS6807: This operation can be simplified. This shift is identical to `0xFF_FF_FF_FF >> 0`.
3383
0xFF_FF_FF_FF >> 123;
84+
~~~~~~~~~~~~~~~~~~~~
85+
!!! suggestion TS6807: This operation can be simplified. This shift is identical to `0xFF_FF_FF_FF >> 27`.
3486
0xFF_FF_FF_FF >> 1024;
87+
~~~~~~~~~~~~~~~~~~~~~
88+
!!! suggestion TS6807: This operation can be simplified. This shift is identical to `0xFF_FF_FF_FF >> 0`.
3589
0xFF_FF_FF_FF >> -1; // OK-ish
3690
0xFF_FF_FF_FF >> -32; // backwards overshift
91+
~~~~~~~~~~~~~~~~~~~~
92+
!!! suggestion TS6807: This operation can be simplified. This shift is identical to `0xFF_FF_FF_FF >> 0`.
3793
0xFF_FF_FF_FF >> -123;
94+
~~~~~~~~~~~~~~~~~~~~~
95+
!!! suggestion TS6807: This operation can be simplified. This shift is identical to `0xFF_FF_FF_FF >> -27`.
3896
0xFF_FF_FF_FF >> -1024;
97+
~~~~~~~~~~~~~~~~~~~~~~
98+
!!! suggestion TS6807: This operation can be simplified. This shift is identical to `0xFF_FF_FF_FF >> 0`.
3999

40100
0xFF_FF_FF_FF >>> 1; // ok
41101
0xFF_FF_FF_FF >>> 32; // overshift
102+
~~~~~~~~~~~~~~~~~~~~
103+
!!! suggestion TS6807: This operation can be simplified. This shift is identical to `0xFF_FF_FF_FF >>> 0`.
42104
0xFF_FF_FF_FF >>> 123;
105+
~~~~~~~~~~~~~~~~~~~~~
106+
!!! suggestion TS6807: This operation can be simplified. This shift is identical to `0xFF_FF_FF_FF >>> 27`.
43107
0xFF_FF_FF_FF >>> 1024;
108+
~~~~~~~~~~~~~~~~~~~~~~
109+
!!! suggestion TS6807: This operation can be simplified. This shift is identical to `0xFF_FF_FF_FF >>> 0`.
44110
0xFF_FF_FF_FF >>> -1; // OK-ish
45111
0xFF_FF_FF_FF >>> -32; // backwards overshift
112+
~~~~~~~~~~~~~~~~~~~~~
113+
!!! suggestion TS6807: This operation can be simplified. This shift is identical to `0xFF_FF_FF_FF >>> 0`.
46114
0xFF_FF_FF_FF >>> -123;
115+
~~~~~~~~~~~~~~~~~~~~~~
116+
!!! suggestion TS6807: This operation can be simplified. This shift is identical to `0xFF_FF_FF_FF >>> -27`.
47117
0xFF_FF_FF_FF >>> -1024;
118+
~~~~~~~~~~~~~~~~~~~~~~~
119+
!!! suggestion TS6807: This operation can be simplified. This shift is identical to `0xFF_FF_FF_FF >>> 0`.
48120

49121
let x = 1;
50122
x <<= 1; // ok
51123
x <<= 32; // overshift
124+
~~~~~~~~
125+
!!! suggestion TS6807: This operation can be simplified. This shift is identical to `x <<= 0`.
52126
x <<= 123;
127+
~~~~~~~~~
128+
!!! suggestion TS6807: This operation can be simplified. This shift is identical to `x <<= 27`.
53129
x <<= 1024;
130+
~~~~~~~~~~
131+
!!! suggestion TS6807: This operation can be simplified. This shift is identical to `x <<= 0`.
54132
x <<= -1; // OK-ish
55133
x <<= -32; // backwards overshift
134+
~~~~~~~~~
135+
!!! suggestion TS6807: This operation can be simplified. This shift is identical to `x <<= 0`.
56136
x <<= -123;
137+
~~~~~~~~~~
138+
!!! suggestion TS6807: This operation can be simplified. This shift is identical to `x <<= -27`.
57139
x <<= -1024;
140+
~~~~~~~~~~~
141+
!!! suggestion TS6807: This operation can be simplified. This shift is identical to `x <<= 0`.
58142

59143
x >>= 1; // ok
60144
x >>= 32; // overshift
145+
~~~~~~~~
146+
!!! suggestion TS6807: This operation can be simplified. This shift is identical to `x >>= 0`.
61147
x >>= 123;
148+
~~~~~~~~~
149+
!!! suggestion TS6807: This operation can be simplified. This shift is identical to `x >>= 27`.
62150
x >>= 1024;
151+
~~~~~~~~~~
152+
!!! suggestion TS6807: This operation can be simplified. This shift is identical to `x >>= 0`.
63153
x >>= -1; // OK-ish
64154
x >>= -32; // backwards overshift
155+
~~~~~~~~~
156+
!!! suggestion TS6807: This operation can be simplified. This shift is identical to `x >>= 0`.
65157
x >>= -123;
158+
~~~~~~~~~~
159+
!!! suggestion TS6807: This operation can be simplified. This shift is identical to `x >>= -27`.
66160
x >>= -1024;
161+
~~~~~~~~~~~
162+
!!! suggestion TS6807: This operation can be simplified. This shift is identical to `x >>= 0`.
67163

68164
x >>>= 1; // ok
69165
x >>>= 32; // overshift
166+
~~~~~~~~~
167+
!!! suggestion TS6807: This operation can be simplified. This shift is identical to `x >>>= 0`.
70168
x >>>= 123;
169+
~~~~~~~~~~
170+
!!! suggestion TS6807: This operation can be simplified. This shift is identical to `x >>>= 27`.
71171
x >>>= 1024;
172+
~~~~~~~~~~~
173+
!!! suggestion TS6807: This operation can be simplified. This shift is identical to `x >>>= 0`.
72174
x >>>= -1; // OK-ish
73175
x >>>= -32; // backwards overshift
176+
~~~~~~~~~~
177+
!!! suggestion TS6807: This operation can be simplified. This shift is identical to `x >>>= 0`.
74178
x >>>= -123;
179+
~~~~~~~~~~~
180+
!!! suggestion TS6807: This operation can be simplified. This shift is identical to `x >>>= -27`.
75181
x >>>= -1024;
182+
~~~~~~~~~~~~
183+
!!! suggestion TS6807: This operation can be simplified. This shift is identical to `x >>>= 0`.
76184

77185
enum One {
78186
A = 1 << 1, // ok

0 commit comments

Comments
 (0)