From 69edaa2354d0f89eaec2030b7d91dd7a0dc0bbfe Mon Sep 17 00:00:00 2001 From: Romain Beguet Date: Thu, 16 Nov 2023 00:07:15 +0100 Subject: [PATCH] Try to resolve concatenations using built-in operators first. --- ada/ast.py | 20 +++++++++++-------- .../concat_op_overloading/test.out | 4 ++-- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/ada/ast.py b/ada/ast.py index ab3a51ffc..86856eb8f 100644 --- a/ada/ast.py +++ b/ada/ast.py @@ -13621,9 +13621,19 @@ def xref_equation(): ), concat_operand=Entity.other_operands.at(pos), right=Entity.other_operands.at(pos).operand: Or( + # TODO: this is implementation is actually not correct + # w.r.t. visibility (eng/libadalang/libadalang#1138). - # Find the subprogram corresponding to: - # "&" (left, right). + # First, try to resolve this operator using built-in + # operators only. + Entity.operator_no_subprogram_equation( + left, concat_operand, right + ), + + # If that didn't work, try to resolve it by considering + # visible user-defined overloads of "&". NOTE: for + # performance reasons it is better to first try the + # built-in operators first. concat_subprograms.logic_any( lambda subp: Let( lambda spec=subp.subp_spec_or_null: @@ -13637,12 +13647,6 @@ def xref_equation(): spec) ) ) - ), - # When no subprogram is found for this concat operator, - # use this equation to infer it's type depending on the - # context. - Entity.operator_no_subprogram_equation( - left, concat_operand, right ) ) ) diff --git a/testsuite/tests/name_resolution/concat_op_overloading/test.out b/testsuite/tests/name_resolution/concat_op_overloading/test.out index 96f557ed6..66ba8293a 100644 --- a/testsuite/tests/name_resolution/concat_op_overloading/test.out +++ b/testsuite/tests/name_resolution/concat_op_overloading/test.out @@ -43,7 +43,7 @@ Expr: type: expected type: Expr: - references: + references: None type: None expected type: None Expr: @@ -97,7 +97,7 @@ Expr: type: expected type: Expr: - references: + references: None type: None expected type: None Expr: