Pipo
Pipo

Reputation: 5093

The class inherits two different generic derivations of the same class

What is the proper way of precising the type of an iterable through inheritence.

as inherit FOO[like babar] is not alowed

FOO

class FOO

inherit
    ITERABLE[detachable ANY] -- I know garbage but for DB_RESULT its the case


feature -- Access

    new_cursor: ITERATION_CURSOR[like items.item]
        do
            Result := items.new_cursor
        end

    items: ARRAY[detachable ANY]


end -- class FOO

BAR

class BAR

inherit
    FOO -- I know garbage but for DB_RESULT its the case

    ITERABLE[STRING] -- I know garbage but for DB_RESULT its the case


feature -- Access

    new_cursor: ITERATION_CURSOR[like items.item]
        do
            Result := items.new_cursor
        end

    items: ARRAY[STRING]


end -- class FOO

enter image description here

Upvotes: 0

Views: 20

Answers (1)

Alexander Kogtenkov
Alexander Kogtenkov

Reputation: 5810

I would suggest using a formal generic parameter in class FOO:

class FOO [G]
inherit
    ITERABLE [G]

Then, class BAR would provide a suitable actual generic parameter:

class BAR
inherit
    FOO [STRING]

Upvotes: 1

Related Questions