Pipo
Pipo

Reputation: 5093

non-compatible actual argument in feature call with generic separate arguments. A way to use anchored type?

As far as I understand,

so, that's the reason the compiler complains when I say like Current, when the P and S I specified into the RELATIONSHIP class are non separate

Is there a way to anchor the relationship: RELATIONSHIP[unseparate like Current, RABBIT] or do I have to specify it with relationship: RELATIONSHIP[PERSON, RABBIT]?

If no any reason for that escaping my understanding?

see the example above

RELATIONSHIP

class
    RELATIONSHIP[P -> ANIMAL create default_create, make_from_separate end, S -> ANIMAL create default_create, make_from_separate end]

create
    make,
    make_from_separate

feature {NONE} -- Initialize

    make (v: like primary)
        do
            primary := v
            create secondary
        end

    make_from_separate (other: separate like Current)
        do
            create primary.make_from_separate (other.primary)
            create secondary.make_from_separate (other.secondary)
        end

feature -- Access

    primary: P
    secondary: S

end

PERSON

class PERSON

inherit
    ANIMAL
        redefine
            default_create
        end

create
    default_create,
    make_from_separate

feature -- Init

    default_create
        do
            create relationship.make (Current)
        end

    make_from_separate (other: separate like Current)
        do
            create relationship.make_from_separate (other.relationship)
        end

feature -- access

    -- relationship: RELATIONSHIP[like Current, RABBIT] -- not compiling
    relationship: RELATIONSHIP[PERSON, RABBIT] -- compiling

end

Upvotes: 0

Views: 27

Answers (0)

Related Questions