0

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

Pipo
  • 4,653
  • 38
  • 47

1 Answers1

1

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.
Alexander Kogtenkov
  • 5,770
  • 1
  • 27
  • 35
  • Nice, I was missing the detachable, I remembered the separate part. The most extendible I see is testing for attached before adding it. Thx. Could be nice to add that as a hint on compilation with type of Generic #1 it will be more explicit for those who don't learned well their theory ;) – Pipo Jun 12 '20 at 20:00