Instance coercion in Assignment Statement
A reference path to an assignment receiver may include one or more attributes that define relations to another instances, i.e. the attribute data types are of instance type. For all such attributes that have no value assigned, the assignment statement will create an instance of the attribute domain type and connect it to the actual attribute before the result of the assignment expression is written to the assignment receiver. In case the instance type is an abstract supertype coercion must be used, otherwise the declared type is used when coercion is omitted. In case the actual domain type is of type SELECT or of a supertype, then several instance types can be legal for the implicitly created instance, i.e. any instance type that is in the actual select list or any subtype of the actual supertype is legal. The Coercion construct should then be used to specify the exact type of the instances that will be implicitly created by the assignment statement. Coercion can be specified in any chain in an assignment receiver reference path.
Â
Example:
An instance of entity type PERSON has an attribute ?child?. The entity type of child is CHILD which is supertype of BOY and GIRL. CHILD has an      attribute ?age?. Specify an instance of type BOY to be implicitly created as shown below, when you assign value to age.
Â
aPerson.{BOY}child.age := 10;
Â
That say instead that PERSON has an attribute ?children?, which is a set of CHILD. The way to apply coercion to aggregate elements is shown below.
Â
aPerson.children[1]{GIRL}.age := 11;