@@ -195,11 +195,14 @@ class EditTest : public ::testing::Test {
195195 void doubleOpenWithDelay (std::chrono::microseconds delay, bool close);
196196
197197 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.
198201 const char *Contents =
199202 " struct S {\n "
200203 " var mem: Int = 0\n "
201204 " func test() {\n "
202- " _ = (self. mem, self. mem, self. mem) \n "
205+ " _ = mem; _ = mem; _ = mem\n "
203206 " }\n "
204207 " }\n " ;
205208 const char *Args[] = { " -parse-as-library" };
@@ -385,8 +388,13 @@ TEST_F(EditTest, AnnotationsAfterOpen) {
385388 TestConsumer Consumer;
386389 open (DocName, Contents, Args, Consumer);
387390 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+ }
390398
391399 ASSERT_EQ (0u , Consumer.Diags .size ());
392400 checkTokens (Consumer.Annotations , {
@@ -416,8 +424,13 @@ TEST_F(EditTest, AnnotationsAfterEdit) {
416424 TestConsumer Consumer;
417425 open (DocName, Contents, Args, Consumer);
418426 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+ }
421434 checkTokens (Consumer.Annotations , {
422435 " [off=22 len=3 source.lang.swift.ref.struct system]" ,
423436 });
@@ -426,8 +439,14 @@ TEST_F(EditTest, AnnotationsAfterEdit) {
426439 replaceText (DocName, 61 , 0 , " m" , Consumer);
427440 ASSERT_FALSE (waitForDocUpdate ()) << " timed out" ;
428441
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+
431450 ASSERT_EQ (0u , Consumer.Diags .size ());
432451 checkTokens (Consumer.Annotations , {
433452 " [off=22 len=3 source.lang.swift.ref.struct system]" ,
@@ -550,8 +569,6 @@ TEST_F(EditTest, AnnotationsRangeShiftingAfterEditInsertEnd) {
550569 ASSERT_FALSE (waitForDocUpdate ()) << " timed out" ;
551570 close (DocName);
552571}
553- // rdar://65934938 Failing in CI with ASan
554- #if defined(__has_feature) && !__has_feature(address_sanitizer)
555572TEST_F (EditTest, AnnotationsRangeShiftingAfterEditReplaceEnd) {
556573 const char *DocName = " test.swift" ;
557574 TestConsumer Consumer;
@@ -570,7 +587,6 @@ TEST_F(EditTest, AnnotationsRangeShiftingAfterEditReplaceEnd) {
570587 ASSERT_FALSE (waitForDocUpdate ()) << " timed out" ;
571588 close (DocName);
572589}
573- #endif
574590TEST_F (EditTest, AnnotationsRangeShiftingAfterEditDeleteEnd) {
575591 const char *DocName = " test.swift" ;
576592 TestConsumer Consumer;
0 commit comments