feat: support recursive class definition

This commit is contained in:
Shunsuke Shibayama 2023-08-25 21:02:47 +09:00
parent 418f31e6ed
commit f3b188e095
13 changed files with 285 additions and 93 deletions

View file

@ -65,12 +65,12 @@ pub(crate) fn class_func(mut args: ValueArgs, ctx: &Context) -> EvalValueResult<
match base {
Some(value) => {
if let Some(base) = value.as_type(ctx) {
Ok(ValueObj::gen_t(GenTypeObj::class(t, Some(base), impls)).into())
Ok(ValueObj::gen_t(GenTypeObj::class(t, Some(base), impls, true)).into())
} else {
Err(type_mismatch("type", value, "Base"))
}
}
None => Ok(ValueObj::gen_t(GenTypeObj::class(t, None, impls)).into()),
None => Ok(ValueObj::gen_t(GenTypeObj::class(t, None, impls, true)).into()),
}
}
@ -133,7 +133,7 @@ pub(crate) fn trait_func(mut args: ValueArgs, ctx: &Context) -> EvalValueResult<
let impls = args.remove_left_or_key("Impl");
let impls = impls.map(|v| v.as_type(ctx).unwrap());
let t = mono(ctx.name.clone());
Ok(ValueObj::gen_t(GenTypeObj::trait_(t, req, impls)).into())
Ok(ValueObj::gen_t(GenTypeObj::trait_(t, req, impls, true)).into())
}
/// Base: Type, Impl := Type -> Patch