From a33330163579ff04ccad1a9e9b7f5d3609ea3954 Mon Sep 17 00:00:00 2001 From: Matt Brown Date: Thu, 17 Oct 2024 16:56:39 -0400 Subject: [PATCH] Fix population of interface signatures --- src/orchestrator/populator.rs | 38 +------------------ .../refineInterfaceThenCall/input.hack | 15 ++++++++ 2 files changed, 17 insertions(+), 36 deletions(-) create mode 100644 tests/inference/Interface/refineInterfaceThenCall/input.hack diff --git a/src/orchestrator/populator.rs b/src/orchestrator/populator.rs index 863fbc54..adf08882 100644 --- a/src/orchestrator/populator.rs +++ b/src/orchestrator/populator.rs @@ -741,42 +741,8 @@ fn inherit_methods_from_parent( } } - if let Some(existing_declaring_class) = storage.declaring_method_ids.get(method_name) { - if existing_declaring_class != declaring_class { - let existing_declaring_class_storage = if existing_declaring_class == &storage.name - { - &storage - } else if let Some(storage) = codebase.classlike_infos.get(existing_declaring_class) - { - storage - } else { - continue; - }; - - if !matches!(existing_declaring_class_storage.kind, SymbolKind::Interface) { - if let Some(functionlike_storage) = codebase - .functionlike_infos - .get(&(existing_declaring_class_storage.name, *method_name)) - { - if let Some(method_info) = &functionlike_storage.method_info { - if !method_info.is_abstract { - continue; - } - - if let Some(functionlike_storage) = codebase - .functionlike_infos - .get(&(storage.name, *method_name)) - { - if let Some(method_info) = &functionlike_storage.method_info { - if method_info.is_abstract { - continue; - } - } - } - } - } - } - } + if let Some(_) = storage.declaring_method_ids.get(method_name) { + continue; } storage diff --git a/tests/inference/Interface/refineInterfaceThenCall/input.hack b/tests/inference/Interface/refineInterfaceThenCall/input.hack new file mode 100644 index 00000000..fb0ad2a0 --- /dev/null +++ b/tests/inference/Interface/refineInterfaceThenCall/input.hack @@ -0,0 +1,15 @@ +interface I { + public function foo(): arraykey; +} + +interface IChild extends I { + public function foo(): string; +} + +function bar(I $i): string { + if ($i is IChild) { + return $i->foo(); + } else { + return ''; + } +} \ No newline at end of file