summaryrefslogtreecommitdiff
path: root/src/ir/function.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/ir/function.rs')
-rw-r--r--src/ir/function.rs17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/ir/function.rs b/src/ir/function.rs
index 602de80c..5e8d2fc8 100644
--- a/src/ir/function.rs
+++ b/src/ir/function.rs
@@ -402,14 +402,27 @@ impl FunctionSig {
let is_virtual = is_method && cursor.method_is_virtual();
let is_static = is_method && cursor.method_is_static();
if !is_static && !is_virtual {
- let class = Item::parse(cursor.semantic_parent(), None, ctx)
+ let parent = cursor.semantic_parent();
+ let class = Item::parse(parent, None, ctx)
.expect("Expected to parse the class");
// The `class` most likely is not finished parsing yet, so use
// the unchecked variant.
let class = class.as_type_id_unchecked();
+ let class = if is_const {
+ let const_class_id = ctx.next_item_id();
+ ctx.build_const_wrapper(
+ const_class_id,
+ class,
+ None,
+ &parent.cur_type(),
+ )
+ } else {
+ class
+ };
+
let ptr =
- Item::builtin_type(TypeKind::Pointer(class), is_const, ctx);
+ Item::builtin_type(TypeKind::Pointer(class), false, ctx);
args.insert(0, (Some("this".into()), ptr));
} else if is_virtual {
let void = Item::builtin_type(TypeKind::Void, false, ctx);