Skip to content

AST: Fix mangling of entities in subscript context #23751

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lib/AST/ASTMangler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1595,10 +1595,10 @@ void ASTMangler::appendContext(const DeclContext *ctx) {
return appendEntity(eed);
}

case DeclContextKind::SubscriptDecl:
// FIXME: We may need to do something here if subscripts contain any symbols
// exposed with linkage names, or if/when they get generic parameters.
return appendContext(ctx->getParent());
case DeclContextKind::SubscriptDecl: {
auto sd = cast<SubscriptDecl>(ctx);
return appendEntity(sd);
}

case DeclContextKind::Initializer:
switch (cast<Initializer>(ctx)->getInitializerKind()) {
Expand Down
6 changes: 3 additions & 3 deletions test/IDE/print_usrs.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class GenericClass {
}

// CHECK: [[@LINE+2]]:3 s:14swift_ide_test12GenericClassCySfSicip{{$}}
// CHECK: [[@LINE+1]]:13 s:14swift_ide_test12GenericClassC1iL_Sivp{{$}}
// CHECK: [[@LINE+1]]:13 s:14swift_ide_test12GenericClassCySfSicip1iL_Sivp{{$}}
subscript(i: Int) -> Float {
// CHECK: [[@LINE+1]]:5 s:14swift_ide_test12GenericClassCySfSicig{{$}}
get { return 0.0 }
Expand Down Expand Up @@ -212,7 +212,7 @@ class ObjCClass1 {
class func staticFunc1(_ a: Int) {}

// CHECK: [[@LINE+2]]:10 s:14swift_ide_test10ObjCClass1CyS2icip{{$}}
// CHECK: [[@LINE+1]]:20 s:14swift_ide_test10ObjCClass1C1xL_Sivp{{$}}
// CHECK: [[@LINE+1]]:20 s:14swift_ide_test10ObjCClass1CyS2icip1xL_Sivp{{$}}
public subscript(x: Int) -> Int {

// CHECK: [[@LINE+1]]:5 c:@M@swift_ide_test@objc(cs)ObjCClass1(im)objectAtIndexedSubscript:{{$}}
Expand All @@ -223,7 +223,7 @@ class ObjCClass1 {
}

// CHECK: [[@LINE+2]]:10 s:14swift_ide_test10ObjCClass1CySiACcip{{$}}
// CHECK: [[@LINE+1]]:20 s:14swift_ide_test10ObjCClass1C1xL_ACvp{{$}}
// CHECK: [[@LINE+1]]:20 s:14swift_ide_test10ObjCClass1CySiACcip1xL_ACvp{{$}}
public subscript(x: ObjCClass1) -> Int {

// CHECK: [[@LINE+1]]:5 c:@M@swift_ide_test@objc(cs)ObjCClass1(im)objectForKeyedSubscript:{{$}}
Expand Down
6 changes: 2 additions & 4 deletions test/SourceKit/CursorInfo/cursor_info_param.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,14 @@ func customSourceLocation(a: Int) {}
// CHECK-FUNC-THEB-NOT: PARENT OFFSET

// RUN: %sourcekitd-test -req=cursor -pos=4:13 %s -- %s | %FileCheck -check-prefix=CHECK-SUBSCRIPT-A %s
// FIXME: This USR is wrong; see https://bugs.swift.org/browse/SR-8660.
// CHECK-SUBSCRIPT-A: s:17cursor_info_param12AccessorTestV1aL_Sivp
// CHECK-SUBSCRIPT-A: s:17cursor_info_param12AccessorTestV_1bS2i_Sitcip1aL_Sivp
// CHECK-SUBSCRIPT-A: PARENT OFFSET: 67

// RUN: %sourcekitd-test -req=cursor -pos=4:21 %s -- %s | %FileCheck -check-prefix=CHECK-SUBSCRIPT-B %s
// CHECK-SUBSCRIPT-B: s:17cursor_info_param12AccessorTestV

// RUN: %sourcekitd-test -req=cursor -pos=4:23 %s -- %s | %FileCheck -check-prefix=CHECK-SUBSCRIPT-THEB %s
// FIXME: This USR is wrong; see https://bugs.swift.org/browse/SR-8660.
// CHECK-SUBSCRIPT-THEB: s:17cursor_info_param12AccessorTestV4theBL_Sivp
// CHECK-SUBSCRIPT-THEB: s:17cursor_info_param12AccessorTestV_1bS2i_Sitcip4theBL_Sivp
// CHECK-SUBSCRIPT-THEB-NOT: PARENT OFFSET

// RUN: %sourcekitd-test -req=cursor -pos=7:9 %s -- %s | %FileCheck -check-prefix=CHECK-SETTER-V %s
Expand Down