Search code examples
genericsgeneric-listeiffeleiffel-scoop

non-compatible actual argument in feature call in collection make_from_separate


Don't understand where I'm wrong here...

class
    LINKED_LIST_SEP[G]

inherit
    LINKED_LIST [G]

create
    make,
    make_from_iterable,
    make_from_separate

feature {NONE} -- Initialization

    make_from_separate (other: separate like Current)
        do
            default_create
            across
                other is l_item
            loop
                check
                    attached {G} {SCOOP_UTIL}.any_from_separate (l_item) as l_v
                then
                    extend (l_v)
                end
            end
        end

end -- class

enter image description here


Solution

  • For an unconstrained formal generic parameter, the implicit constraint is detachable separate ANY. But feature any_from_separate expects separate ANY.

    The following solutions are possible:

    1. Add a test that l_item is not void before calling any_from_separate.
    2. Change signature of any_from_separate to accept detachable types. In this case, however, its result would also become detachable.
    3. Add a constraint separate ANY to the formal generic parameter of class LINKED_LIST_SEP.