Eiffel:功能调用中不兼容的实参

Eiffel: non-compatible actual argument in feature call

我不明白为什么会这样。

为什么我必须指定 {G}???

SIT_HANDLER

class
    SIT_HANDLER[G -> DB_ENTITY create default_create, make_from_db_service, make_from_json end]

feature --

    some_feature
        do
            if attached {G} l_rest_request.calling_entity as l_calling_entity then
                db_service.set_item_prototype (l_calling_entity) -- Complains here!!!!!!!!!!!!
                db_service.load_with_relationships (l_rest_request)
            ...
        end
end -- class

REST_REQUEST

class
    REST_REQUEST

feature -- Access
    calling_entity: detachable RELATED_DB_ENTITY -- RELATED_DB_ENTITY inherits DB_ENTITY
...
end -- class

DB_SERVICE

class
    DB_SERVICE [G -> DB_ENTITY create default_create, make_from_db_service, make_from_json end]

feature -- Status setting

    item_prototype: G

    set_item_prototype (v: like item_prototype)
        do
            item_prototype := v
        ensure
            item_prototype = v
        end

...
end -- class

类型RELATED_DB_ENTITY不符合类型G

这是一个例子。假设有一个 class FOO 继承自 DB_ENTITY 并且具有所有需要的创建过程。 FOORELATED_DB_ENTITY 不相符。对于类型 SIT_HANDLER [FOO],特征 db_service.set_item_prototype 的参数具有类型 FOO 而表达式 l_rest_request.calling_entity 的类型是 RELATED_DB_ENTITY。不允许将类型 RELATED_DB_ENTITY 的表达式分配给类型 FOO.

的实体