I don't understand why it is so.
attached {G}
it worksWhy do I have to specify {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
The type RELATED_DB_ENTITY
does not conform to the type G
.
Here is an example why. Suppose there is a class FOO
that inherits from DB_ENTITY
and has all required creation procedures. FOO
and RELATED_DB_ENTITY
do not conform to each other. For the type SIT_HANDLER [FOO]
, the argument of the feature db_service.set_item_prototype
has type FOO
whereas the type of the expression l_rest_request.calling_entity
is RELATED_DB_ENTITY
. It is not allowed to assign an expression of type RELATED_DB_ENTITY
to the entity of type FOO
.