With extended types in Fortran, there must be a private component visible to the type extension in another module.
When using gcc4.7 and ifort, the following code results in an error, since bName has both an initial type and an extension. But since it is private, it is not available in the extension in another module, that is, if you comment out bName in bar_type, you will get an error message that it is private.
module foo type :: foo_type character(256),private :: bName = "foo" contains procedure :: pName => pName end type contains subroutine pName(this) class(foo_type), intent(in) :: this print*,trim(this%bName) end subroutine end module module bar use foo, only : foo_type type,extends(foo_type) :: bar_type character(256),private :: bName = "bar" contains procedure :: pName => pName end type contains subroutine pName(this) class(bar_type), intent(in) :: this print*,this%bName end subroutine end module program test use foo, only : foo_type use bar, only : bar_type type(foo_type) :: foo_inst type(bar_type) :: bar_inst call foo_inst%pName() call bar_inst%pName() end program
If bar_type was contained in the same module as foo_type, then bName will be accessible from bar_type, i.e. the following code will compile
module foo type :: foo_type character(256),private :: bName = "foo" contains procedure :: pName => pName end type type, extends(foo_type) :: baz_type contains procedure :: pName => pName_baz end type contains subroutine pName_baz(this) class(baz_type), intent(in) :: this print*,trim(this%bName) end subroutine subroutine pName(this) class(foo_type), intent(in) :: this print*,trim(this%bName) end subroutine end module program test use foo, only : foo_type,baz_type type(foo_type) :: foo_inst type(baz_type) :: baz_inst call foo_inst%pName() call baz_inst%pName() end program
It is not easy to disassemble standards to know what should happen in the first example.