feat: add Record.as_dict()

This commit is contained in:
Shunsuke Shibayama 2023-08-20 02:02:53 +09:00
parent 2966497ad6
commit 5e71bd7fd0
6 changed files with 96 additions and 4 deletions

View file

@ -2424,12 +2424,12 @@ impl Context {
Type::Poly { name, .. } => {
return self.get_poly_type(name);
}
Type::Record(rec) if rec.values().all(|attr| self.supertype_of(&Type, attr)) => {
/*Type::Record(rec) if rec.values().all(|attr| self.supertype_of(&Type, attr)) => {
return self
.get_builtins()
.unwrap_or(self)
.rec_local_get_mono_type("RecordType");
}
}*/
Type::Record(_) => {
return self
.get_builtins()
@ -3149,6 +3149,11 @@ impl Context {
.map(|(name, tp)| (name.clone(), self.meta_type(tp)))
.collect(),
),
Record(rec) => Record(
rec.iter()
.map(|(name, tp)| (name.clone(), self.meta_type(tp)))
.collect(),
),
_ => Type,
}
}