Collection attribute contributions on ASTNode yield broken Java code

Issue #245 resolved
Christoff Bürger
created an issue

If an equation for a collection attribute is given for ASTNode, malformed Java code is generated.

Example: Generic error handling support

coll java.util.List<ASTNode> ErrorBuilder.ErrorNodes()
     [new java.util.LinkedList<ASTNode>()] with add;

ASTNode contributes this when IsErrorNode() to ErrorBuilder.ErrorNodes()
     for ErrorBuilder();

IsErrorNode() decides for each node if it has errors and ErrorBuilder() is an inherited attribute distributing an unique ErrorBuilder node.

JastAdd generates the following code in ASTNode:

protected void contributeTo_ErrorBuilder_ErrorBuilder_ErrorNodes(java.util.List<ASTNode> collection) {
     super.contributeTo_ErrorBuilder_ErrorBuilder_ErrorNodes(collection);
     if (IsErrorNode())
          collection.add(this);
}

Obviously, the super call is invalid. ASTNode has no super class with a super.contributeTo_ErrorBuilder_ErrorBuilder_ErrorNodes method.

Comments (7)

  1. Jesper Öqvist

    Thank you for reporting the issue! The JastAdd regression tests did not have anything covering this yet!

    I probably caused this error because I was changing collection code generation recently.

  2. Log in to comment