// Dot-call dispatch for generic struct methods.
//
// Covers three shapes:
//   1. non-generic method:                h.plain()
//   2. generic method, explicit type arg: h.sized(s32)
//   3. generic method, inferred from val: h.taking(99)

#import "modules/std.sx";

Holder :: struct {
    n: s64;

    plain :: (self: *Holder) -> s64 { self.n; }
    sized :: (self: *Holder, $T: Type) -> s64 { size_of(T); }
    taking :: (self: *Holder, $T: Type, v: T) -> T { v; }
}

main :: () -> s32 {
    h : *Holder = xx malloc(size_of(Holder));
    h.n = 7;

    print("plain: {}\n", h.plain());
    print("sized s32: {}\n", h.sized(s32));
    print("sized s64: {}\n", h.sized(s64));
    print("taking explicit: {}\n", h.taking(s32, 42));
    print("taking inferred: {}\n", h.taking(99));
    0;
}
