Question about class and abstract interface

Dominique Dhumieres dominiq@lps.ens.fr
Mon Nov 1 14:26:00 GMT 2010


Extracted from http://fortranwiki.org/fortran/show/Design+Patterns
the following code is rejected by gfortran (trunk)

[macbook] f90/bug% cat > pattern_1_db.f90
module decorator_pattern
implicit none

!! Abstract Base Type with a procedure 'do_it' which MUST be implemented by
!! derived types
type, abstract :: I
    contains
        procedure(do_it_interface), deferred :: do_it
end type I

abstract interface
    subroutine do_it_interface(self)
        class(I) :: self
    end subroutine do_it_interface
end interface

end module decorator_pattern
[macbook] f90/bug% gfc -c pattern_1_db.f90
pattern_1_db.f90:13.24:

        class(I) :: self
                        1
Error: the type of 'self' at (1) has not been declared within the interface
pattern_1_db.f90:8.34:

        procedure(do_it_interface), deferred :: do_it
                                  1
Error: Non-polymorphic passed-object dummy argument of 'do_it_interface' at (1)

Is the error right? If yes, why? If no, is there a PR already opened?

TIA

Dominique



More information about the Fortran mailing list