lisette-stdlib 0.2.13

Little language inspired by Rust that compiles to Go
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
// Generated by Lisette bindgen
// Source: go/types (Go stdlib)
// Go: 1.25.10
// Lisette: 0.2.1

import "go:bytes"
import "go:go/ast"
import "go:go/constant"
import "go:go/token"
import "go:io"
import "go:iter"

pub enum BasicKind: int {
  Bool = 1,
  Byte = 8,
  Complex128 = 16,
  Complex64 = 15,
  Float32 = 13,
  Float64 = 14,
  Int = 2,
  Int16 = 4,
  Int32 = 5,
  Int64 = 6,
  Int8 = 3,
  Invalid = 0,
  Rune = 5,
  String = 17,
  Uint = 7,
  Uint16 = 9,
  Uint32 = 10,
  Uint64 = 11,
  Uint8 = 8,
  Uintptr = 12,
  UnsafePointer = 18,
  UntypedBool = 19,
  UntypedComplex = 23,
  UntypedFloat = 22,
  UntypedInt = 20,
  UntypedNil = 25,
  UntypedRune = 21,
  UntypedString = 24,
}

pub const Bool: BasicKind = 1

pub const Byte: BasicKind = 8

pub const Complex128: BasicKind = 16

pub const Complex64: BasicKind = 15

pub const Float32: BasicKind = 13

pub const Float64: BasicKind = 14

pub const Int: BasicKind = 2

pub const Int16: BasicKind = 4

pub const Int32: BasicKind = 5

pub const Int64: BasicKind = 6

pub const Int8: BasicKind = 3

pub const Invalid: BasicKind = 0

pub const Rune: BasicKind = 5

pub const String: BasicKind = 17

pub const Uint: BasicKind = 7

pub const Uint16: BasicKind = 9

pub const Uint32: BasicKind = 10

pub const Uint64: BasicKind = 11

pub const Uint8: BasicKind = 8

pub const Uintptr: BasicKind = 12

pub const UnsafePointer: BasicKind = 18

pub const UntypedBool: BasicKind = 19

pub const UntypedComplex: BasicKind = 23

pub const UntypedFloat: BasicKind = 22

pub const UntypedInt: BasicKind = 20

pub const UntypedNil: BasicKind = 25

pub const UntypedRune: BasicKind = 21

pub const UntypedString: BasicKind = 24

pub enum ChanDir: int {
  RecvOnly = 2,
  SendOnly = 1,
  SendRecv = 0,
}

pub const RecvOnly: ChanDir = 2

pub const SendOnly: ChanDir = 1

pub const SendRecv: ChanDir = 0

pub enum SelectionKind: int {
  FieldVal = 0,
  MethodExpr = 2,
  MethodVal = 1,
}

pub const FieldVal: SelectionKind = 0

pub const MethodExpr: SelectionKind = 2

pub const MethodVal: SelectionKind = 1

pub enum VarKind: uint8 {
  FieldVar = 6,
  LocalVar = 2,
  PackageVar = 1,
  ParamVar = 4,
  RecvVar = 3,
  ResultVar = 5,
}

pub const FieldVar: VarKind = 6

pub const LocalVar: VarKind = 2

pub const PackageVar: VarKind = 1

pub const ParamVar: VarKind = 4

pub const RecvVar: VarKind = 3

pub const ResultVar: VarKind = 5

/// AssertableTo reports whether a value of type V can be asserted to have type T.
/// 
/// The behavior of AssertableTo is unspecified in three cases:
///   - if T is Typ[Invalid]
///   - if V is a generalized interface; i.e., an interface that may only be used
///     as a type constraint in Go code
///   - if T is an uninstantiated generic type
pub fn AssertableTo(v: Ref<Interface>, t: Type) -> bool

/// AssignableTo reports whether a value of type V is assignable to a variable
/// of type T.
/// 
/// The behavior of AssignableTo is unspecified if V or T is Typ[Invalid] or an
/// uninstantiated generic type.
pub fn AssignableTo(v: Type, t: Type) -> bool

/// CheckExpr type checks the expression expr as if it had appeared at position
/// pos of package pkg. [Type] information about the expression is recorded in
/// info. The expression may be an identifier denoting an uninstantiated generic
/// function or type.
/// 
/// If pkg == nil, the [Universe] scope is used and the provided
/// position pos is ignored. If pkg != nil, and pos is invalid,
/// the package scope is used. Otherwise, pos must belong to the
/// package.
/// 
/// An error is returned if pos is not within the package or
/// if the node cannot be type-checked.
/// 
/// Note: [Eval] and CheckExpr should not be used instead of running Check
/// to compute types and values, but in addition to Check, as these
/// functions ignore the context in which an expression is used (e.g., an
/// assignment). Thus, top-level untyped constants will return an
/// untyped type rather than the respective context-specific type.
pub fn CheckExpr(
  fset: Ref<token.FileSet>,
  pkg: Ref<Package>,
  pos: token.Pos,
  expr: ast.Expr,
  info: Ref<Info>,
) -> Result<(), error>

/// Comparable reports whether values of type T are comparable.
pub fn Comparable(t: Type) -> bool

/// ConvertibleTo reports whether a value of type V is convertible to a value of
/// type T.
/// 
/// The behavior of ConvertibleTo is unspecified if V or T is Typ[Invalid] or an
/// uninstantiated generic type.
pub fn ConvertibleTo(v: Type, t: Type) -> bool

/// DefPredeclaredTestFuncs defines the assert and trace built-ins.
/// These built-ins are intended for debugging and testing of this
/// package only.
pub fn DefPredeclaredTestFuncs()

/// Default returns the default "typed" type for an "untyped" type;
/// it returns the incoming type for all other types. The default type
/// for untyped nil is untyped nil.
pub fn Default(t: Type) -> Type

/// Eval returns the type and, if constant, the value for the
/// expression expr, evaluated at position pos of package pkg,
/// which must have been derived from type-checking an AST with
/// complete position information relative to the provided file
/// set.
/// 
/// The meaning of the parameters fset, pkg, and pos is the
/// same as in [CheckExpr]. An error is returned if expr cannot
/// be parsed successfully, or the resulting expr AST cannot be
/// type-checked.
pub fn Eval(
  fset: Ref<token.FileSet>,
  pkg: Ref<Package>,
  pos: token.Pos,
  expr: string,
) -> Result<TypeAndValue, error>

/// ExprString returns the (possibly shortened) string representation for x.
/// Shortened representations are suitable for user interfaces but may not
/// necessarily follow Go syntax.
pub fn ExprString(x: ast.Expr) -> string

/// Id returns name if it is exported, otherwise it
/// returns the name qualified with the package path.
pub fn Id(pkg: Ref<Package>, name: string) -> string

/// Identical reports whether x and y are identical types.
/// Receivers of [Signature] types are ignored.
/// 
/// Predicates such as [Identical], [Implements], and
/// [Satisfies] assume that both operands belong to a
/// consistent collection of symbols ([Object] values).
/// For example, two [Named] types can be identical only if their
/// [Named.Obj] methods return the same [TypeName] symbol.
/// A collection of symbols is consistent if, for each logical
/// package whose path is P, the creation of those symbols
/// involved at most one call to [NewPackage](P, ...).
/// To ensure consistency, use a single [Importer] for
/// all loaded packages and their dependencies.
/// For more information, see https://github.com/golang/go/issues/57497.
pub fn Identical(x: Type, y: Type) -> bool

/// IdenticalIgnoreTags reports whether x and y are identical types if tags are ignored.
/// Receivers of [Signature] types are ignored.
pub fn IdenticalIgnoreTags(x: Type, y: Type) -> bool

/// Implements reports whether type V implements interface T.
/// 
/// The behavior of Implements is unspecified if V is Typ[Invalid] or an uninstantiated
/// generic type.
pub fn Implements(v: Type, t: Ref<Interface>) -> bool

/// Instantiate instantiates the type orig with the given type arguments targs.
/// orig must be an *Alias, *Named, or *Signature type. If there is no error,
/// the resulting Type is an instantiated type of the same kind (*Alias, *Named
/// or *Signature, respectively).
/// 
/// Methods attached to a *Named type are also instantiated, and associated with
/// a new *Func that has the same position as the original method, but nil function
/// scope.
/// 
/// If ctxt is non-nil, it may be used to de-duplicate the instance against
/// previous instances with the same identity. As a special case, generic
/// *Signature origin types are only considered identical if they are pointer
/// equivalent, so that instantiating distinct (but possibly identical)
/// signatures will yield different instances. The use of a shared context does
/// not guarantee that identical instances are deduplicated in all cases.
/// 
/// If validate is set, Instantiate verifies that the number of type arguments
/// and parameters match, and that the type arguments satisfy their respective
/// type constraints. If verification fails, the resulting error may wrap an
/// *ArgumentError indicating which type argument did not satisfy its type parameter
/// constraint, and why.
/// 
/// If validate is not set, Instantiate does not verify the type argument count
/// or whether the type arguments satisfy their constraints. Instantiate is
/// guaranteed to not return an error, but may panic. Specifically, for
/// *Signature types, Instantiate will panic immediately if the type argument
/// count is incorrect; for *Named types, a panic may occur later inside the
/// *Named API.
pub fn Instantiate(
  ctxt: Ref<Context>,
  orig: Type,
  targs: Slice<Type>,
  validate: bool,
) -> Result<Type, error>

