Skip to content

Commit

Permalink
Merge branch 'topic/lkql_171' into 'master'
Browse files Browse the repository at this point in the history
Name resolution fixes on the Matreshka codebase.

Closes langkit-query-language#171

See merge request eng/libadalang/libadalang!1635
  • Loading branch information
Roldak committed May 13, 2024
2 parents 345558a + 3a90763 commit dd73eab
Show file tree
Hide file tree
Showing 9 changed files with 77 additions and 7 deletions.
10 changes: 3 additions & 7 deletions ada/ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -4547,12 +4547,8 @@ def safe_generic_decl_part():
# lookups, hence doing an infinite recursion.
Entity.children_env.env_parent.get(
Entity.name_symbol, categories=no_prims
).then(
lambda results:
results.at(1).cast(T.GenericSubpDecl)._or(
results.at(2).cast(T.GenericSubpDecl)
)
),
)._.find(lambda r: r.is_a(T.GenericSubpDecl))
.cast(T.GenericSubpDecl),

No(T.GenericDecl.entity)
)
Expand Down Expand Up @@ -10208,7 +10204,7 @@ def is_referred_by(origin=T.AdaNode):
synthetic object.
"""
return And(
Not(origin.parent.parent.is_a(TypeAccessDef)),
origin.parents.find(lambda p: p.is_a(AccessDef)).is_null,
Self.is_children_env(
Self.type_expr.cast(SyntheticTypeExpr)
.target_type.children_env,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
generic
type T is private;
procedure Pkg.Gen (X : T);
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
procedure Pkg.Gen (X : T) is
pragma Assert (T'Size = 8);
pragma Test_Statement;
begin
null;
end Pkg.Gen;
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
package Pkg is
end Pkg;
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
project Prj is
package Naming is
for Implementation ("Pkg.Gen")
use "pkg-gen__test.adb";
end Naming;
end Prj;
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
Analyzing pkg-gen__test.adb
###########################

Resolving xrefs for node <PragmaNode pkg-gen__test.adb:2:4-2:31>
****************************************************************

Expr: <Id "Assert" pkg-gen__test.adb:2:11-2:17>
references: None
type: None
expected type: None
Expr: <RelationOp pkg-gen__test.adb:2:19-2:29>
type: <ConcreteTypeDecl ["Boolean"] __standard:3:3-3:33>
expected type: <ConcreteTypeDecl ["Boolean"] __standard:3:3-3:33>
Expr: <AttributeRef pkg-gen__test.adb:2:19-2:25>
references: None
type: <ConcreteTypeDecl ["Universal_Int_Type_"] __standard:116:3-116:45>
expected type: <ConcreteTypeDecl ["root_integer"] __standard:120:3-120:38>
Expr: <Id "T" pkg-gen__test.adb:2:19-2:20>
references: <DefiningName "T" pkg-gen.ads:2:9-2:10>
type: None
expected type: None
Expr: <Id "Size" pkg-gen__test.adb:2:21-2:25>
references: None
type: None
expected type: None
Expr: <OpEq "=" pkg-gen__test.adb:2:26-2:27>
references: <SyntheticDefiningName ""="" __standard:120:24-120:37>
type: None
expected type: None
Expr: <Int pkg-gen__test.adb:2:28-2:29>
references: None
type: <ConcreteTypeDecl ["Universal_Int_Type_"] __standard:116:3-116:45>
expected type: <ConcreteTypeDecl ["root_integer"] __standard:120:3-120:38>


Done.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
driver: name-resolution
input_sources: [pkg-gen__test.adb]
7 changes: 7 additions & 0 deletions testsuite/tests/name_resolution/record_self_access/test.adb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ procedure Test is
--% access_type.f_type_def.f_subtype_indication.p_designated_type_decl
--% node.f_default_expr.f_prefix.p_referenced_decl()
end record;

type T_4 is record
X : access procedure
(A : T_4 --% node.p_referenced_decl()
; B : access T_4 --% node.p_referenced_decl()
);
end record;
begin
null;
end Test;
Expand Down
12 changes: 12 additions & 0 deletions testsuite/tests/name_resolution/record_self_access/test.out
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,15 @@ Result: <ConcreteTypeDecl ["T_3"] test.adb:31:4-37:15>

Eval 'node.f_default_expr.f_prefix.p_referenced_decl()'
Result: <SyntheticObjectDecl ["T_3"] test.adb:31:4-37:15>

Working on node <Id "T_4" test.adb:41:14-41:17>
===============================================

Eval 'node.p_referenced_decl()'
Result: <ConcreteTypeDecl ["T_4"] test.adb:39:4-44:15>

Working on node <Id "T_4" test.adb:42:23-42:26>
===============================================

Eval 'node.p_referenced_decl()'
Result: <ConcreteTypeDecl ["T_4"] test.adb:39:4-44:15>

0 comments on commit dd73eab

Please sign in to comment.