Skip to content

Commit

Permalink
Avoid crash in covariant calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
muglug committed Sep 30, 2024
1 parent f936946 commit 7509f8c
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/code_info/ttype/template/standin_type_replacer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -526,8 +526,6 @@ fn replace_atomic<'a>(
None
};

let classlike_info = codebase.classlike_infos.get(name).unwrap();

for (offset, type_param) in type_params.iter_mut().enumerate() {
let input_type_param = match &input_type {
Some(input_inner) => match input_inner {
Expand Down Expand Up @@ -562,10 +560,15 @@ fn replace_atomic<'a>(
_ => None,
};

let is_covariant = matches!(
classlike_info.generic_variance.get(&offset),
Some(Variance::Covariant)
);
let is_covariant =
if let Some(classlike_info) = codebase.classlike_infos.get(name) {
matches!(
classlike_info.generic_variance.get(&offset),
Some(Variance::Covariant)
)
} else {
false
};

*type_param = self::replace(
type_param,
Expand Down

0 comments on commit 7509f8c

Please sign in to comment.