Consider the following skeletal code:
module abstract_m private public:: abs_t type ,abstract :: abs_t contains !other bindings procedure(sub_abs_t_abs_t) ,deferred :: assign generic :: assignment(=) => assign end type abstract interface elemental subroutine assign(lhs,rhs) import :: abs_t class(abs_t) ,intent(inout) :: lhs class(abs_t) ,intent(in) :: rhs end subroutine end interface end module module concrete_m use abstract_m ,only:abs_t implicit none private public :: cncrt_t type ,extends(abs_t) :: cncrt_t private !State/data variables contains procedure :: assign => copy procedure :: some_op end type contains elemental subroutine copy(lhs,rhs) class(cncrt_t) ,intent(inout) :: lhs class(abs_t) ,intent(in) :: rhs select type(rhs) class is(cncrt_t) lhs%.... = rhs%.... etc. : end select type end subroutine elemental function some_op(lhs,rhs) result(res) class(cncrt_t) ,intent(in) :: lhs class(abs_t) ,intent(in) :: rhs class(abs_t) ,allocatable :: res allocate(res,source=lhs) select type(rhs) class is (cncrt_t) !Shouldn't this call the generic assignment bound to Assign in the abstract class, implemented as copy? res = lhs .other_op. rhs : end select type end function end module
When I run the syntax checker on a similar code I get the following error message:
$ ifort -warn -stand f03 -syntax-only -fpp statN.F90 statN.F90(97): error #8304: In an intrinsic assignment statement, variable shall not be polymorphic. [LOCAL_RES] local_res = rhs !I think this will call copy...nope.jpg -------------^
I believe that the generic assignment specified in the abstract type should be inherited by the implementation. Therefore, a polymorphic object of class(abs_t) or one of it's children should try to call assign() when it encounters an assignment statement like local_res = .... Please correct me if my understanding is flawed or I missed some subtlety surrounding polymorphism, inheritance and generic type bound procedures.
I'm super swamped at the moment, and don't really have time to go through the original code and make a simplified reproducer. For the time being I can work around this by calling the copy subroutine directly rather than through the generic type bound assignment. I will try to work up a reproducer soon.