Skip to content

Commit

Permalink
Don’t over-expand Hakana type aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
muglug committed Oct 30, 2024
1 parent 3c682e2 commit cd9b465
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/analyzer/expr/call/arguments_analyzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ pub(crate) fn check_arguments_match(
.get_file_source()
.file_path,
),
expand_typenames: false,
..Default::default()
},
&mut analysis_data.data_flow_graph,
Expand Down
9 changes: 9 additions & 0 deletions src/code_info/ttype/comparison/scalar_type_comparator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,15 @@ pub fn is_contained_by(
base_type: None,
}
} else if let Some(typedef_info) = codebase.type_definitions.get(input_name) {
if let TAtomic::TTypeAlias {
name: alias_name, ..
} = &**container_name
{
if alias_name == input_name {
return true;
}
}

typedef_info.actual_type.clone().get_single_owned()
} else {
TAtomic::TNamedObject {
Expand Down
2 changes: 1 addition & 1 deletion src/code_info/ttype/template/standin_type_replacer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1385,7 +1385,7 @@ fn handle_template_param_type_standin<'a>(
.unwrap();

for template_atomic_type in &template_type.types {
atomic_types.push(TAtomic::TClassname {
atomic_types.push(TAtomic::TTypename {
as_type: Box::new(template_atomic_type.clone()),
});
}
Expand Down
6 changes: 6 additions & 0 deletions src/code_info/ttype/type_expander.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ pub struct TypeExpansionOptions<'a> {
pub expand_generic: bool,
pub expand_templates: bool,
pub expand_hakana_types: bool,
pub expand_typenames: bool,
pub expand_all_type_aliases: bool,
}

Expand All @@ -57,6 +58,7 @@ impl Default for TypeExpansionOptions<'_> {
function_is_final: false,
expand_generic: false,
expand_templates: true,
expand_typenames: true,
expand_hakana_types: true,
expand_all_type_aliases: false,
}
Expand Down Expand Up @@ -365,6 +367,10 @@ fn expand_atomic(
as_type,
} = return_type_part
{
if !options.expand_typenames {
return;
}

let type_definition = if let Some(t) = codebase.type_definitions.get(type_name) {
t
} else {
Expand Down

0 comments on commit cd9b465

Please sign in to comment.