File tree Expand file tree Collapse file tree 2 files changed +15
-7
lines changed
test/SourceKit/SourceDocInfo Expand file tree Collapse file tree 2 files changed +15
-7
lines changed Original file line number Diff line number Diff line change @@ -3855,10 +3855,18 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
3855
3855
if (T->getName ().empty ())
3856
3856
Printer << " <anonymous>" ;
3857
3857
else {
3858
- PrintNameContext context = PrintNameContext::Normal;
3859
- if (T->getSelfProtocol ())
3860
- context = PrintNameContext::GenericParameter;
3861
- Printer.printName (T->getName (), context);
3858
+ // Print protocol 'Self' as a generic parameter so that it gets
3859
+ // annotated in cursor info.
3860
+ // FIXME: in a protocol extension, we really want the extension, not the
3861
+ // protocol.
3862
+ if (auto *P = T->getSelfProtocol ()) {
3863
+ auto *GTD = P->getProtocolSelf ();
3864
+ assert (GTD && GTD->isProtocolSelf ());
3865
+ Printer.printTypeRef (T, GTD, T->getName ());
3866
+ return ;
3867
+ }
3868
+
3869
+ Printer.printName (T->getName ());
3862
3870
}
3863
3871
}
3864
3872
}
Original file line number Diff line number Diff line change @@ -602,10 +602,10 @@ class C7 {
602
602
// RUN: %sourcekitd-test -req=cursor -pos=165:8 %s -- -F %S/../Inputs/libIDE-mock-sdk -I %t.tmp %mcp_opt %s | FileCheck %s -check-prefix=CHECK75
603
603
// CHECK75: source.lang.swift.decl.function.method.instance (165:8-165:18)
604
604
// CHECK75: <Self : P3> (Self) -> (Self) -> Self
605
- // CHECK75: <Declaration>func f(s: <Type usr="s:tE11cursor_infoPS_2P34SelfMx">Self</Type>) -> Self</Declaration>
605
+ // CHECK75: <Declaration>func f(s: <Type usr="s:tE11cursor_infoPS_2P34SelfMx">Self</Type>) -> <Type usr="s:tP11cursor_info2P34SelfMx"> Self</Type> </Declaration>
606
606
// CHECK75: <decl.var.parameter.type><ref.generic_type_param usr="s:tE11cursor_infoPS_2P34SelfMx">Self</ref.generic_type_param></decl.var.parameter.type>
607
- // CHECK75-SAME: <decl.function.returntype><decl .generic_type_param.name >Self</decl .generic_type_param.name ></decl.function.returntype>
608
- // FIXME: Should be ref.generic_type_param
607
+ // CHECK75-SAME: <decl.function.returntype><ref .generic_type_param usr="s:tP11cursor_info2P34SelfMx" >Self</ref .generic_type_param></decl.function.returntype>
608
+ // FIXME: the return type gets the USR for the original protocol, rather than the extension.
609
609
610
610
// RUN: %sourcekitd-test -req=cursor -pos=169:8 %s -- -F %S/../Inputs/libIDE-mock-sdk -I %t.tmp %mcp_opt %s | FileCheck %s -check-prefix=CHECK76
611
611
// CHECK76: source.lang.swift.decl.function.method.instance (169:8-169:11)
You can’t perform that action at this time.
0 commit comments