Acknowledged

Referencing interface own type in interface method signature causes stack overflow in SDK 7.1.0+

I got the following exception when trying to build my app:

Exception in thread "main" java.lang.StackOverflowError
    at java.base/java.util.LinkedHashMap$LinkedKeyIterator.<init>(LinkedHashMap.java:1046)
    at java.base/java.util.LinkedHashMap$LinkedKeySet.iterator(LinkedHashMap.java:701)
    at java.base/java.util.HashSet.iterator(HashSet.java:183)
    at java.base/java.lang.String.join(String.java:3666)
    at com.garmin.monkeybrains.compiler2.ir.types.PolyType.toString(PolyType.java:383)
    at com.garmin.monkeybrains.compiler2.ir.types.InterfaceType.toString(InterfaceType.java:328)
    at com.garmin.monkeybrains.compiler2.ir.types.PolyType.toString(PolyType.java:378)
    at com.garmin.monkeybrains.compiler2.ir.types.InterfaceType.toString(InterfaceType.java:328)
    at com.garmin.monkeybrains.compiler2.ir.types.PolyType.toString(PolyType.java:378)

...

Because the compiler crashed, it couldn't tell me what line number the error came from. After some guesswork, I figured out the error was caused by an interface that references its own type in a method signature, i.e.:


typedef Foo as interface {

function bar(otherFoo as Foo) as Boolean;

};

Changing the type of otherFoo to object prevents the compiler from crashing.

Unfortunately, I haven't been able to produce a self-contained bit of code that replicates the bug for sharing.

The error happens only for SDK versions 7.1.0+.