Skip to content

Commit f71feb9

Browse files
authored
Merge pull request #25557 from rintaro/5.1-sourcekit-test-cursor-some
[5.1][SourceKit] Extend opaque type results test case
2 parents 72c4e7f + 0a12e3e commit f71feb9

File tree

1 file changed

+43
-7
lines changed

1 file changed

+43
-7
lines changed
Lines changed: 43 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,48 @@
1+
public protocol Proto {
2+
associatedtype Assoc
3+
func method() -> Assoc
4+
}
5+
16
public class Base {}
27

3-
public protocol Proto {}
8+
public class Derived: Base, Proto {
9+
public func method() -> Int {}
10+
}
411

5-
public func foo() -> some Base & Proto {
6-
class Derived: Base, Proto {}
7-
return Derived()
12+
public struct S {
13+
public func foo<T>(x: T) -> some Base & Proto {
14+
return Derived()
15+
}
816
}
917

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>
18+
func test(value: S) {
19+
let _ = value.foo(x: 12)
20+
}
21+
22+
// RUN: %sourcekitd-test -req=cursor -pos=13:15 %s -- %s -module-name Test | %FileCheck %s -check-prefix=DECLSITE
23+
// DECLSITE: source.lang.swift.decl.function.method.instance (13:15-13:27)
24+
// DECLSITE-NEXT: foo(x:)
25+
// DECLSITE-NEXT: s:4Test1SV3foo1xQrx_tlF
26+
// DECLSITE-NEXT: <T> (S) -> (T) -> some Base & Proto
27+
// DECLSITE-NEXT: $s1xQrx_tcluD
28+
// DECLSITE-NEXT: <Declaration>public func foo&lt;T&gt;(x: <Type usr=[[T_USR:.*]]>T</Type>) -&gt; some <Type usr=[[Base_USR:.*]]>Base</Type> &amp; <Type usr=[[Proto_USR:.*]]>Proto</Type></Declaration>
29+
// DECLSITE-NEXT: <decl.function.method.instance><syntaxtype.keyword>public</syntaxtype.keyword> <syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>foo</decl.name>&lt;<decl.generic_type_param usr=[[T_USR]]><decl.generic_type_param.name>T</decl.generic_type_param.name></decl.generic_type_param>&gt;(<decl.var.parameter><decl.var.parameter.argument_label>x</decl.var.parameter.argument_label>: <decl.var.parameter.type><ref.generic_type_param usr=[[T_USR]]>T</ref.generic_type_param></decl.var.parameter.type></decl.var.parameter>) -&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.method.instance>
30+
31+
// RUN: %sourcekitd-test -req=cursor -pos=13:43 %s -- %s -module-name Test | %FileCheck %s -check-prefix=PROTO_AFTER_SOME
32+
// PROTO_AFTER_SOME: source.lang.swift.ref.protocol (1:17-1:22)
33+
// PROTO_AFTER_SOME-NEXT: Proto
34+
// PROTO_AFTER_SOME-NEXT: s:4Test5ProtoP
35+
// PROTO_AFTER_SOME-NEXT: Proto.Protocol
36+
// PROTO_AFTER_SOME-NEXT: $s4Test5Proto_pmD
37+
// PROTO_AFTER_SOME-NEXT: <Declaration>public protocol Proto</Declaration>
38+
// PROTO_AFTER_SOME-NEXT: <decl.protocol><syntaxtype.keyword>public</syntaxtype.keyword> <syntaxtype.keyword>protocol</syntaxtype.keyword> <decl.name>Proto</decl.name></decl.protocol>
39+
40+
// RUN: %sourcekitd-test -req=cursor -pos=19:17 %s -- %s -module-name Test | %FileCheck %s -check-prefix=USESITE
41+
// USESITE: source.lang.swift.ref.function.method.instance (13:15-13:27)
42+
// USESITE-NEXT: foo(x:)
43+
// USESITE-NEXT: s:4Test1SV3foo1xQrx_tlF
44+
// USESITE-NEXT: <T> (S) -> (T) -> some Base & Proto
45+
// USESITE-NEXT: $s1xQrx_tcluD
46+
// USESITE-NEXT: <Container>$s4Test1SVD</Container>
47+
// USESITE-NEXT: <Declaration>public func foo&lt;T&gt;(x: T) -&gt; some <Type usr=[[Base_USR:.*]]>Base</Type> &amp; <Type usr=[[Proto_USR:.*]]>Proto</Type></Declaration>
48+
// USESITE-NEXT: <decl.function.method.instance><syntaxtype.keyword>public</syntaxtype.keyword> <syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>foo</decl.name>&lt;<decl.generic_type_param usr=[[T_USR:.*]]><decl.generic_type_param.name>T</decl.generic_type_param.name></decl.generic_type_param>&gt;(<decl.var.parameter><decl.var.parameter.argument_label>x</decl.var.parameter.argument_label>: <decl.var.parameter.type>T</decl.var.parameter.type></decl.var.parameter>) -&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.method.instance>

0 commit comments

Comments
 (0)