If a type-bound procedure which is private in a module foo is overridden (or attempted to be overridden) by a type in a second module bar, how is this resolved? Is there any specification in the standard? Considering that the following example code, depending on the compiler, either prints FOO (intel fortan 19.1.1) or BAR (gfortran 7.5, maybe a newer version gives different results?), I wonder which is correct.
module foo
type :: foo_t
contains
procedure, private :: foobar
procedure :: exec
end type foo_t
contains
subroutine exec(obj)
class(foo_t) :: obj
call obj%foobar()
end subroutine exec
subroutine foobar(this)
class(foo_t) :: this
print *, "FOO"
end subroutine foobar
end module foo
module bar
use foo
type, extends(foo_t) :: bar_t
contains
procedure :: foobar => impl
end type bar_t
contains
subroutine impl(this)
class(bar_t) :: this
print *, "BAR"
end subroutine impl
end module bar
program test
use foo
use bar
class(foo_t), allocatable :: inst
allocate( bar_t :: inst)
call inst%exec()
end program test
Furthermore, is it possible to extend an abstract type with a private deferred method in a different module, as it would be the case in the example if foobar was deferred (which only compiles with the aforementioned gfortran compiler and then yields the expected result, but the question is if this is also the correct behavior)?