/// IsInterface reports whether t is an interface type.
pub fn IsInterface(t: Type) -> bool

/// LookupFieldOrMethod looks up a field or method with given package and name
/// in T and returns the corresponding *Var or *Func, an index sequence, and a
/// bool indicating if there were any pointer indirections on the path to the
/// field or method. If addressable is set, T is the type of an addressable
/// variable (only matters for method lookups). T must not be nil.
/// 
/// The last index entry is the field or method index in the (possibly embedded)
/// type where the entry was found, either:
/// 
///  1. the list of declared methods of a named type; or
///  2. the list of all methods (method set) of an interface type; or
///  3. the list of fields of a struct type.
/// 
/// The earlier index entries are the indices of the embedded struct fields
/// traversed to get to the found entry, starting at depth 0.
/// 
/// If no entry is found, a nil object is returned. In this case, the returned
/// index and indirect values have the following meaning:
/// 
///   - If index != nil, the index sequence points to an ambiguous entry
///     (the same name appeared more than once at the same embedding level).
/// 
///   - If indirect is set, a method with a pointer receiver type was found
///     but there was no pointer on the path from the actual receiver type to
///     the method's formal receiver base type, nor was the receiver addressable.
/// 
/// See also [LookupSelection], which returns the result as a [Selection].
pub fn LookupFieldOrMethod(
  t: Type,
  addressable: bool,
  pkg: Ref<Package>,
  name: string,
) -> (Object, Slice<int>, bool)

/// LookupSelection selects the field or method whose ID is Id(pkg,
/// name), on a value of type T. If addressable is set, T is the type
/// of an addressable variable (this matters only for method lookups).
/// T must not be nil.
/// 
/// If the selection is valid:
/// 
///   - [Selection.Obj] returns the field ([Var]) or method ([Func]);
///   - [Selection.Indirect] reports whether there were any pointer
///     indirections on the path to the field or method.
///   - [Selection.Index] returns the index sequence, defined below.
/// 
/// The last index entry is the field or method index in the (possibly
/// embedded) type where the entry was found, either:
/// 
///  1. the list of declared methods of a named type; or
///  2. the list of all methods (method set) of an interface type; or
///  3. the list of fields of a struct type.
/// 
/// The earlier index entries are the indices of the embedded struct
/// fields traversed to get to the found entry, starting at depth 0.
/// 
/// See also [LookupFieldOrMethod], which returns the components separately.
pub fn LookupSelection(
  t: Type,
  addressable: bool,
  pkg: Ref<Package>,
  name: string,
) -> Option<Selection>

/// MissingMethod returns (nil, false) if V implements T, otherwise it
/// returns a missing method required by T and whether it is missing or
/// just has the wrong type: either a pointer receiver or wrong signature.
/// 
/// For non-interface types V, or if static is set, V implements T if all
/// methods of T are present in V. Otherwise (V is an interface and static
/// is not set), MissingMethod only checks that methods of T which are also
/// present in V have matching types (e.g., for a type assertion x.(T) where
/// x is of interface type V).
#[go(comma_ok)]
pub fn MissingMethod(v: Type, t: Ref<Interface>, static: bool) -> Option<Ref<Func>>

/// NewAlias creates a new Alias type with the given type name and rhs.
/// rhs must not be nil.
pub fn NewAlias(obj: Ref<TypeName>, rhs: Type) -> Ref<Alias>

/// NewArray returns a new array type for the given element type and length.
/// A negative length indicates an unknown length.
pub fn NewArray(elem: Type, len: int64) -> Ref<Array>

/// NewChan returns a new channel type for the given direction and element type.
pub fn NewChan(dir: ChanDir, elem: Type) -> Ref<Chan>

/// NewChecker returns a new [Checker] instance for a given package.
/// [Package] files may be added incrementally via checker.Files.
pub fn NewChecker(
  conf: Ref<Config>,
  fset: Ref<token.FileSet>,
  pkg: Ref<Package>,
  info: Ref<Info>,
) -> Ref<Checker>

/// NewConst returns a new constant with value val.
/// The remaining arguments set the attributes found with all Objects.
pub fn NewConst(
  pos: token.Pos,
  pkg: Ref<Package>,
  name: string,
  typ: Type,
  val: constant.Value,
) -> Ref<Const>

/// NewContext creates a new Context.
pub fn NewContext() -> Ref<Context>

/// NewField returns a new variable representing a struct field.
/// For embedded fields, the name is the unqualified type name
/// under which the field is accessible.
pub fn NewField(
  pos: token.Pos,
  pkg: Ref<Package>,
  name: string,
  typ: Type,
  embedded: bool,
) -> Ref<Var>

/// NewFunc returns a new function with the given signature, representing
/// the function's type.
pub fn NewFunc(
  pos: token.Pos,
  pkg: Ref<Package>,
  name: string,
  sig: Ref<Signature>,
) -> Ref<Func>

/// NewInterface returns a new interface for the given methods and embedded types.
/// NewInterface takes ownership of the provided methods and may modify their types
/// by setting missing receivers.
/// 
/// Deprecated: Use NewInterfaceType instead which allows arbitrary embedded types.
pub fn NewInterface(methods: Slice<Ref<Func>>, embeddeds: Slice<Ref<Named>>) -> Ref<Interface>

/// NewInterfaceType returns a new interface for the given methods and embedded
/// types. NewInterfaceType takes ownership of the provided methods and may
/// modify their types by setting missing receivers.
/// 
/// To avoid race conditions, the interface's type set should be computed before
/// concurrent use of the interface, by explicitly calling Complete.
pub fn NewInterfaceType(methods: Slice<Ref<Func>>, embeddeds: Slice<Type>) -> Ref<Interface>

/// NewLabel returns a new label.
pub fn NewLabel(pos: token.Pos, pkg: Ref<Package>, name: string) -> Ref<Label>

/// NewMap returns a new map for the given key and element types.
pub fn NewMap(key: Type, elem: Type) -> Ref<Map>

/// NewMethodSet returns the method set for the given type T.
/// It always returns a non-nil method set, even if it is empty.
pub fn NewMethodSet(t: Type) -> Ref<MethodSet>

/// NewNamed returns a new named type for the given type name, underlying type, and associated methods.
/// If the given type name obj doesn't have a type yet, its type is set to the returned named type.
/// The underlying type must not be a *Named.
pub fn NewNamed(obj: Ref<TypeName>, underlying: Type, methods: Slice<Ref<Func>>) -> Ref<Named>

/// NewPackage returns a new Package for the given package path and name.
/// The package is not complete and contains no explicit imports.
pub fn NewPackage(path: string, name: string) -> Ref<Package>

/// NewParam returns a new variable representing a function parameter.
/// 
/// The caller must subsequently call [Var.SetKind] if the desired Var
/// is not of kind [ParamVar]: for example, [RecvVar] or [ResultVar].
pub fn NewParam(pos: token.Pos, pkg: Ref<Package>, name: string, typ: Type) -> Ref<Var>

/// NewPkgName returns a new PkgName object representing an imported package.
/// The remaining arguments set the attributes found with all Objects.
pub fn NewPkgName(
  pos: token.Pos,
  pkg: Ref<Package>,
  name: string,
  imported: Ref<Package>,
) -> Ref<PkgName>

/// NewPointer returns a new pointer type for the given element (base) type.
pub fn NewPointer(elem: Type) -> Ref<Pointer>

/// NewScope returns a new, empty scope contained in the given parent
/// scope, if any. The comment is for debugging only.
pub fn NewScope(
  parent: Ref<Scope>,
  pos: token.Pos,
  end: token.Pos,
  comment: string,
) -> Ref<Scope>

/// NewSignature returns a new function type for the given receiver, parameters,
/// and results, either of which may be nil. If variadic is set, the function
/// is variadic, it must have at least one parameter, and the last parameter
/// must be of unnamed slice type.
/// 
/// Deprecated: Use [NewSignatureType] instead which allows for type parameters.
pub fn NewSignature(
  recv: Ref<Var>,
  params: Ref<Tuple>,
  results: Ref<Tuple>,
  variadic: bool,
) -> Ref<Signature>

/// NewSignatureType creates a new function type for the given receiver,
/// receiver type parameters, type parameters, parameters, and results.
/// If variadic is set, params must hold at least one parameter and the
/// last parameter must be an unnamed slice or a type parameter whose
/// type set has an unnamed slice as common underlying type.
/// As a special case, for variadic signatures the last parameter may
/// also be a string type, or a type parameter containing a mix of byte
/// slices and string types in its type set.
/// If recv is non-nil, typeParams must be empty. If recvTypeParams is
/// non-empty, recv must be non-nil.
pub fn NewSignatureType(
  recv: Ref<Var>,
  recvTypeParams: Slice<Ref<TypeParam>>,
  typeParams: Slice<Ref<TypeParam>>,
  params: Ref<Tuple>,
  results: Ref<Tuple>,
  variadic: bool,
) -> Ref<Signature>

/// NewSlice returns a new slice type for the given element type.
pub fn NewSlice(elem: Type) -> Ref<Slice>

