Skip to content

Commit

Permalink
Merge branch 'topic/967' into 'master'
Browse files Browse the repository at this point in the history
Also consider accessed type when checking for classwide type

Closes #967

See merge request eng/libadalang/libadalang!1439
  • Loading branch information
thvnx committed Nov 21, 2023
2 parents ccc406b + 4d921bb commit 8c452c0
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 1 deletion.
3 changes: 2 additions & 1 deletion ada/ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -7104,7 +7104,8 @@ def matching_assign_type(expected_type=T.BaseTypeDecl.entity):
Entity.matching_type(expected_type),

And(
expected_type.is_classwide,
expected_type.is_classwide
| expected_type.accessed_type._.is_classwide,
actual_type.matching_formal_prim_type(expected_type)
),

Expand Down
20 changes: 20 additions & 0 deletions testsuite/tests/name_resolution/matching_assign_type/test.adb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
procedure Test is

type MDI is tagged null record;
type MDI_Child is access all MDI'Class;

type Local_T is new MDI with null record;

function Set return access Local_T'Class;

function Set return access Local_T'Class is
begin
return null;
end Set;

Child : MDI_Child;

begin
Child := Set;
pragma Test_Statement;
end Test;
17 changes: 17 additions & 0 deletions testsuite/tests/name_resolution/matching_assign_type/test.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Analyzing test.adb
##################

Resolving xrefs for node <AssignStmt test.adb:18:5-18:18>
*********************************************************

Expr: <Id "Child" test.adb:18:5-18:10>
references: <DefiningName "Child" test.adb:15:4-15:9>
type: <ConcreteTypeDecl ["MDI_Child"] test.adb:4:4-4:43>
expected type: None
Expr: <Id "Set" test.adb:18:14-18:17>
references: <DefiningName "Set" test.adb:10:13-10:16>
type: <AnonymousTypeDecl ["None"] test.adb:10:24-10:44>
expected type: <ConcreteTypeDecl ["MDI_Child"] test.adb:4:4-4:43>


Done.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
driver: name-resolution
input_sources: [test.adb]

0 comments on commit 8c452c0

Please sign in to comment.