Skip to content

Commit c938293

Browse files
authored
Merge pull request #25516 from akyrtzi/5.1-print-some-as-keyword
2 parents 5a124f1 + d25e468 commit c938293

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

lib/AST/ASTPrinter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4216,7 +4216,7 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
42164216
void visitOpaqueTypeArchetypeType(OpaqueTypeArchetypeType *T) {
42174217
switch (Options.OpaqueReturnTypePrinting) {
42184218
case PrintOptions::OpaqueReturnTypePrintingMode::WithOpaqueKeyword:
4219-
Printer << "some ";
4219+
Printer.printKeyword("some", Options, /*Suffix=*/" ");
42204220
LLVM_FALLTHROUGH;
42214221
case PrintOptions::OpaqueReturnTypePrintingMode::WithoutOpaqueKeyword: {
42224222
visit(T->getExistentialType());

lib/AST/TypeRepr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ void ProtocolTypeRepr::printImpl(ASTPrinter &Printer,
555555

556556
void OpaqueReturnTypeRepr::printImpl(ASTPrinter &Printer,
557557
const PrintOptions &Opts) const {
558-
Printer << "some ";
558+
Printer.printKeyword("some", Opts, /*Suffix=*/" ");
559559
printTypeRepr(Constraint, Printer, Opts);
560560
}
561561

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
public class Base {}
2+
3+
public protocol Proto {}
4+
5+
public func foo() -> some Base & Proto {
6+
class Derived: Base, Proto {}
7+
return Derived()
8+
}
9+
10+
// RUN: %sourcekitd-test -req=cursor -pos=5:13 %s -- %s | %FileCheck %s
11+
// CHECK: <Declaration>public func foo() -&gt; some <Type usr=[[Base_USR:.*]]>Base</Type> &amp; <Type usr=[[Proto_USR:.*]]>Proto</Type></Declaration>
12+
// CHECK: <decl.function.free><syntaxtype.keyword>public</syntaxtype.keyword> <syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>foo</decl.name>() -&gt; <decl.function.returntype><syntaxtype.keyword>some</syntaxtype.keyword> <ref.class usr=[[Base_USR]]>Base</ref.class> &amp; <ref.protocol usr=[[Proto_USR]]>Proto</ref.protocol></decl.function.returntype></decl.function.free>

0 commit comments

Comments
 (0)