/// NewStruct returns a new struct with the given fields and corresponding field tags.
/// If a field with index i has a tag, tags[i] must be that tag, but len(tags) may be
/// only as long as required to hold the tag with the largest index i. Consequently,
/// if no field has a tag, tags may be nil.
pub fn NewStruct(fields: Slice<Ref<Var>>, tags: Slice<string>) -> Ref<Struct>

/// NewTerm returns a new union term.
pub fn NewTerm(tilde: bool, typ: Type) -> Ref<Term>

/// NewTuple returns a new tuple for the given variables.
pub fn NewTuple(x: VarArgs<Ref<Var>>) -> Option<Ref<Tuple>>

/// NewTypeName returns a new type name denoting the given typ.
/// The remaining arguments set the attributes found with all Objects.
/// 
/// The typ argument may be a defined (Named) type or an alias type.
/// It may also be nil such that the returned TypeName can be used as
/// argument for NewNamed, which will set the TypeName's type as a side-
/// effect.
pub fn NewTypeName(pos: token.Pos, pkg: Ref<Package>, name: string, typ: Type) -> Ref<TypeName>

/// NewTypeParam returns a new TypeParam. Type parameters may be set on a Named
/// type by calling SetTypeParams. Setting a type parameter on more than one type
/// will result in a panic.
/// 
/// The constraint argument can be nil, and set later via SetConstraint. If the
/// constraint is non-nil, it must be fully defined.
pub fn NewTypeParam(obj: Ref<TypeName>, constraint: Type) -> Ref<TypeParam>

/// NewUnion returns a new [Union] type with the given terms.
/// It is an error to create an empty union; they are syntactically not possible.
pub fn NewUnion(terms: Slice<Ref<Term>>) -> Ref<Union>

/// NewVar returns a new variable.
/// The arguments set the attributes found with all Objects.
/// 
/// The caller must subsequently call [Var.SetKind]
/// if the desired Var is not of kind [PackageVar].
pub fn NewVar(pos: token.Pos, pkg: Ref<Package>, name: string, typ: Type) -> Ref<Var>

/// ObjectString returns the string form of obj.
/// The Qualifier controls the printing of
/// package-level objects, and may be nil.
pub fn ObjectString(obj: Object, qf: Qualifier) -> string

/// RelativeTo returns a [Qualifier] that fully qualifies members of
/// all packages other than pkg.
pub fn RelativeTo(pkg: Ref<Package>) -> Qualifier

/// Satisfies reports whether type V satisfies the constraint T.
/// 
/// The behavior of Satisfies is unspecified if V is Typ[Invalid] or an uninstantiated
/// generic type.
pub fn Satisfies(v: Type, t: Ref<Interface>) -> bool

/// SelectionString returns the string form of s.
/// The Qualifier controls the printing of
/// package-level objects, and may be nil.
/// 
/// Examples:
/// 
/// 	"field (T) f int"
/// 	"method (T) f(X) Y"
/// 	"method expr (T) f(X) Y"
pub fn SelectionString(s: Ref<Selection>, qf: Qualifier) -> string

/// SizesFor returns the Sizes used by a compiler for an architecture.
/// The result is nil if a compiler/architecture pair is not known.
/// 
/// Supported architectures for compiler "gc":
/// "386", "amd64", "amd64p32", "arm", "arm64", "loong64", "mips", "mipsle",
/// "mips64", "mips64le", "ppc64", "ppc64le", "riscv64", "s390x", "sparc64", "wasm".
pub fn SizesFor(compiler: string, arch: string) -> Option<Sizes>

/// TypeString returns the string representation of typ.
/// The [Qualifier] controls the printing of
/// package-level objects, and may be nil.
pub fn TypeString(typ: Type, qf: Qualifier) -> string

/// Unalias returns t if it is not an alias type;
/// otherwise it follows t's alias chain until it
/// reaches a non-alias type which is then returned.
/// Consequently, the result is never an alias type.
pub fn Unalias(t: Type) -> Type

/// WriteExpr writes the (possibly shortened) string representation for x to buf.
/// Shortened representations are suitable for user interfaces but may not
/// necessarily follow Go syntax.
pub fn WriteExpr(buf: Ref<bytes.Buffer>, x: ast.Expr)

/// WriteSignature writes the representation of the signature sig to buf,
/// without a leading "func" keyword. The [Qualifier] controls the printing
/// of package-level objects, and may be nil.
pub fn WriteSignature(
  buf: Ref<bytes.Buffer>,
  sig: Ref<Signature>,
  qf: Qualifier,
)

/// WriteType writes the string representation of typ to buf.
/// The [Qualifier] controls the printing of
/// package-level objects, and may be nil.
pub fn WriteType(buf: Ref<bytes.Buffer>, typ: Type, qf: Qualifier)

/// An Alias represents an alias type.
/// 
/// Alias types are created by alias declarations such as:
/// 
/// 	type A = int
/// 
/// The type on the right-hand side of the declaration can be accessed
/// using [Alias.Rhs]. This type may itself be an alias.
/// Call [Unalias] to obtain the first non-alias type in a chain of
/// alias type declarations.
/// 
/// Like a defined ([Named]) type, an alias type has a name.
/// Use the [Alias.Obj] method to access its [TypeName] object.
/// 
/// Historically, Alias types were not materialized so that, in the example
/// above, A's type was represented by a Basic (int), not an Alias
/// whose [Alias.Rhs] is int. But Go 1.24 allows you to declare an
/// alias type with type parameters or arguments:
/// 
/// 	type Set[K comparable] = map[K]bool
/// 	s := make(Set[String])
/// 
/// and this requires that Alias types be materialized. Use the
/// [Alias.TypeParams] and [Alias.TypeArgs] methods to access them.
/// 
/// To ease the transition, the Alias type was introduced in go1.22,
/// but the type-checker would not construct values of this type unless
/// the GODEBUG=gotypesalias=1 environment variable was provided.
/// Starting in go1.23, this variable is enabled by default.
/// This setting also causes the predeclared type "any" to be
/// represented as an Alias, not a bare [Interface].
pub type Alias

/// An ArgumentError holds an error associated with an argument index.
pub struct ArgumentError {
  pub Index: int,
  pub Err: error,
}

/// An Array represents an array type.
pub type Array

/// A Basic represents a basic type.
pub type Basic

/// BasicInfo is a set of flags describing properties of a basic type.
#[go(bit_flag_set)]
pub struct BasicInfo(int)

/// A Builtin represents a built-in function.
/// Builtins don't have a valid type.
pub type Builtin

/// A Chan represents a channel type.
pub type Chan

/// A Checker maintains the state of the type checker.
/// It must be created with [NewChecker].
pub struct Checker {
  pub Info: Option<Ref<Info>>,
}

/// A Config specifies the configuration for type checking.
/// The zero value for Config is a ready-to-use default configuration.
pub struct Config {
  pub Context: Option<Ref<Context>>,
  pub GoVersion: string,
  pub IgnoreFuncBodies: bool,
  pub FakeImportC: bool,
  pub Error: Option<fn(error) -> ()>,
  pub Importer: Option<Importer>,
  pub Sizes: Option<Sizes>,
  pub DisableUnusedImportCheck: bool,
}

/// A Const represents a declared constant.
pub type Const

/// A Context is an opaque type checking context. It may be used to share
/// identical type instances across type-checked packages or calls to
/// Instantiate. Contexts are safe for concurrent use.
/// 
/// The use of a shared context does not guarantee that identical instances are
/// deduplicated in all cases.
pub type Context

/// An Error describes a type-checking error; it implements the error interface.
/// A "soft" error is an error that still permits a valid interpretation of a
/// package (such as "unused variable"); "hard" errors may lead to unpredictable
/// behavior if ignored.
pub struct Error {
  pub Fset: Option<Ref<token.FileSet>>,
  pub Pos: token.Pos,
  pub Msg: string,
  pub Soft: bool,
}

/// A Func represents a declared function, concrete method, or abstract
/// (interface) method. Its Type() is always a *Signature.
/// An abstract method may belong to many interfaces due to embedding.
pub type Func

/// ImportMode is reserved for future use.
pub struct ImportMode(int)

/// An Importer resolves import paths to Packages.
/// 
/// CAUTION: This interface does not support the import of locally
/// vendored packages. See https://golang.org/s/go15vendor.
/// If possible, external implementations should implement [ImporterFrom].
pub interface Importer {
  fn Import(path: string) -> Result<Ref<Package>, error>
}

/// An ImporterFrom resolves import paths to packages; it
/// supports vendoring per https://golang.org/s/go15vendor.
/// Use go/importer to obtain an ImporterFrom implementation.
pub interface ImporterFrom {
  fn Import(path: string) -> Result<Ref<Package>, error>
  fn ImportFrom(path: string, dir: string, mode: ImportMode) -> Result<Ref<Package>, error>
}

/// Info holds result type information for a type-checked package.
/// Only the information for which a map is provided is collected.
/// If the package has type errors, the collected information may
/// be incomplete.
pub struct Info {
  pub Types: Map<ast.Expr, TypeAndValue>,
  pub Instances: Map<Ref<ast.Ident>, Instance>,
  pub Defs: Map<Ref<ast.Ident>, Option<Object>>,
  pub Uses: Map<Ref<ast.Ident>, Option<Object>>,
  pub Implicits: Map<ast.Node, Option<Object>>,
  pub Selections: Map<Ref<ast.SelectorExpr>, Option<Ref<Selection>>>,
  pub Scopes: Map<ast.Node, Option<Ref<Scope>>>,
  pub InitOrder: Slice<Option<Ref<Initializer>>>,
  pub FileVersions: Map<Ref<ast.File>, string>,
}

