code gen Accessor

This commit is contained in:
Folkert 2020-10-03 21:08:41 +02:00
parent bb6f36ad28
commit c8e5acf142
6 changed files with 96 additions and 27 deletions

View file

@ -675,6 +675,7 @@ pub fn constrain_expr(
)
}
Accessor {
function_var,
field,
record_var,
closure_var,
@ -701,16 +702,19 @@ pub fn constrain_expr(
region,
);
let function_type = Type::Function(
vec![record_type],
Box::new(Type::Variable(*closure_var)),
Box::new(field_type),
);
exists(
vec![*record_var, *closure_var, field_var, ext_var],
vec![*record_var, *function_var, *closure_var, field_var, ext_var],
And(vec![
Eq(function_type.clone(), expected, category.clone(), region),
Eq(
Type::Function(
vec![record_type],
Box::new(Type::Variable(*closure_var)),
Box::new(field_type),
),
expected,
function_type,
NoExpectation(Variable(*function_var)),
category,
region,
),