ALF 1.0 FTF Avatar
  1. OMG Issue

ALF_ — Constructors and Diamond Inheritance

  • Key: ALF_-13
  • Legacy Issue Number: 16423
  • Status: closed  
  • Source: Model Driven Solutions ( Mr. Ed Seidewitz)
  • Summary:

    Subclause: 10.5.3.1 Constructors

    At the end of Subclause 10.5.3.1 it states that: “In the absence of explicit constructor invocations at the start of a constructor body (and also in the case of the default constructor behavior), a super constructor invocation is made implicitly for each immediate superclass, in the order the superclasses appear in the specializes list of the class containing the constructor, before executing any statements in the constructor body.” However, if the immediate superclasses themselves have common ancestors (so called “diamond inheritance”), applying this rule recursively will result in the constructors of these common ancestors being called multiple times.

  • Reported: ALF 1.0b2 — Fri, 29 Jul 2011 04:00 GMT
  • Disposition: Resolved — ALF 1.0
  • Disposition Summary:

    Agreed. Handling diamond inheritance can be tricky. The approach proposed here leaves the current constructor semantics largely in place, and simply adds that, after a constructor from a certain class is called on an object, other calls on constructors from the same class have no effect. This could be implemented adding class-specific initialization flags to the implementation of the object or by “linearizing” the sequence of direct and indirect super constructor calls and removing any redundant calls.

  • Updated: Fri, 6 Mar 2015 21:48 GMT