/// An Initializer describes a package-level variable, or a list of variables in case
/// of a multi-valued initialization expression, and the corresponding initialization
/// expression.
pub struct Initializer {
  pub Lhs: Slice<Option<Ref<Var>>>,
  pub Rhs: Option<ast.Expr>,
}

/// Instance reports the type arguments and instantiated type for type and
/// function instantiations. For type instantiations, [Type] will be of dynamic
/// type *[Named]. For function instantiations, [Type] will be of dynamic type
/// *Signature.
pub struct Instance {
  pub TypeArgs: Option<Ref<TypeList>>,
  pub Type: Option<Type>,
}

/// An Interface represents an interface type.
pub type Interface

/// A Label represents a declared label.
/// Labels don't have a type.
pub type Label

/// A Map represents a map type.
pub type Map

/// A MethodSet is an ordered set of concrete or abstract (interface) methods;
/// a method is a [MethodVal] selection, and they are ordered by ascending m.Obj().Id().
/// The zero value for a MethodSet is a ready-to-use empty method set.
pub type MethodSet

/// A Named represents a named (defined) type.
/// 
/// A declaration such as:
/// 
/// 	type S struct { ... }
/// 
/// creates a defined type whose underlying type is a struct,
/// and binds this type to the object S, a [TypeName].
/// Use [Named.Underlying] to access the underlying type.
/// Use [Named.Obj] to obtain the object S.
/// 
/// Before type aliases (Go 1.9), the spec called defined types "named types".
pub type Named

/// Nil represents the predeclared value nil.
pub type Nil

/// An Object is a named language entity.
/// An Object may be a constant ([Const]), type name ([TypeName]),
/// variable or struct field ([Var]), function or method ([Func]),
/// imported package ([PkgName]), label ([Label]),
/// built-in function ([Builtin]),
/// or the predeclared identifier 'nil' ([Nil]).
/// 
/// The environment, which is structured as a tree of Scopes,
/// maps each name to the unique Object that it denotes.
pub interface Object {
  fn Exported() -> bool
  fn Id() -> string
  fn Name() -> string
  fn Parent() -> Option<Ref<Scope>>
  fn Pkg() -> Option<Ref<Package>>
  fn Pos() -> token.Pos
  fn String() -> string
  fn Type() -> Option<Type>
}

/// A Package describes a Go package.
pub type Package

/// A PkgName represents an imported Go package.
/// PkgNames don't have a type.
pub type PkgName

/// A Pointer represents a pointer type.
pub type Pointer

/// A Qualifier controls how named package-level objects are printed in
/// calls to [TypeString], [ObjectString], and [SelectionString].
/// 
/// These three formatting routines call the Qualifier for each
/// package-level object O, and if the Qualifier returns a non-empty
/// string p, the object is printed in the form p.O.
/// If it returns an empty string, only the object name O is printed.
/// 
/// Using a nil Qualifier is equivalent to using (*[Package]).Path: the
/// object is qualified by the import path, e.g., "encoding/json.Marshal".
pub type Qualifier = fn(Ref<Package>) -> string

/// A Scope maintains a set of objects and links to its containing
/// (parent) and contained (children) scopes. Objects may be inserted
/// and looked up by name. The zero value for Scope is a ready-to-use
/// empty scope.
pub type Scope

/// A Selection describes a selector expression x.f.
/// For the declarations:
/// 
/// 	type T struct{ x int; E }
/// 	type E struct{}
/// 	func (e E) m() {}
/// 	var p *T
/// 
/// the following relations exist:
/// 
/// 	Selector    Kind          Recv    Obj    Type       Index     Indirect
/// 
/// 	p.x         FieldVal      T       x      int        {0}       true
/// 	p.m         MethodVal     *T      m      func()     {1, 0}    true
/// 	T.m         MethodExpr    T       m      func(T)    {1, 0}    false
pub type Selection

/// A Signature represents a (non-builtin) function or method type.
/// The receiver is ignored when comparing signatures for identity.
pub type Signature

/// Sizes defines the sizing functions for package unsafe.
pub interface Sizes {
  fn Alignof(t: Type) -> int64
  fn Offsetsof(fields: Slice<Ref<Var>>) -> Slice<int64>
  fn Sizeof(t: Type) -> int64
}

/// A Slice represents a slice type.
pub type Slice

/// StdSizes is a convenience type for creating commonly used Sizes.
/// It makes the following simplifying assumptions:
/// 
///   - The size of explicitly sized basic types (int16, etc.) is the
///     specified size.
///   - The size of strings and interfaces is 2*WordSize.
///   - The size of slices is 3*WordSize.
///   - The size of an array of n elements corresponds to the size of
///     a struct of n consecutive fields of the array's element type.
///   - The size of a struct is the offset of the last field plus that
///     field's size. As with all element types, if the struct is used
///     in an array its size must first be aligned to a multiple of the
///     struct's alignment.
///   - All other types have size WordSize.
///   - Arrays and structs are aligned per spec definition; all other
///     types are naturally aligned with a maximum alignment MaxAlign.
/// 
/// *StdSizes implements Sizes.
pub struct StdSizes {
  pub WordSize: int64,
  pub MaxAlign: int64,
}

/// A Struct represents a struct type.
pub type Struct

/// A Term represents a term in a [Union].
pub type Term

/// A Tuple represents an ordered list of variables; a nil *Tuple is a valid (empty) tuple.
/// Tuples are used as components of signatures and to represent the type of multiple
/// assignments; they are not first class types of Go.
pub type Tuple

/// A Type represents a type of Go.
/// All types implement the Type interface.
pub interface Type {
  fn String() -> string
  fn Underlying() -> Option<Type>
}

/// TypeAndValue reports the type and value (for constants)
/// of the corresponding expression.
pub struct TypeAndValue {
  pub Type: Option<Type>,
  pub Value: Option<constant.Value>,
}

/// TypeList holds a list of types.
pub type TypeList

/// A TypeName is an [Object] that represents a type with a name:
/// a defined type ([Named]),
/// an alias type ([Alias]),
/// a type parameter ([TypeParam]),
/// or a predeclared type such as int or error.
pub type TypeName

/// A TypeParam represents the type of a type parameter in a generic declaration.
/// 
/// A TypeParam has a name; use the [TypeParam.Obj] method to access
/// its [TypeName] object.
pub type TypeParam

/// TypeParamList holds a list of type parameters.
pub type TypeParamList

/// A Union represents a union of terms embedded in an interface.
pub type Union

/// A Variable represents a declared variable (including function parameters and results, and struct fields).
pub type Var

pub const IsBoolean: BasicInfo = 1

pub const IsComplex: BasicInfo = 16

pub const IsConstType: BasicInfo = 59

pub const IsFloat: BasicInfo = 8

pub const IsInteger: BasicInfo = 2

pub const IsNumeric: BasicInfo = 26

pub const IsOrdered: BasicInfo = 42

pub const IsString: BasicInfo = 32

pub const IsUnsigned: BasicInfo = 4

pub const IsUntyped: BasicInfo = 64

/// Typ contains the predeclared *Basic types indexed by their
/// corresponding BasicKind.
/// 
/// The *Basic type for Typ[Byte] will have the name "uint8".
/// Use Universe.Lookup("byte").Type() to obtain the specific
/// alias basic type named "byte" (and analogous for "rune").
pub var Typ: Slice<Ref<Basic>>

pub var Universe: Ref<Scope>

pub var Unsafe: Ref<Package>

impl Alias {
  /// Obj returns the type name for the declaration defining the alias type a.
  /// For instantiated types, this is same as the type name of the origin type.
  fn Obj(self: Ref<Alias>) -> Ref<TypeName>

  /// Origin returns the generic Alias type of which a is an instance.
  /// If a is not an instance of a generic alias, Origin returns a.
  fn Origin(self: Ref<Alias>) -> Ref<Alias>

  /// Rhs returns the type R on the right-hand side of an alias
  /// declaration "type A = R", which may be another alias.
  fn Rhs(self: Ref<Alias>) -> Type

  /// SetTypeParams sets the type parameters of the alias type a.
  /// The alias a must not have type arguments.
  fn SetTypeParams(self: Ref<Alias>, tparams: Slice<Ref<TypeParam>>)

  fn String(self: Ref<Alias>) -> string

  /// TypeArgs returns the type arguments used to instantiate the Alias type.
  /// If a is not an instance of a generic alias, the result is nil.
  fn TypeArgs(self: Ref<Alias>) -> Option<Ref<TypeList>>

  /// TypeParams returns the type parameters of the alias type a, or nil.
  /// A generic Alias and its instances have the same type parameters.
  fn TypeParams(self: Ref<Alias>) -> Option<Ref<TypeParamList>>

  /// Underlying returns the [underlying type] of the alias type a, which is the
  /// underlying type of the aliased type. Underlying types are never Named,
  /// TypeParam, or Alias types.
  /// 
  /// [underlying type]: https://go.dev/ref/spec#Underlying_types.
  fn Underlying(self: Ref<Alias>) -> Type
}

