Skip to content

Commit

Permalink
WIP: fix #666
Browse files Browse the repository at this point in the history
  • Loading branch information
yorickpeterse committed Dec 13, 2023
1 parent 47e4c0b commit 54759ed
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
1 change: 0 additions & 1 deletion compiler/src/mir/specialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -976,7 +976,6 @@ impl<'a, 'b> Specialize<'a, 'b> {
// We can reach this point if our parameter is assigned to a
// type parameter bound, and the shape for that is already
// generated by the above loop.
// shapes.insert(par, *shape);
continue;
}
}
Expand Down
12 changes: 8 additions & 4 deletions compiler/src/type_check/expressions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,17 +341,21 @@ impl MethodCall {
&& !method.is_moving(&state.db);

let bounds = if let Some((self_id, self_method)) = surrounding_scope {
// When calling a method on `self`, we need to take any surrounding
// bounds into account when resolving types.
if self_id == receiver_id {
self_method.bounds(&state.db).union(method.bounds(&state.db))
} else {
self_method.bounds(&state.db).clone()
method.bounds(&state.db).clone()
}
} else {
TypeBounds::new()
method.bounds(&state.db).clone()
};

// TODO: remove
if method.name(&state.db) == "my_eq" {
println!("method: {}", method.0);
println!("type bounds: {:?}\n", bounds);
}

// If the receiver is rigid, it may introduce additional type arguments
// through its type parameter requirements. We need to ensure that these
// are all returned as rigid parameters as well. In addition, we need to
Expand Down
10 changes: 9 additions & 1 deletion types/src/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,13 @@ impl<'a> TypeChecker<'a> {
};

if allow {
// TODO: remove
if left_id.id == 642 {
println!("value: {:?}", right);
println!("left: {:?}", env.left);
println!("right: {:?}", env.right);
}

left_id.assign(self.db, right);
}

Expand Down Expand Up @@ -1115,7 +1122,8 @@ impl<'a> TypeChecker<'a> {
arguments: &TypeArguments,
rules: Rules,
) -> TypeRef {
match arguments.get(id) {
// TODO: add tests for using a bound here
match arguments.get(id.original(self.db).unwrap_or(id)) {
Some(arg @ TypeRef::Placeholder(id)) => id
.value(self.db)
.map(|v| self.resolve(v, arguments, rules))
Expand Down

0 comments on commit 54759ed

Please sign in to comment.