[
http://issues.apache.org/jira/browse/TUSCANY-562?page=comments#action_12452092
]
Yang ZHONG commented on TUSCANY-562:
------------------------------------
Neither can a type be its own base/parent, nor can an extended/child type be
the base/parent of any its base/parent.
TypeImpl::setBaseType can simply call isBaseTypeOf/isAssignableFrom to check
that.
In addition, isBaseTypeOf/isAssignableFrom might be useful for modeling users.
Maybe the specification(s) can consider that.
How about the following algorithm for isBaseTypeOf/isAssignableFrom?
2-1. A type is its own base (sounds weird, maybe isAssignableFrom is a better
name)
or a type instance can be assigned to the same type variable
2-2. Recursively, return isBaseTypeOf(type.getBaseType()) or
isAssignableFrom(type.getBaseType())
If that's fine, here's the code snippet:
bool TypeImpl::isBaseTypeOf(const Type* type)
{
return type
&& (this == type || isBaseTypeOf(type.getBaseType()));
}
> Robustness of type inheritance
> ------------------------------
>
> Key: TUSCANY-562
> URL: http://issues.apache.org/jira/browse/TUSCANY-562
> Project: Tuscany
> Issue Type: Bug
> Components: C++ SDO
> Affects Versions: Cpp-M1
> Reporter: Ed Slattery
> Priority: Minor
> Fix For: Cpp-current
>
>
> You can define a type as its own parent. The heirarchy from the type upwards
> should be checked and this should be thrown out -
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]