A node in MPS always has a concept. It may or may not have a type.
A concept may have at most one superconcept and any number of subconcepts. A types may have many supertypes and subtypes.
These are two distinct, independent relationships: inheritance between concepts and subtyping between types. Let’s examine some further differences between them.
The concept hierarchy must not contain a cycle. The type hierarchy in MPS may be cyclic, as we will see below.
In MPS, types are represented as nodes. Thus, inheritance applies to concepts and subtyping applies to nodes.
Concept A being a subconcept of B does not imply that a type represented by an instance of A is a subtype of a type represented by an instance of B.
Let’s look at a concrete example.
The sequence type
sequence type in
jetbrains.mps.baseLanguage.collections is an instance of
If you examine the supertypes of
sequence<node<>> in Type Explorer, you will see this hierarchy:
You see that
sequence<node<>> has multiple supertypes, one of them being
java.lang.Iterable<node<>> (an instance of
ClassifierType, although this is not shown in the tool), one of whose superclasses is again
forming a cycle.
If you now examine the declaration of
SequenceType concept, you will see this inheritance hierarchy:
The hierarchy does not contain
SequenceType is neither a superclass, nor a subclass of it.
The classifier type
ClassifierType closer. This is the concept used to represent Java class or interface types. Here is its
For example, the type for
java.lang.Object could be represented (in the notation of light
The type for
java.util.List<Object> would be
ClassifierType( classifier: List, parameter: [ClassifierType(classifier: Object)] )
These two types are represented by two instances of the same concept,
List<Object> is a
The type hierarchy is independent from the concept hierarchy and it’s important not to confuse the two.