impl ArgumentError {
  fn Error(self: Ref<ArgumentError>) -> string

  fn Unwrap(self: Ref<ArgumentError>) -> Option<error>
}

impl Array {
  /// Elem returns element type of array a.
  fn Elem(self: Ref<Array>) -> Type

  /// Len returns the length of array a.
  /// A negative result indicates an unknown length.
  fn Len(self: Ref<Array>) -> int64

  fn String(self: Ref<Array>) -> string

  fn Underlying(self: Ref<Array>) -> Type
}

impl Basic {
  /// Info returns information about properties of basic type b.
  fn Info(self: Ref<Basic>) -> BasicInfo

  /// Kind returns the kind of basic type b.
  fn Kind(self: Ref<Basic>) -> BasicKind

  /// Name returns the name of basic type b.
  fn Name(self: Ref<Basic>) -> string

  fn String(self: Ref<Basic>) -> string

  fn Underlying(self: Ref<Basic>) -> Type
}

impl Builtin {
  /// Exported reports whether the object is exported (starts with a capital letter).
  /// It doesn't take into account whether the object is in a local (function) scope
  /// or not.
  fn Exported(self: Ref<Builtin>) -> bool

  /// Id is a wrapper for Id(obj.Pkg(), obj.Name()).
  fn Id(self: Ref<Builtin>) -> string

  /// Name returns the object's (package-local, unqualified) name.
  fn Name(self: Ref<Builtin>) -> string

  /// Parent returns the scope in which the object is declared.
  /// The result is nil for methods and struct fields.
  fn Parent(self: Ref<Builtin>) -> Option<Ref<Scope>>

  /// Pkg returns the package to which the object belongs.
  /// The result is nil for labels and objects in the Universe scope.
  fn Pkg(self: Ref<Builtin>) -> Option<Ref<Package>>

  /// Pos returns the declaration position of the object's identifier.
  fn Pos(self: Ref<Builtin>) -> token.Pos

  fn String(self: Ref<Builtin>) -> string

  /// Type returns the object's type.
  fn Type(self: Ref<Builtin>) -> Type
}

impl Chan {
  /// Dir returns the direction of channel c.
  fn Dir(self: Ref<Chan>) -> ChanDir

  /// Elem returns the element type of channel c.
  fn Elem(self: Ref<Chan>) -> Type

  fn String(self: Ref<Chan>) -> string

  fn Underlying(self: Ref<Chan>) -> Type
}

impl Checker {
  /// Files checks the provided files as part of the checker's package.
  fn Files(self: Ref<Checker>, files: Slice<Ref<ast.File>>) -> Result<(), error>

  /// ObjectOf returns the object denoted by the specified id,
  /// or nil if not found.
  /// 
  /// If id is an embedded struct field, [Info.ObjectOf] returns the field (*[Var])
  /// it defines, not the type (*[TypeName]) it uses.
  /// 
  /// Precondition: the Uses and Defs maps are populated.
  fn ObjectOf(self: Ref<Checker>, id: Ref<ast.Ident>) -> Option<Object>

  /// PkgNameOf returns the local package name defined by the import,
  /// or nil if not found.
  /// 
  /// For dot-imports, the package name is ".".
  /// 
  /// Precondition: the Defs and Implicts maps are populated.
  fn PkgNameOf(self: Ref<Checker>, imp: Ref<ast.ImportSpec>) -> Option<Ref<PkgName>>

  /// TypeOf returns the type of expression e, or nil if not found.
  /// Precondition: the Types, Uses and Defs maps are populated.
  fn TypeOf(self: Ref<Checker>, e: ast.Expr) -> Option<Type>
}

impl Config {
  /// Check type-checks a package and returns the resulting package object and
  /// the first error if any. Additionally, if info != nil, Check populates each
  /// of the non-nil maps in the [Info] struct.
  /// 
  /// The package is marked as complete if no errors occurred, otherwise it is
  /// incomplete. See [Config.Error] for controlling behavior in the presence of
  /// errors.
  /// 
  /// The package is specified by a list of *ast.Files and corresponding
  /// file set, and the package path the package is identified with.
  /// The clean path must not be empty or dot (".").
  fn Check(
    self: Ref<Config>,
    path: string,
    fset: Ref<token.FileSet>,
    files: Slice<Ref<ast.File>>,
    info: Ref<Info>,
  ) -> Partial<Ref<Package>, error>
}

impl Const {
  /// Exported reports whether the object is exported (starts with a capital letter).
  /// It doesn't take into account whether the object is in a local (function) scope
  /// or not.
  fn Exported(self: Ref<Const>) -> bool

  /// Id is a wrapper for Id(obj.Pkg(), obj.Name()).
  fn Id(self: Ref<Const>) -> string

  /// Name returns the object's (package-local, unqualified) name.
  fn Name(self: Ref<Const>) -> string

  /// Parent returns the scope in which the object is declared.
  /// The result is nil for methods and struct fields.
  fn Parent(self: Ref<Const>) -> Option<Ref<Scope>>

  /// Pkg returns the package to which the object belongs.
  /// The result is nil for labels and objects in the Universe scope.
  fn Pkg(self: Ref<Const>) -> Option<Ref<Package>>

  /// Pos returns the declaration position of the object's identifier.
  fn Pos(self: Ref<Const>) -> token.Pos

  fn String(self: Ref<Const>) -> string

  /// Type returns the object's type.
  fn Type(self: Ref<Const>) -> Type

  /// Val returns the constant's value.
  fn Val(self: Ref<Const>) -> Option<constant.Value>
}

impl Error {
  /// Error returns an error string formatted as follows:
  /// filename:line:column: message
  fn Error(self) -> string
}

impl Func {
  /// Exported reports whether the object is exported (starts with a capital letter).
  /// It doesn't take into account whether the object is in a local (function) scope
  /// or not.
  fn Exported(self: Ref<Func>) -> bool

  /// FullName returns the package- or receiver-type-qualified name of
  /// function or method obj.
  fn FullName(self: Ref<Func>) -> string

  /// Id is a wrapper for Id(obj.Pkg(), obj.Name()).
  fn Id(self: Ref<Func>) -> string

  /// Name returns the object's (package-local, unqualified) name.
  fn Name(self: Ref<Func>) -> string

  /// Origin returns the canonical Func for its receiver, i.e. the Func object
  /// recorded in Info.Defs.
  /// 
  /// For synthetic functions created during instantiation (such as methods on an
  /// instantiated Named type or interface methods that depend on type arguments),
  /// this will be the corresponding Func on the generic (uninstantiated) type.
  /// For all other Funcs Origin returns the receiver.
  fn Origin(self: Ref<Func>) -> Ref<Func>

  /// Parent returns the scope in which the object is declared.
  /// The result is nil for methods and struct fields.
  fn Parent(self: Ref<Func>) -> Option<Ref<Scope>>

  /// Pkg returns the package to which the function belongs.
  /// 
  /// The result is nil for methods of types in the Universe scope,
  /// like method Error of the error built-in interface type.
  fn Pkg(self: Ref<Func>) -> Option<Ref<Package>>

  /// Pos returns the declaration position of the object's identifier.
  fn Pos(self: Ref<Func>) -> token.Pos

  /// Scope returns the scope of the function's body block.
  /// The result is nil for imported or instantiated functions and methods
  /// (but there is also no mechanism to get to an instantiated function).
  fn Scope(self: Ref<Func>) -> Option<Ref<Scope>>

  /// Signature returns the signature (type) of the function or method.
  fn Signature(self: Ref<Func>) -> Ref<Signature>

  fn String(self: Ref<Func>) -> string

  /// Type returns the object's type.
  fn Type(self: Ref<Func>) -> Type
}

impl Info {
  /// ObjectOf returns the object denoted by the specified id,
  /// or nil if not found.
  /// 
  /// If id is an embedded struct field, [Info.ObjectOf] returns the field (*[Var])
  /// it defines, not the type (*[TypeName]) it uses.
  /// 
  /// Precondition: the Uses and Defs maps are populated.
  fn ObjectOf(self: Ref<Info>, id: Ref<ast.Ident>) -> Option<Object>

  /// PkgNameOf returns the local package name defined by the import,
  /// or nil if not found.
  /// 
  /// For dot-imports, the package name is ".".
  /// 
  /// Precondition: the Defs and Implicts maps are populated.
  fn PkgNameOf(self: Ref<Info>, imp: Ref<ast.ImportSpec>) -> Option<Ref<PkgName>>

  /// TypeOf returns the type of expression e, or nil if not found.
  /// Precondition: the Types, Uses and Defs maps are populated.
  fn TypeOf(self: Ref<Info>, e: ast.Expr) -> Option<Type>
}

impl Initializer {
  fn String(self: Ref<Initializer>) -> string
}

impl Interface {
  /// Complete computes the interface's type set. It must be called by users of
  /// [NewInterfaceType] and [NewInterface] after the interface's embedded types are
  /// fully defined and before using the interface type in any way other than to
  /// form other types. The interface must not contain duplicate methods or a
  /// panic occurs. Complete returns the receiver.
  /// 
  /// Interface types that have been completed are safe for concurrent use.
  #[allow(unused_value)]
  fn Complete(self: Ref<Interface>) -> Ref<Interface>

