The more I use F08 object orientation, the more confused I get... I was pretty sure I had tested this previously with Intel compiler and it worked (about 4 years ago) but now it refuses to!
Imagine a simple linked list implementation:
TYPE :: List_T CLASS(List_T), POINTER :: next => null() CLASS(List_T), POINTER :: prev => null() CONTAINS PROCEDURE, PUBLIC :: insert => ListInsert PROCEDURE, PUBLIC :: first => ListFirst PROCEDURE, PUBLIC :: last => ListLast PROCEDURE, PUBLIC :: found => ListFound PROCEDURE, PUBLIC :: append => ListAppend PROCEDURE, PUBLIC :: print => ListPrint FINAL :: ListFree END TYPE List_T SUBROUTINE ListAppend(this,new) CLASS(List_T), INTENT(INOUT), TARGET :: this CLASS(List_T), INTENT(IN), POINTER :: new ! do stuff here END SUBROUTINE ListAppend
Then I create a type ExtList_T which extends List_T. I don't want to redefine the "append" function because it is exactly the same, I just want to inherit it. But then if I try something like
TYPE(ExtList_T), POINTER :: instance1 TYPE(ExtList_T), POINTER :: instance2 ALLOCATE(instance1) ALLOCATE(instance2) ! put stuff inside each CALL instance1%append(instance2)
Intel Compiler complains "error #6633: The type of the actual argument differs from the type of the dummy argument. [INSTANCE2]"
gfortran compiles that fine. Am I doing something conceptually wrong? Isn't downcasting like that allowed in Fortran?