【发布时间】:2019-02-01 03:33:47
【问题描述】:
我不明白为什么会这样。
- 如果我说
attached {G}它有效 - 如果我什么都不说,这对我来说是调用实体的预期行为:可拆卸的 RELATED_DB_ENTITY 应该符合(一旦附加)到 G,即 -> DB_ENTITY
- 如果我说 DB_ENTITY 它没有
- 如果我说 RELATED_DB_ENTITY 是否通过
为什么我必须指定{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
【问题讨论】:
标签: polymorphism generic-programming eiffel