diff --git a/ada/ast.py b/ada/ast.py index b7adadb2a..acec62067 100644 --- a/ada/ast.py +++ b/ada/ast.py @@ -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) ), diff --git a/testsuite/tests/name_resolution/matching_assign_type/test.adb b/testsuite/tests/name_resolution/matching_assign_type/test.adb new file mode 100644 index 000000000..1707d97b2 --- /dev/null +++ b/testsuite/tests/name_resolution/matching_assign_type/test.adb @@ -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; diff --git a/testsuite/tests/name_resolution/matching_assign_type/test.out b/testsuite/tests/name_resolution/matching_assign_type/test.out new file mode 100644 index 000000000..0b699603c --- /dev/null +++ b/testsuite/tests/name_resolution/matching_assign_type/test.out @@ -0,0 +1,17 @@ +Analyzing test.adb +################## + +Resolving xrefs for node +********************************************************* + +Expr: + references: + type: + expected type: None +Expr: + references: + type: + expected type: + + +Done. diff --git a/testsuite/tests/name_resolution/matching_assign_type/test.yaml b/testsuite/tests/name_resolution/matching_assign_type/test.yaml new file mode 100644 index 000000000..173e325ff --- /dev/null +++ b/testsuite/tests/name_resolution/matching_assign_type/test.yaml @@ -0,0 +1,2 @@ +driver: name-resolution +input_sources: [test.adb]