Debian Codegraph @

crates/wit-component/tests/interfaces/resources.wit.print

raw
1 package foo:bar;
2
3 interface foo {
4 resource bar {
5 constructor();
6 a: static func();
7 b: func();
8 }
9
10 type t = bar;
11
12 type t2 = own<bar>;
13
14 a: func(x: bar) -> bar;
15 }
16
17 interface baz {
18 use foo.{bar, t};
19
20 a: func(x: bar) -> bar;
21
22 b: func() -> t;
23 }
24
25 interface implicit-own-handles {
26 resource a;
27
28 b: func(a1: a, a2: a) -> a;
29
30 c: func() -> list<a>;
31 }
32
33 interface implicit-own-handles2 {
34 /// the `own` return and list param should be the same `own`
35 resource a {
36 constructor(a: list<a>);
37 }
38
39 /// same as above, even when the `list<b>` implicitly-defined `own` comes
40 /// before an explicitly defined `own`
41 resource b {
42 constructor(a: list<b>, b: b);
43 }
44
45 /// same as the above, the `own` argument should have the same type as the
46 /// return value
47 resource c {
48 a: static func(a: c) -> c;
49 }
50 }
51
52 world some-world {
53 import anon: interface {
54 resource a {
55 constructor();
56 b: static func();
57 c: func();
58 }
59 }
60 import foo;
61 import baz;
62 use baz.{bar};
63
64 resource a {
65 constructor();
66 }
67
68 resource b {
69 constructor() -> result<b, string>;
70 }
71
72 export x: func() -> a;
73 export y: func() -> bar;
74 }
75 world implicit-own-handles3 {
76 /// there should only be one `list` type despite there looking like two
77 /// list types here
78 resource a {
79 constructor(a: list<a>, b: list<a>);
80 }
81 }