| ... | @@ -723,3 +723,19 @@ pub fn refAllDecls(comptime T: type) void { | ... | @@ -723,3 +723,19 @@ pub fn refAllDecls(comptime T: type) void { |
| 723 | if (decl.is_pub) _ = @field(T, decl.name); | 723 | if (decl.is_pub) _ = @field(T, decl.name); |
| 724 | } | 724 | } |
| 725 | } | 725 | } |
| | 726 | |
| | 727 | /// Given a type, and Recursively reference all the declarations inside, so that the semantic analyzer sees them. |
| | 728 | /// For deep types, you may use `@setEvalBranchQuota` |
| | 729 | pub fn refAllDeclsRecursive(comptime T: type) void { |
| | 730 | inline for (comptime std.meta.declarations(T)) |decl| { |
| | 731 | if (decl.is_pub) { |
| | 732 | if (@TypeOf(@field(T, decl.name)) == type) { |
| | 733 | switch (@typeInfo(@field(T, decl.name))) { |
| | 734 | .Struct, .Enum, .Union, .Opaque => refAllDeclsRecursive(@field(T, decl.name)), |
| | 735 | else => {}, |
| | 736 | } |
| | 737 | } |
| | 738 | _ = @field(T, decl.name); |
| | 739 | } |
| | 740 | } |
| | 741 | } |