Correctly treat distinct inline types as having their inner type's methods available.

This commit is contained in:
Christoffer Lerno
2023-07-07 13:48:20 +02:00
parent 7dc1eab185
commit 8780df8467
3 changed files with 41 additions and 1 deletions

View File

@@ -3968,6 +3968,14 @@ CHECK_DEEPER:
goto CHECK_DEEPER;
}
if (type->type_kind == TYPE_DISTINCT && decl->is_substruct)
{
Expr *inner_expr = expr_copy(current_parent);
type = type->decl->distinct_decl.base_type;
inner_expr->type = type;
current_parent = inner_expr;
goto CHECK_DEEPER;
}
// 11b. Otherwise we give up.
if (private)
{

View File

@@ -1 +1 @@
#define COMPILER_VERSION "0.4.556"
#define COMPILER_VERSION "0.4.557"

View File

@@ -0,0 +1,32 @@
module testing;
import std::io;
import foo;
fn void main()
{
FooInt foo;
}
def FooInt = distinct inline Foo;
struct Bar
{
FooInt list;
}
fn void Bar.set(&self, int x)
{
self.list.set(x);
}
module foo;
struct Foo
{
int x;
}
fn void Foo.set(&self, int x)
{
self.x = x;
}