Skip to content

Commit

Permalink
fix: methods are now callable locally
Browse files Browse the repository at this point in the history
  • Loading branch information
mhasel committed Nov 18, 2024
1 parent 712677c commit c376416
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/codegen/generators/expression_generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -862,7 +862,14 @@ impl<'ink, 'b> ExpressionCodeGenerator<'ink, 'b> {
// no function
let (class_ptr, call_ptr) = match pou {
PouIndexEntry::Method { .. } => {
let class_ptr = self.generate_lvalue(operator)?;
let class_ptr = self.generate_lvalue(operator).or_else(|_| {
// this might be a local method
function_context
.function
.get_first_param()
.map(|class_ptr| class_ptr.into_pointer_value())
.ok_or_else(|| Diagnostic::cannot_generate_call_statement(operator))
})?;
let call_ptr =
self.allocate_function_struct_instance(implementation.get_call_name(), operator)?;
(Some(class_ptr), call_ptr)
Expand Down

0 comments on commit c376416

Please sign in to comment.