  /// Embedded returns the i'th embedded defined (*[Named]) type of interface t for 0 <= i < t.NumEmbeddeds().
  /// The result is nil if the i'th embedded type is not a defined type.
  /// 
  /// Deprecated: Use [Interface.EmbeddedType] which is not restricted to defined (*[Named]) types.
  fn Embedded(self: Ref<Interface>, i: int) -> Option<Ref<Named>>

  /// EmbeddedType returns the i'th embedded type of interface t for 0 <= i < t.NumEmbeddeds().
  fn EmbeddedType(self: Ref<Interface>, i: int) -> Type

  /// EmbeddedTypes returns a go1.23 iterator over the types embedded within an interface.
  /// 
  /// Example: for e := range t.EmbeddedTypes() { ... }
  fn EmbeddedTypes(self: Ref<Interface>) -> iter.Seq<Type>

  /// Empty reports whether t is the empty interface.
  fn Empty(self: Ref<Interface>) -> bool

  /// ExplicitMethod returns the i'th explicitly declared method of interface t for 0 <= i < t.NumExplicitMethods().
  /// The methods are ordered by their unique [Id].
  fn ExplicitMethod(self: Ref<Interface>, i: int) -> Ref<Func>

  /// ExplicitMethods returns a go1.23 iterator over the explicit methods of
  /// an interface, ordered by Id.
  /// 
  /// Example: for m := range t.ExplicitMethods() { ... }
  fn ExplicitMethods(self: Ref<Interface>) -> iter.Seq<Ref<Func>>

  /// IsComparable reports whether each type in interface t's type set is comparable.
  fn IsComparable(self: Ref<Interface>) -> bool

  /// IsImplicit reports whether the interface t is a wrapper for a type set literal.
  fn IsImplicit(self: Ref<Interface>) -> bool

  /// IsMethodSet reports whether the interface t is fully described by its method
  /// set.
  fn IsMethodSet(self: Ref<Interface>) -> bool

  /// MarkImplicit marks the interface t as implicit, meaning this interface
  /// corresponds to a constraint literal such as ~T or A|B without explicit
  /// interface embedding. MarkImplicit should be called before any concurrent use
  /// of implicit interfaces.
  fn MarkImplicit(self: Ref<Interface>)

  /// Method returns the i'th method of interface t for 0 <= i < t.NumMethods().
  /// The methods are ordered by their unique Id.
  fn Method(self: Ref<Interface>, i: int) -> Ref<Func>

  /// Methods returns a go1.23 iterator over all the methods of an
  /// interface, ordered by Id.
  /// 
  /// Example: for m := range t.Methods() { ... }
  fn Methods(self: Ref<Interface>) -> iter.Seq<Ref<Func>>

  /// NumEmbeddeds returns the number of embedded types in interface t.
  fn NumEmbeddeds(self: Ref<Interface>) -> int

  /// NumExplicitMethods returns the number of explicitly declared methods of interface t.
  fn NumExplicitMethods(self: Ref<Interface>) -> int

  /// NumMethods returns the total number of methods of interface t.
  fn NumMethods(self: Ref<Interface>) -> int

  fn String(self: Ref<Interface>) -> string

  fn Underlying(self: Ref<Interface>) -> Type
}

impl Label {
  /// Exported reports whether the object is exported (starts with a capital letter).
  /// It doesn't take into account whether the object is in a local (function) scope
  /// or not.
  fn Exported(self: Ref<Label>) -> bool

  /// Id is a wrapper for Id(obj.Pkg(), obj.Name()).
  fn Id(self: Ref<Label>) -> string

  /// Name returns the object's (package-local, unqualified) name.
  fn Name(self: Ref<Label>) -> string

  /// Parent returns the scope in which the object is declared.
  /// The result is nil for methods and struct fields.
  fn Parent(self: Ref<Label>) -> Option<Ref<Scope>>

  /// Pkg returns the package to which the object belongs.
  /// The result is nil for labels and objects in the Universe scope.
  fn Pkg(self: Ref<Label>) -> Option<Ref<Package>>

  /// Pos returns the declaration position of the object's identifier.
  fn Pos(self: Ref<Label>) -> token.Pos

  fn String(self: Ref<Label>) -> string

  /// Type returns the object's type.
  fn Type(self: Ref<Label>) -> Type
}

impl Map {
  /// Elem returns the element type of map m.
  fn Elem(self: Ref<Map>) -> Type

  /// Key returns the key type of map m.
  fn Key(self: Ref<Map>) -> Type

  fn String(self: Ref<Map>) -> string

  fn Underlying(self: Ref<Map>) -> Type
}

impl MethodSet {
  /// At returns the i'th method in s for 0 <= i < s.Len().
  fn At(self: Ref<MethodSet>, i: int) -> Ref<Selection>

  /// Len returns the number of methods in s.
  fn Len(self: Ref<MethodSet>) -> int

  /// Lookup returns the method with matching package and name, or nil if not found.
  fn Lookup(self: Ref<MethodSet>, pkg: Ref<Package>, name: string) -> Option<Ref<Selection>>

  /// Methods returns a go1.23 iterator over the methods of a method set.
  /// 
  /// Example: for method := range s.Methods() { ... }
  fn Methods(self: Ref<MethodSet>) -> iter.Seq<Ref<Selection>>

  fn String(self: Ref<MethodSet>) -> string
}

impl Named {
  /// AddMethod adds method m unless it is already in the method list.
  /// The method must be in the same package as t, and t must not have
  /// type arguments.
  fn AddMethod(self: Ref<Named>, m: Ref<Func>)

  /// Method returns the i'th method of named type t for 0 <= i < t.NumMethods().
  /// 
  /// For an ordinary or instantiated type t, the receiver base type of this
  /// method is the named type t. For an uninstantiated generic type t, each
  /// method receiver is instantiated with its receiver type parameters.
  /// 
  /// Methods are numbered deterministically: given the same list of source files
  /// presented to the type checker, or the same sequence of NewMethod and AddMethod
  /// calls, the mapping from method index to corresponding method remains the same.
  /// But the specific ordering is not specified and must not be relied on as it may
  /// change in the future.
  fn Method(self: Ref<Named>, i: int) -> Ref<Func>

  /// Methods returns a go1.23 iterator over the declared methods of a named type.
  /// 
  /// Example: for m := range t.Methods() { ... }
  fn Methods(self: Ref<Named>) -> iter.Seq<Ref<Func>>

  /// NumMethods returns the number of explicit methods defined for t.
  fn NumMethods(self: Ref<Named>) -> int

  /// Obj returns the type name for the declaration defining the named type t. For
  /// instantiated types, this is same as the type name of the origin type.
  fn Obj(self: Ref<Named>) -> Ref<TypeName>

  /// Origin returns the generic type from which the named type t is
  /// instantiated. If t is not an instantiated type, the result is t.
  fn Origin(self: Ref<Named>) -> Ref<Named>

  /// SetTypeParams sets the type parameters of the named type t.
  /// t must not have type arguments.
  fn SetTypeParams(self: Ref<Named>, tparams: Slice<Ref<TypeParam>>)

  /// SetUnderlying sets the underlying type and marks t as complete.
  /// t must not have type arguments.
  fn SetUnderlying(self: Ref<Named>, underlying: Type)

  fn String(self: Ref<Named>) -> string

  /// TypeArgs returns the type arguments used to instantiate the named type t.
  fn TypeArgs(self: Ref<Named>) -> Option<Ref<TypeList>>

  /// TypeParams returns the type parameters of the named type t, or nil.
  /// The result is non-nil for an (originally) generic type even if it is instantiated.
  fn TypeParams(self: Ref<Named>) -> Option<Ref<TypeParamList>>

  /// Underlying returns the [underlying type] of the named type t, resolving all
  /// forwarding declarations. Underlying types are never Named, TypeParam, or
  /// Alias types.
  /// 
  /// [underlying type]: https://go.dev/ref/spec#Underlying_types.
  fn Underlying(self: Ref<Named>) -> Type
}

impl Nil {
  /// Exported reports whether the object is exported (starts with a capital letter).
  /// It doesn't take into account whether the object is in a local (function) scope
  /// or not.
  fn Exported(self: Ref<Nil>) -> bool

  /// Id is a wrapper for Id(obj.Pkg(), obj.Name()).
  fn Id(self: Ref<Nil>) -> string

  /// Name returns the object's (package-local, unqualified) name.
  fn Name(self: Ref<Nil>) -> string

  /// Parent returns the scope in which the object is declared.
  /// The result is nil for methods and struct fields.
  fn Parent(self: Ref<Nil>) -> Option<Ref<Scope>>

  /// Pkg returns the package to which the object belongs.
  /// The result is nil for labels and objects in the Universe scope.
  fn Pkg(self: Ref<Nil>) -> Option<Ref<Package>>

  /// Pos returns the declaration position of the object's identifier.
  fn Pos(self: Ref<Nil>) -> token.Pos

  fn String(self: Ref<Nil>) -> string

  /// Type returns the object's type.
  fn Type(self: Ref<Nil>) -> Type
}

impl Package {
  /// A package is complete if its scope contains (at least) all
  /// exported objects; otherwise it is incomplete.
  fn Complete(self: Ref<Package>) -> bool

