Skip to content

Commit

Permalink
Always enlarge resolved constant types
Browse files Browse the repository at this point in the history
  • Loading branch information
muglug committed Oct 9, 2024
1 parent ddd2e14 commit e777b99
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/code_info/ttype/type_expander.rs
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,15 @@ fn expand_atomic(
FxHashSet::default(),
);

if let Some(const_type) = const_type {
if let Some(mut const_type) = const_type {
expand_union(
codebase,
interner,
&mut const_type,
options,
data_flow_graph,
);

new_return_type_parts.extend(const_type.types);
} else {
new_return_type_parts.push(TAtomic::TMixed);
Expand Down
17 changes: 17 additions & 0 deletions tests/inference/Constant/classConstantIndirection/input.hack
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
enum M: int as int {
A = 0;
B = 1;
C = 2;
D = 3;
E = 4;
}

const keyset<M> FOO = Bar::FOO;

final class Bar {
const keyset<M> FOO = keyset[M::A, M::C, M::E];
}

function baz(M $i): void {
if (C\contains(FOO, $i)) {}
}

0 comments on commit e777b99

Please sign in to comment.