@@ -195,11 +195,14 @@ class EditTest : public ::testing::Test {
195
195
void doubleOpenWithDelay (std::chrono::microseconds delay, bool close);
196
196
197
197
void setupThreeAnnotations (const char *DocName, TestConsumer &Consumer) {
198
+ // The following is engineered so that the references to `mem` are at
199
+ // offsets 60, 70, and 80 for convenience. They're on the same line so
200
+ // that tests do not accidentally depend on line separation.
198
201
const char *Contents =
199
202
" struct S {\n "
200
203
" var mem: Int = 0\n "
201
204
" func test() {\n "
202
- " _ = (self. mem, self. mem, self. mem) \n "
205
+ " _ = mem; _ = mem; _ = mem\n "
203
206
" }\n "
204
207
" }\n " ;
205
208
const char *Args[] = { " -parse-as-library" };
@@ -385,8 +388,13 @@ TEST_F(EditTest, AnnotationsAfterOpen) {
385
388
TestConsumer Consumer;
386
389
open (DocName, Contents, Args, Consumer);
387
390
ASSERT_FALSE (waitForDocUpdate ()) << " timed out" ;
388
- reset (Consumer);
389
- replaceText (DocName, 0 , 0 , " " , Consumer);
391
+ if (Consumer.DiagStage == SemaDiagStage) {
392
+ // AST already built, annotations are on Consumer.
393
+ } else {
394
+ // Re-query.
395
+ reset (Consumer);
396
+ replaceText (DocName, 0 , 0 , " " , Consumer);
397
+ }
390
398
391
399
ASSERT_EQ (0u , Consumer.Diags .size ());
392
400
checkTokens (Consumer.Annotations , {
@@ -416,8 +424,13 @@ TEST_F(EditTest, AnnotationsAfterEdit) {
416
424
TestConsumer Consumer;
417
425
open (DocName, Contents, Args, Consumer);
418
426
ASSERT_FALSE (waitForDocUpdate ()) << " timed out" ;
419
- reset (Consumer);
420
- replaceText (DocName, 0 , 0 , " " , Consumer);
427
+ if (Consumer.DiagStage == SemaDiagStage) {
428
+ // AST already built, annotations are on Consumer.
429
+ } else {
430
+ // Re-query.
431
+ reset (Consumer);
432
+ replaceText (DocName, 0 , 0 , " " , Consumer);
433
+ }
421
434
checkTokens (Consumer.Annotations , {
422
435
" [off=22 len=3 source.lang.swift.ref.struct system]" ,
423
436
});
@@ -426,8 +439,14 @@ TEST_F(EditTest, AnnotationsAfterEdit) {
426
439
replaceText (DocName, 61 , 0 , " m" , Consumer);
427
440
ASSERT_FALSE (waitForDocUpdate ()) << " timed out" ;
428
441
429
- reset (Consumer);
430
- replaceText (DocName, 0 , 0 , " " , Consumer);
442
+ if (Consumer.DiagStage == SemaDiagStage) {
443
+ // AST already built, annotations are on Consumer.
444
+ } else {
445
+ // Re-query.
446
+ reset (Consumer);
447
+ replaceText (DocName, 0 , 0 , " " , Consumer);
448
+ }
449
+
431
450
ASSERT_EQ (0u , Consumer.Diags .size ());
432
451
checkTokens (Consumer.Annotations , {
433
452
" [off=22 len=3 source.lang.swift.ref.struct system]" ,
@@ -550,8 +569,6 @@ TEST_F(EditTest, AnnotationsRangeShiftingAfterEditInsertEnd) {
550
569
ASSERT_FALSE (waitForDocUpdate ()) << " timed out" ;
551
570
close (DocName);
552
571
}
553
- // rdar://65934938 Failing in CI with ASan
554
- #if defined(__has_feature) && !__has_feature(address_sanitizer)
555
572
TEST_F (EditTest, AnnotationsRangeShiftingAfterEditReplaceEnd) {
556
573
const char *DocName = " test.swift" ;
557
574
TestConsumer Consumer;
@@ -570,7 +587,6 @@ TEST_F(EditTest, AnnotationsRangeShiftingAfterEditReplaceEnd) {
570
587
ASSERT_FALSE (waitForDocUpdate ()) << " timed out" ;
571
588
close (DocName);
572
589
}
573
- #endif
574
590
TEST_F (EditTest, AnnotationsRangeShiftingAfterEditDeleteEnd) {
575
591
const char *DocName = " test.swift" ;
576
592
TestConsumer Consumer;
0 commit comments