Skip to content

Commit c30b098

Browse files
authored
Merge pull request #37079 from ahoppen/pr-5.5/check-may-have-members
[5.5][SourceKit] Don’t transform type when printing if CurrentType can’t have members
2 parents ca86c6d + e54b871 commit c30b098

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

lib/AST/ASTPrinter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,7 @@ class PrintAST : public ASTVisitor<PrintAST> {
755755
void printType(Type T) { printTypeWithOptions(T, Options); }
756756

757757
void printTransformedTypeWithOptions(Type T, PrintOptions options) {
758-
if (CurrentType && Current) {
758+
if (CurrentType && Current && CurrentType->mayHaveMembers()) {
759759
if (T->hasArchetype()) {
760760
// Get the interface type, since TypeLocs still have
761761
// contextual types in them.

test/SourceKit/CursorInfo/cursor_generics.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,17 @@ class MyType<T> {
1919
}
2020
}
2121

22+
// rdar://76750555
23+
public protocol IP {
24+
init(networkBytes: Int)
25+
}
26+
27+
public struct HostRecord<IPType: IP> {
28+
func foo() {
29+
let ipType = IPType(networkBytes: 42)
30+
}
31+
}
32+
2233
// RUN: %sourcekitd-test -req=cursor -pos=1:10 %s -- %s | %FileCheck -check-prefix=CHECK1 %s
2334
// CHECK1: <Declaration>func testGenerics&lt;T&gt;(x: <Type usr="s:15cursor_generics12testGenerics1xyx_tlF1TL_xmfp">T</Type>)</Declaration>
2435

@@ -37,3 +48,7 @@ class MyType<T> {
3748
// RUN: %sourcekitd-test -req=cursor -pos=18:14 %s -- %s | %FileCheck -check-prefix=CHECK5 %s
3849
// CHECK5: source.lang.swift.ref.var.instance
3950
// CHECK5: <Declaration>let items: [<Type usr="s:Si">Int</Type>]</Declaration>
51+
52+
// RUN: %sourcekitd-test -req=cursor -pos=29:22 %s -- %s | %FileCheck -check-prefix=CHECK_IP_TYPE %s
53+
// CHECK_IP_TYPE: source.lang.swift.ref.generic_type_param
54+
// CHECK_IP_TYPE: <Declaration>IPType : <Type usr="s:15cursor_generics2IPP">IP</Type></Declaration>

0 commit comments

Comments
 (0)