  /// GoVersion returns the minimum Go version required by this package.
  /// If the minimum version is unknown, GoVersion returns the empty string.
  /// Individual source files may specify a different minimum Go version,
  /// as reported in the [go/ast.File.GoVersion] field.
  fn GoVersion(self: Ref<Package>) -> string

  /// Imports returns the list of packages directly imported by
  /// pkg; the list is in source order.
  /// 
  /// If pkg was loaded from export data, Imports includes packages that
  /// provide package-level objects referenced by pkg. This may be more or
  /// less than the set of packages directly imported by pkg's source code.
  /// 
  /// If pkg uses cgo and the FakeImportC configuration option
  /// was enabled, the imports list may contain a fake "C" package.
  fn Imports(self: Ref<Package>) -> Slice<Ref<Package>>

  /// MarkComplete marks a package as complete.
  fn MarkComplete(self: Ref<Package>)

  /// Name returns the package name.
  fn Name(self: Ref<Package>) -> string

  /// Path returns the package path.
  fn Path(self: Ref<Package>) -> string

  /// Scope returns the (complete or incomplete) package scope
  /// holding the objects declared at package level (TypeNames,
  /// Consts, Vars, and Funcs).
  /// For a nil pkg receiver, Scope returns the Universe scope.
  fn Scope(self: Ref<Package>) -> Ref<Scope>

  /// SetImports sets the list of explicitly imported packages to list.
  /// It is the caller's responsibility to make sure list elements are unique.
  fn SetImports(self: Ref<Package>, list: Slice<Ref<Package>>)

  /// SetName sets the package name.
  fn SetName(self: Ref<Package>, name: string)

  fn String(self: Ref<Package>) -> string
}

impl PkgName {
  /// Exported reports whether the object is exported (starts with a capital letter).
  /// It doesn't take into account whether the object is in a local (function) scope
  /// or not.
  fn Exported(self: Ref<PkgName>) -> bool

  /// Id is a wrapper for Id(obj.Pkg(), obj.Name()).
  fn Id(self: Ref<PkgName>) -> string

  /// Imported returns the package that was imported.
  /// It is distinct from Pkg(), which is the package containing the import statement.
  fn Imported(self: Ref<PkgName>) -> Ref<Package>

  /// Name returns the object's (package-local, unqualified) name.
  fn Name(self: Ref<PkgName>) -> string

  /// Parent returns the scope in which the object is declared.
  /// The result is nil for methods and struct fields.
  fn Parent(self: Ref<PkgName>) -> Option<Ref<Scope>>

  /// Pkg returns the package to which the object belongs.
  /// The result is nil for labels and objects in the Universe scope.
  fn Pkg(self: Ref<PkgName>) -> Option<Ref<Package>>

  /// Pos returns the declaration position of the object's identifier.
  fn Pos(self: Ref<PkgName>) -> token.Pos

  fn String(self: Ref<PkgName>) -> string

  /// Type returns the object's type.
  fn Type(self: Ref<PkgName>) -> Type
}

impl Pointer {
  /// Elem returns the element type for the given pointer p.
  fn Elem(self: Ref<Pointer>) -> Type

  fn String(self: Ref<Pointer>) -> string

  fn Underlying(self: Ref<Pointer>) -> Type
}

impl Scope {
  /// Child returns the i'th child scope for 0 <= i < NumChildren().
  fn Child(self: Ref<Scope>, i: int) -> Ref<Scope>

  /// Children returns a go1.23 iterator over the child scopes nested within scope s.
  /// 
  /// Example: for child := range scope.Children() { ... }
  fn Children(self: Ref<Scope>) -> iter.Seq<Ref<Scope>>

  /// Contains reports whether pos is within the scope's extent.
  /// The result is guaranteed to be valid only if the type-checked
  /// AST has complete position information.
  fn Contains(self: Ref<Scope>, pos: token.Pos) -> bool

  fn End(self: Ref<Scope>) -> token.Pos

  /// Innermost returns the innermost (child) scope containing
  /// pos. If pos is not within any scope, the result is nil.
  /// The result is also nil for the Universe scope.
  /// The result is guaranteed to be valid only if the type-checked
  /// AST has complete position information.
  fn Innermost(self: Ref<Scope>, pos: token.Pos) -> Option<Ref<Scope>>

  /// Insert attempts to insert an object obj into scope s.
  /// If s already contains an alternative object alt with
  /// the same name, Insert leaves s unchanged and returns alt.
  /// Otherwise it inserts obj, sets the object's parent scope
  /// if not already set, and returns nil.
  fn Insert(self: Ref<Scope>, obj: Object) -> Option<Object>

  /// Len returns the number of scope elements.
  fn Len(self: Ref<Scope>) -> int

  /// Lookup returns the object in scope s with the given name if such an
  /// object exists; otherwise the result is nil.
  fn Lookup(self: Ref<Scope>, name: string) -> Option<Object>

  /// LookupParent follows the parent chain of scopes starting with s until
  /// it finds a scope where Lookup(name) returns a non-nil object, and then
  /// returns that scope and object. If a valid position pos is provided,
  /// only objects that were declared at or before pos are considered.
  /// If no such scope and object exists, the result is (nil, nil).
  /// The results are guaranteed to be valid only if the type-checked
  /// AST has complete position information.
  /// 
  /// Note that obj.Parent() may be different from the returned scope if the
  /// object was inserted into the scope and already had a parent at that
  /// time (see Insert). This can only happen for dot-imported objects
  /// whose parent is the scope of the package that exported them.
  fn LookupParent(self: Ref<Scope>, name: string, pos: token.Pos) -> (Ref<Scope>, Object)

  /// Names returns the scope's element names in sorted order.
  fn Names(self: Ref<Scope>) -> Slice<string>

  /// NumChildren returns the number of scopes nested in s.
  fn NumChildren(self: Ref<Scope>) -> int

  /// Parent returns the scope's containing (parent) scope.
  fn Parent(self: Ref<Scope>) -> Option<Ref<Scope>>

  /// Pos and End describe the scope's source code extent [pos, end).
  /// The results are guaranteed to be valid only if the type-checked
  /// AST has complete position information. The extent is undefined
  /// for Universe and package scopes.
  fn Pos(self: Ref<Scope>) -> token.Pos

  /// String returns a string representation of the scope, for debugging.
  fn String(self: Ref<Scope>) -> string

  /// WriteTo writes a string representation of the scope to w,
  /// with the scope elements sorted by name.
  /// The level of indentation is controlled by n >= 0, with
  /// n == 0 for no indentation.
  /// If recurse is set, it also writes nested (children) scopes.
  fn WriteTo(self: Ref<Scope>, w: io.Writer, n: int, recurse: bool)
}

impl Selection {
  /// Index describes the path from x to f in x.f.
  /// The last index entry is the field or method index of the type declaring f;
  /// either:
  /// 
  ///  1. the list of declared methods of a named type; or
  ///  2. the list of methods of an interface type; or
  ///  3. the list of fields of a struct type.
  /// 
  /// The earlier index entries are the indices of the embedded fields implicitly
  /// traversed to get from (the type of) x to f, starting at embedding depth 0.
  fn Index(self: Ref<Selection>) -> Slice<int>

  /// Indirect reports whether any pointer indirection was required to get from
  /// x to f in x.f.
  /// 
  /// Beware: Indirect spuriously returns true (Go issue #8353) for a
  /// MethodVal selection in which the receiver argument and parameter
  /// both have type *T so there is no indirection.
  /// Unfortunately, a fix is too risky.
  fn Indirect(self: Ref<Selection>) -> bool

  /// Kind returns the selection kind.
  fn Kind(self: Ref<Selection>) -> SelectionKind

  /// Obj returns the object denoted by x.f; a *Var for
  /// a field selection, and a *Func in all other cases.
  fn Obj(self: Ref<Selection>) -> Object

  /// Recv returns the type of x in x.f.
  fn Recv(self: Ref<Selection>) -> Type

  fn String(self: Ref<Selection>) -> string

  /// Type returns the type of x.f, which may be different from the type of f.
  /// See Selection for more information.
  fn Type(self: Ref<Selection>) -> Type
}

impl Signature {
  /// Params returns the parameters of signature s, or nil.
  fn Params(self: Ref<Signature>) -> Option<Ref<Tuple>>

  /// Recv returns the receiver of signature s (if a method), or nil if a
  /// function. It is ignored when comparing signatures for identity.
  /// 
  /// For an abstract method, Recv returns the enclosing interface either
  /// as a *[Named] or an *[Interface]. Due to embedding, an interface may
  /// contain methods whose receiver type is a different interface.
  fn Recv(self: Ref<Signature>) -> Option<Ref<Var>>

  /// RecvTypeParams returns the receiver type parameters of signature s, or nil.
  fn RecvTypeParams(self: Ref<Signature>) -> Option<Ref<TypeParamList>>

  /// Results returns the results of signature s, or nil.
  fn Results(self: Ref<Signature>) -> Option<Ref<Tuple>>

  fn String(self: Ref<Signature>) -> string

  /// TypeParams returns the type parameters of signature s, or nil.
  fn TypeParams(self: Ref<Signature>) -> Option<Ref<TypeParamList>>

  fn Underlying(self: Ref<Signature>) -> Type

  /// Variadic reports whether the signature s is variadic.
  fn Variadic(self: Ref<Signature>) -> bool
}

