|
| 1 | +public protocol Proto { |
| 2 | + associatedtype Assoc |
| 3 | + func method() -> Assoc |
| 4 | +} |
| 5 | + |
1 | 6 | public class Base {}
|
2 | 7 |
|
3 |
| -public protocol Proto {} |
| 8 | +public class Derived: Base, Proto { |
| 9 | + public func method() -> Int {} |
| 10 | +} |
4 | 11 |
|
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 | + } |
8 | 16 | }
|
9 | 17 |
|
10 |
| -// RUN: %sourcekitd-test -req=cursor -pos=5:13 %s -- %s | %FileCheck %s |
11 |
| -// CHECK: <Declaration>public func foo() -> some <Type usr=[[Base_USR:.*]]>Base</Type> & <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>() -> <decl.function.returntype><syntaxtype.keyword>some</syntaxtype.keyword> <ref.class usr=[[Base_USR]]>Base</ref.class> & <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<T>(x: <Type usr=[[T_USR:.*]]>T</Type>) -> some <Type usr=[[Base_USR:.*]]>Base</Type> & <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><<decl.generic_type_param usr=[[T_USR]]><decl.generic_type_param.name>T</decl.generic_type_param.name></decl.generic_type_param>>(<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>) -> <decl.function.returntype><syntaxtype.keyword>some</syntaxtype.keyword> <ref.class usr=[[Base_USR]]>Base</ref.class> & <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<T>(x: T) -> some <Type usr=[[Base_USR:.*]]>Base</Type> & <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><<decl.generic_type_param usr=[[T_USR:.*]]><decl.generic_type_param.name>T</decl.generic_type_param.name></decl.generic_type_param>>(<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>) -> <decl.function.returntype><syntaxtype.keyword>some</syntaxtype.keyword> <ref.class usr=[[Base_USR]]>Base</ref.class> & <ref.protocol usr=[[Proto_USR]]>Proto</ref.protocol></decl.function.returntype></decl.function.method.instance> |
0 commit comments