Subtyping: do we need to return a single node or a list of nodes from the rule? Follow
Hi,
I'm experimenting with the MPS type system and I'm a bit confused by subtyping rules at the moment. As far as I could see in the baseLanguage.mpr , the subtyping rule
subtyping rule int_extends_long {
weak = false
applicable for concept = IntegerType as intType
rule {
return < long > ;
}
}
resulted in the following generated code:
public class int_extends_long_SubtypingRule extends SubtypingRule_Runtime implements ISubtypingRule_Runtime {
...
public SNode getSubOrSuperType(SNode intType) {
return new _Quotations.QuotationClass_49().createNode();
}
Thus, it seems to be possible to return a single node containing type information from the rule body. On the other side, when I've tried to build a similar construct (as a sample) in my own test project:
subtyping rule integerExtendsNumeric {
weak = false
applicable for concept = TypeInteger as typeInteger
rule {
return < numeric > ;
}
}
I've got the following code:
public class integerExtendsNumeric_SubtypingRule extends SubtypingRule_Runtime implements ISubtypingRule_Runtime {
...
public List<SNode> getSubOrSuperTypes(SNode typeInteger) {
return new _Quotations.QuotationClass_6().createNode();
}
which, obviouly, failed to compile.
Of course, it is not a problem to build a list of nodes with a single element and return it from the rule as a workaround, but I'm not sure why generated code was different.
Could you shed a light on this, please?
Please sign in to leave a comment.
Could you send me your project. I will try to find out what's wrong. My email is Konstantin.Solomatov@jetbrains.com