So I have an abstract type with some stuff in it, and a procedure to set that stuff
module firstTypeMod type, abstract:: firstType character(len=30):: tempChar contains procedure(defProc), deferred:: deferredProcedure procedure:: setChar end type abstract interface subroutine defProc(self) import firstType class(firstType), intent(inout):: self end subroutine defProc end interface contains subroutine setChar(self, charIn) class(firstType), intent(inout):: self character(len=*):: charIn self%tempChar = charIn end subroutine setChar end module firstTypeMod
I now want to define another type which extends this
module secondTypeMod use firstTypeMod type, extends(firstType):: secondType character(len=100):: tempChar2 contains procedure:: deferredProcedure => secondDef procedure:: setChar => overRideSetChar end type contains subroutine secondDef(self) class(secondType), intent(inout):: self write(*,*) "OVERRIDDEN" end subroutine secondDef subroutine overRideSetChar(self, charIn) class(secondType), intent(inout):: self character(len=*), intent(in):: charIn call self%firstType%setChar(charIn) self%tempChar2 = charIn end subroutine overRideSetChar end module secondTypeMod
However, when I try this I get the following error:
error #8314: If the rightmost part-name is of abstract type, data-ref shall be polymorphic.
Is it possible to do what I want directly? I know that I can make an intermediate class that isn't abstract that will allow me to do this, but I would really prefer to avoid that. Is it possible to call the parent of an overridden non-deferred subroutine of an abstract type?
Thank you.
Edit: A slightly modified version (to remove some typos) is attached to this post which illustrates the error.
Thread Topic:
Question