diff --git a/ada/ast.py b/ada/ast.py index c1b26f0fd..fc93b348d 100644 --- a/ada/ast.py +++ b/ada/ast.py @@ -16657,7 +16657,11 @@ def xref_equation(): # as they must all refer to existing declarations. Entity.exprs_assoc_equation, - agg.in_aspect('Contract_Cases'), + # In the case of Contract_Cases aspect, only the top level + # aggregate should be resolved by the special equation here. All + # other agreggates included in the latter should use the regular + # resolution path. + agg.parent.cast(AspectAssoc)._.id.name_is('Contract_Cases'), Entity.contract_cases_assoc_equation, agg.is_a(T.BracketAggregate) & td._.has_aspect('Aggregate'), diff --git a/testsuite/tests/name_resolution/contract_cases/test.adb b/testsuite/tests/name_resolution/contract_cases/test.adb index 158414d9d..93d562ae5 100644 --- a/testsuite/tests/name_resolution/contract_cases/test.adb +++ b/testsuite/tests/name_resolution/contract_cases/test.adb @@ -19,6 +19,12 @@ procedure Test is I > 5 => True, others => False); pragma Test_Block; + + function To_String (S : String) return String is (S); + procedure Qux (S : String) + with Contract_Cases => + [True => To_String (S) = [1 .. 10 => 'C']]; + pragma Test_Block; begin null; end Test; diff --git a/testsuite/tests/name_resolution/contract_cases/test.out b/testsuite/tests/name_resolution/contract_cases/test.out index 6ab46613e..aff323cd5 100644 --- a/testsuite/tests/name_resolution/contract_cases/test.out +++ b/testsuite/tests/name_resolution/contract_cases/test.out @@ -191,5 +191,73 @@ Expr: type: expected type: +Resolving xrefs for node +******************************************************* + + +Resolving xrefs for node +*************************************************************** + +Expr: + references: + type: None + expected type: None + +Resolving xrefs for node +*********************************************************** + +Expr: + references: None + type: None + expected type: None +Expr: + type: None + expected type: None +Expr: + references: + type: + expected type: +Expr: + type: + expected type: +Expr: + references: + type: + expected type: +Expr: + references: + type: + expected type: None +Expr: + references: + type: + expected type: +Expr: + expected type: +Expr: + type: + expected type: +Expr: + references: None + type: + expected type: +Expr: + references: None + type: None + expected type: None +Expr: + references: None + type: + expected type: +Expr: + references: + type: + expected type: + Done.