Skip to content

Commit

Permalink
Fix type-checking against type placeholders
Browse files Browse the repository at this point in the history
Under certain cases we'd compare a type with a TypePlaceholderId, but
due to the lack of explicit match rules for this type we'd treat the
comparison as incompatible.

Changelog: fixed
  • Loading branch information
yorickpeterse committed Oct 25, 2022
1 parent 2e39849 commit 11ab2c3
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions types/src/lib.rs
Expand Up @@ -4476,13 +4476,35 @@ impl TypeRef {
false
}

fn type_check_with_type_placeholder(
self,
db: &mut Database,
with: TypePlaceholderId,
context: &mut TypeContext,
subtyping: bool,
) -> bool {
if let Some(assigned) = with.value(db) {
self.type_check(db, assigned, context, subtyping)
} else {
with.assign(db, self);
true
}
}

fn type_check_directly(
self,
db: &mut Database,
with: TypeRef,
context: &mut TypeContext,
subtyping: bool,
) -> bool {
// This case is the same for all variants of `self`, so we handle it
// here once.
if let TypeRef::Placeholder(id) = with {
return self
.type_check_with_type_placeholder(db, id, context, subtyping);
}

match self {
TypeRef::Owned(our_id) => match with {
TypeRef::Owned(their_id) | TypeRef::Infer(their_id) => {
Expand Down

0 comments on commit 11ab2c3

Please sign in to comment.