[Index] Fix extension type location

The end loc is wrong when generic args are present, just use `getLoc`
which uses the name loc.
This commit is contained in:
Hamish Knight
2025-11-30 16:53:19 +00:00
parent 582462edac
commit a527e20341
3 changed files with 5 additions and 12 deletions

View File

@@ -103,12 +103,8 @@ static bool isMemberwiseInit(swift::ValueDecl *D) {
}
static SourceLoc getLocForExtension(ExtensionDecl *D) {
// Use the 'End' token of the range, in case it is a compound name, e.g.
// extension A.B {}
// we want the location of 'B' token.
if (auto *repr = D->getExtendedTypeRepr()) {
return repr->getSourceRange().End;
}
if (auto *repr = D->getExtendedTypeRepr())
return repr->getLoc();
return SourceLoc();
}

View File

@@ -92,9 +92,8 @@ extension IntArray {
func flam() {}
}
// FIXME: Column 22 here is wrong...
extension ArrayOf<Int> {
// CHECK: [[@LINE-1]]:22 | extension/ext-struct/Swift | Array | s:e:s:Sa14swift_ide_testSiRszlE4bishyyF | Def | rel: 0
// CHECK: [[@LINE-1]]:11 | extension/ext-struct/Swift | Array | s:e:s:Sa14swift_ide_testSiRszlE4bishyyF | Def | rel: 0
// CHECK-NEXT: [[@LINE-2]]:11 | type-alias/Swift | ArrayOf | s:3Lib7ArrayOfa | Ref | rel: 0
// CHECK-NEXT: [[@LINE-3]]:11 | struct/Swift | Array | s:Sa | Ref,Impl,RelExt | rel: 1
// CHECK-NEXT: RelExt | extension/ext-struct/Swift | Array | s:e:s:Sa14swift_ide_testSiRszlE4bishyyF

View File

@@ -565,9 +565,8 @@ class Subclass: BaseClass {
}
}
// FIXME: Column 15 here is wrong...
extension [Int] {
// CHECK: [[@LINE-1]]:15 | extension/ext-struct/Swift | Array | s:e:s:Sa14swift_ide_testSiRszlE3fooyyF | Def | rel: 0
// CHECK: [[@LINE-1]]:11 | extension/ext-struct/Swift | Array | s:e:s:Sa14swift_ide_testSiRszlE3fooyyF | Def | rel: 0
// CHECK-NEXT: [[@LINE-2]]:11 | struct/Swift | Array | s:Sa | Ref,Impl,RelExt | rel: 1
// CHECK-NEXT: RelExt | extension/ext-struct/Swift | Array | s:e:s:Sa14swift_ide_testSiRszlE3fooyyF
// CHECK-NEXT: [[@LINE-4]]:12 | struct/Swift | Int | s:Si | Ref | rel: 0
@@ -602,9 +601,8 @@ extension IntArray {
func flam() {}
}
// FIXME: Column 22 here is wrong...
extension ArrayOf<Int> {
// CHECK: [[@LINE-1]]:22 | extension/ext-struct/Swift | Array | s:e:s:Sa14swift_ide_testSiRszlE4bishyyF | Def | rel: 0
// CHECK: [[@LINE-1]]:11 | extension/ext-struct/Swift | Array | s:e:s:Sa14swift_ide_testSiRszlE4bishyyF | Def | rel: 0
// CHECK-NEXT: [[@LINE-2]]:11 | type-alias/Swift | ArrayOf | s:14swift_ide_test7ArrayOfa | Ref | rel: 0
// CHECK-NEXT: [[@LINE-3]]:11 | struct/Swift | Array | s:Sa | Ref,Impl,RelExt | rel: 1
// CHECK-NEXT: RelExt | extension/ext-struct/Swift | Array | s:e:s:Sa14swift_ide_testSiRszlE4bishyyF