follow up from previous commit for generic methods

master
Andrew Kelley 2020-07-14 15:29:07 -07:00
parent 4696cd3e09
commit a7c3cec65f
2 changed files with 6 additions and 1 deletions

View File

@ -20317,7 +20317,7 @@ static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, IrInst* source_instr,
}
IrInstGen *first_arg;
if (!first_arg_known_bare && handle_is_ptr(ira->codegen, first_arg_ptr->value->type->data.pointer.child_type)) {
if (!first_arg_known_bare) {
first_arg = first_arg_ptr;
} else {
first_arg = ir_get_deref(ira, &first_arg_ptr->base, first_arg_ptr, nullptr);

View File

@ -1150,10 +1150,15 @@ test "method call on an enum" {
fn method(self: *E) bool {
return self.* == .two;
}
fn generic_method(self: *E, foo: anytype) bool {
return self.* == .two and foo == bool;
}
};
fn doTheTest() void {
var e = E.two;
expect(e.method());
expect(e.generic_method(bool));
}
};
S.doTheTest();