I believe that the type-bound-procedure wins. A slightly longer example tests this:
module m
type :: t
contains
procedure :: assign_class_t
generic :: assignment(=) => assign_class_t
end type
interface assignment(=)
module procedure assign_t
end interface
contains
subroutine assign_t( this, rhs )
type(t), intent(out), allocatable :: this
type(t), intent(in) :: rhs
print *, "called assign_t"
end subroutine
subroutine assign_class_t( this, rhs )
class(t), intent(inout) :: this
type(t), intent(in) :: rhs
print *, "called assign_class_t"
end subroutine
end module m
program test
use m
type(t),allocatable :: lhs
type(t) :: rhs
rhs = t( )
lhs = rhs
end program test
I tried this with three compilers and got (in all cases):
> ./a.out
called assign_class_t
called assign_class_t
> On Mar 22, 2018, at 1:10 PM, Vipul Parekh <[log in to unmask]> wrote:
>
> Does the following code conform to the standard considering the
> assignment interface as well as a type-bound generic?
>
> module m
> type :: t
> contains
> procedure :: assign_class_t
> generic :: assignment(=) => assign_class_t
> end type
> interface assignment(=)
> module procedure assign_t
> end interface
> contains
> subroutine assign_t( this, rhs )
> type(t), intent(out), allocatable :: this
> type(t), intent(in) :: rhs
> end subroutine
> subroutine assign_class_t( this, rhs )
> class(t), intent(inout) :: this
> type(t), intent(in) :: rhs
> end subroutine
> end module m
>
> Two processors I tried compiled the code with no errors.
>
> Thanks,
> Vipul Parekh
Bill Long [log in to unmask]
Principal Engineer, Fortran Technical Support & voice: 651-605-9024
Bioinformatics Software Development fax: 651-605-9143
Cray Inc./ 2131 Lindau Lane/ Suite 1000/ Bloomington, MN 55425
|