impl Slice {
  /// Elem returns the element type of slice s.
  fn Elem(self: Ref<Slice>) -> Type

  fn String(self: Ref<Slice>) -> string

  fn Underlying(self: Ref<Slice>) -> Type
}

impl StdSizes {
  fn Alignof(self: Ref<StdSizes>, t: Type) -> int64

  fn Offsetsof(self: Ref<StdSizes>, fields: Slice<Ref<Var>>) -> Slice<int64>

  fn Sizeof(self: Ref<StdSizes>, t: Type) -> int64
}

impl Struct {
  /// Field returns the i'th field for 0 <= i < NumFields().
  fn Field(self: Ref<Struct>, i: int) -> Ref<Var>

  /// Fields returns a go1.23 iterator over the fields of a struct type.
  /// 
  /// Example: for field := range s.Fields() { ... }
  fn Fields(self: Ref<Struct>) -> iter.Seq<Ref<Var>>

  /// NumFields returns the number of fields in the struct (including blank and embedded fields).
  fn NumFields(self: Ref<Struct>) -> int

  fn String(self: Ref<Struct>) -> string

  /// Tag returns the i'th field tag for 0 <= i < NumFields().
  fn Tag(self: Ref<Struct>, i: int) -> string

  fn Underlying(self: Ref<Struct>) -> Type
}

impl Term {
  fn String(self: Ref<Term>) -> string

  fn Tilde(self: Ref<Term>) -> bool

  fn Type(self: Ref<Term>) -> Type
}

impl Tuple {
  /// At returns the i'th variable of tuple t.
  fn At(self: Ref<Tuple>, i: int) -> Ref<Var>

  /// Len returns the number variables of tuple t.
  fn Len(self: Ref<Tuple>) -> int

  fn String(self: Ref<Tuple>) -> string

  fn Underlying(self: Ref<Tuple>) -> Type

  /// Variables returns a go1.23 iterator over the variables of a tuple type.
  /// 
  /// Example: for v := range tuple.Variables() { ... }
  fn Variables(self: Ref<Tuple>) -> iter.Seq<Ref<Var>>
}

impl TypeAndValue {
  /// Addressable reports whether the corresponding expression
  /// is addressable (https://golang.org/ref/spec#Address_operators).
  fn Addressable(self) -> bool

  /// Assignable reports whether the corresponding expression
  /// is assignable to (provided a value of the right type).
  fn Assignable(self) -> bool

  /// HasOk reports whether the corresponding expression may be
  /// used on the rhs of a comma-ok assignment.
  fn HasOk(self) -> bool

  /// IsBuiltin reports whether the corresponding expression denotes
  /// a (possibly parenthesized) built-in function.
  fn IsBuiltin(self) -> bool

  /// IsNil reports whether the corresponding expression denotes the
  /// predeclared value nil.
  fn IsNil(self) -> bool

  /// IsType reports whether the corresponding expression specifies a type.
  fn IsType(self) -> bool

  /// IsValue reports whether the corresponding expression is a value.
  /// Builtins are not considered values. Constant values have a non-
  /// nil Value.
  fn IsValue(self) -> bool

  /// IsVoid reports whether the corresponding expression
  /// is a function call without results.
  fn IsVoid(self) -> bool
}

impl TypeList {
  /// At returns the i'th type in the list.
  fn At(self: Ref<TypeList>, i: int) -> Type

  /// Len returns the number of types in the list.
  /// It is safe to call on a nil receiver.
  fn Len(self: Ref<TypeList>) -> int

  /// Types returns a go1.23 iterator over the elements of a list of types.
  /// 
  /// Example: for t := range l.Types() { ... }
  fn Types(self: Ref<TypeList>) -> iter.Seq<Type>
}

impl TypeName {
  /// Exported reports whether the object is exported (starts with a capital letter).
  /// It doesn't take into account whether the object is in a local (function) scope
  /// or not.
  fn Exported(self: Ref<TypeName>) -> bool

  /// Id is a wrapper for Id(obj.Pkg(), obj.Name()).
  fn Id(self: Ref<TypeName>) -> string

  /// IsAlias reports whether obj is an alias name for a type.
  fn IsAlias(self: Ref<TypeName>) -> bool

  /// Name returns the object's (package-local, unqualified) name.
  fn Name(self: Ref<TypeName>) -> string

  /// Parent returns the scope in which the object is declared.
  /// The result is nil for methods and struct fields.
  fn Parent(self: Ref<TypeName>) -> Option<Ref<Scope>>

  /// Pkg returns the package to which the object belongs.
  /// The result is nil for labels and objects in the Universe scope.
  fn Pkg(self: Ref<TypeName>) -> Option<Ref<Package>>

  /// Pos returns the declaration position of the object's identifier.
  fn Pos(self: Ref<TypeName>) -> token.Pos

  fn String(self: Ref<TypeName>) -> string

  /// Type returns the object's type.
  fn Type(self: Ref<TypeName>) -> Type
}

impl TypeParam {
  /// Constraint returns the type constraint specified for t.
  fn Constraint(self: Ref<TypeParam>) -> Type

  /// Index returns the index of the type param within its param list, or -1 if
  /// the type parameter has not yet been bound to a type.
  fn Index(self: Ref<TypeParam>) -> int

  /// Obj returns the type name for the type parameter t.
  fn Obj(self: Ref<TypeParam>) -> Ref<TypeName>

  /// SetConstraint sets the type constraint for t.
  /// 
  /// It must be called by users of NewTypeParam after the bound's underlying is
  /// fully defined, and before using the type parameter in any way other than to
  /// form other types. Once SetConstraint returns the receiver, t is safe for
  /// concurrent use.
  fn SetConstraint(self: Ref<TypeParam>, bound: Type)

  fn String(self: Ref<TypeParam>) -> string

  /// Underlying returns the [underlying type] of the type parameter t, which is
  /// the underlying type of its constraint. This type is always an interface.
  /// 
  /// [underlying type]: https://go.dev/ref/spec#Underlying_types.
  fn Underlying(self: Ref<TypeParam>) -> Type
}

impl TypeParamList {
  /// At returns the i'th type parameter in the list.
  fn At(self: Ref<TypeParamList>, i: int) -> Ref<TypeParam>

  /// Len returns the number of type parameters in the list.
  /// It is safe to call on a nil receiver.
  fn Len(self: Ref<TypeParamList>) -> int

  /// TypeParams returns a go1.23 iterator over a list of type parameters.
  /// 
  /// Example: for tparam := range l.TypeParams() { ... }
  fn TypeParams(self: Ref<TypeParamList>) -> iter.Seq<Ref<TypeParam>>
}

impl Union {
  fn Len(self: Ref<Union>) -> int

  fn String(self: Ref<Union>) -> string

  fn Term(self: Ref<Union>, i: int) -> Ref<Term>

  /// Terms returns a go1.23 iterator over the terms of a union.
  /// 
  /// Example: for term := range union.Terms() { ... }
  fn Terms(self: Ref<Union>) -> iter.Seq<Ref<Term>>

  fn Underlying(self: Ref<Union>) -> Type
}

impl Var {
  /// Anonymous reports whether the variable is an embedded field.
  /// Same as Embedded; only present for backward-compatibility.
  fn Anonymous(self: Ref<Var>) -> bool

  /// Embedded reports whether the variable is an embedded field.
  fn Embedded(self: Ref<Var>) -> bool

  /// Exported reports whether the object is exported (starts with a capital letter).
  /// It doesn't take into account whether the object is in a local (function) scope
  /// or not.
  fn Exported(self: Ref<Var>) -> bool

  /// Id is a wrapper for Id(obj.Pkg(), obj.Name()).
  fn Id(self: Ref<Var>) -> string

  /// IsField reports whether the variable is a struct field.
  fn IsField(self: Ref<Var>) -> bool

  /// Kind reports what kind of variable v is.
  fn Kind(self: Ref<Var>) -> VarKind

  /// Name returns the object's (package-local, unqualified) name.
  fn Name(self: Ref<Var>) -> string

  /// Origin returns the canonical Var for its receiver, i.e. the Var object
  /// recorded in Info.Defs.
  /// 
  /// For synthetic Vars created during instantiation (such as struct fields or
  /// function parameters that depend on type arguments), this will be the
  /// corresponding Var on the generic (uninstantiated) type. For all other Vars
  /// Origin returns the receiver.
  fn Origin(self: Ref<Var>) -> Ref<Var>

  /// Parent returns the scope in which the object is declared.
  /// The result is nil for methods and struct fields.
  fn Parent(self: Ref<Var>) -> Option<Ref<Scope>>

  /// Pkg returns the package to which the object belongs.
  /// The result is nil for labels and objects in the Universe scope.
  fn Pkg(self: Ref<Var>) -> Option<Ref<Package>>

  /// Pos returns the declaration position of the object's identifier.
  fn Pos(self: Ref<Var>) -> token.Pos

  /// SetKind sets the kind of the variable.
  /// It should be used only immediately after [NewVar] or [NewParam].
  fn SetKind(self: Ref<Var>, kind: VarKind)

  fn String(self: Ref<Var>) -> string

  /// Type returns the object's type.
  fn Type(self: Ref<Var>) -> Type
}

impl VarKind {
  fn String(self) -> string
}