[英]Eiffel: non-compatible actual argument in feature call
我不明白為什么會這樣。
attached {G}
可以 為什么必須指定{G}
?
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
class
REST_REQUEST
feature -- Access
calling_entity: detachable RELATED_DB_ENTITY -- RELATED_DB_ENTITY inherits DB_ENTITY
...
end -- class
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
這是一個為什么的例子。 假設有一個FOO
類,它繼承於DB_ENTITY
並且具有所有必需的創建過程。 FOO
和RELATED_DB_ENTITY
不一致。 對於類型SIT_HANDLER [FOO]
,功能部件db_service.set_item_prototype
的參數類型為FOO
而表達式l_rest_request.calling_entity
的類型為RELATED_DB_ENTITY
。 不允許將類型RELATED_DB_ENTITY
的表達式分配給類型FOO
的實體。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.