Require type and expected indices in equal_types constraints

This commit is contained in:
Ayaz Hafiz 2022-10-24 14:05:19 -05:00
parent 35a4781045
commit 55d7f3f658
No known key found for this signature in database
GPG key ID: 0E2A37416A25EF58
4 changed files with 189 additions and 104 deletions

View file

@ -211,7 +211,7 @@ impl Constraints {
EitherIndex::from_right(index)
}
pub fn push_expected_type(&mut self, expected: Expected<Type>) -> Index<Expected<Cell<Type>>> {
pub fn push_expected_type(&mut self, expected: Expected<Type>) -> ExpectedTypeIndex {
Index::push_new(&mut self.expectations, expected.map(Cell::new))
}
@ -256,13 +256,11 @@ impl Constraints {
pub fn equal_types(
&mut self,
typ: Type,
expected: Expected<Type>,
type_index: TypeOrVar,
expected_index: ExpectedTypeIndex,
category: Category,
region: Region,
) -> Constraint {
let type_index = self.push_type(typ);
let expected_index = Index::push_new(&mut self.expectations, expected.map(Cell::new));
let category_index = Self::push_category(self, category);
Constraint::Eq(Eq(type_index, expected_index, category_index, region))