Methods from super types are not inherited correctly
When a type inherits methods from multiple super types (either classes or interfaces), bcc gets confused in certain situations, leading to either false compile errors or incorrect behaviour (and subsequent crashes).
Example:
The following code results in Compile Error: Identifier 'b' not found., even though it should compile without issues and print "B":
SuperStrict
Framework BRL.StandardIO
Interface I
Method A()
Method B()
End Interface
Type T1 Implements I Abstract
Method D() End Method
End Type
Type T2 Extends T1 Abstract
Method C()
B
End Method
End Type
Type T3 Extends T2 Final
Method A() Override
Print "A"
End Method
Method B() Override
Print "B"
End Method
End Type
New T3.C
If the Implements clause is moved from T1 to T2, the code compiles, but incorrectly calls A instead of B:
SuperStrict
Framework BRL.StandardIO
Interface I
Method A()
Method B()
End Interface
Type T1 Abstract
Method D() End Method
End Type
Type T2 Extends T1 Implements I Abstract
Method C()
B
End Method
End Type
Type T3 Extends T2 Final
Method A() Override
Print "A"
End Method
Method B() Override
Print "B"
End Method
End Type
New T3.C
If A and B have different signatures, this also results in memory corruption.
It does not matter whether T2 inherits its methods from a class and an interface or from two interfaces: changing T1 into an interface (and adding Method D() Override End Method to T2 or T3) in either of the above samples results in the same issues. However, when doing this with the second sample, the bug only occurs if T2s super types are kept in the same order: Type T2 Implements T1, I Abstract triggers the bug, Type T2 Implements I, T1 Abstract on the other hand works correctly.
In every case, adding Method B() Override Abstract to T2, redeclaring the method that is already inherited from I (the compiler recognizes this as an override) functions as a workaround, causing the code to compile and run correctly.
This issue is still immanent.
@woollybah have you had some time to think about the problem? Is there anything we can do to help?
The workaround mentioned above is not only extremely tedious, but also doesn't seem to work in every situation, which makes this a complete roadblock for larger projects with certain kinds of inheritance hierarchies. @woollybah Is there any hope you could look into this?