Faulty code generation with --concurrent option

Issue #298 resolved
Jesper Öqvist created an issue

JastAdd 2.3.2

When an NTA is abstractly declared on an abstract class, it causes incorrect code to be generated for the abstract class.

For example:

Test.ast:
abstract A ::= /d:D/;
B: A;
C: A;
D;

Test.jrag:
// .options: concurrent
// .result: COMPILE_PASS
aspect Test {
  syn lazy D A.getd();
  eq B.getd() = new D();
  eq C.getd() = new D(); 
}

The above JastAdd code leads to the following incorrect code generated in A.java:

        public ASTNode getChildNoTransform(int i) {
                Object _value = AttributeValue.NONE;
                switch (i) {
                        case 0:
                          _value = getd_value.get();
                          break;
                }
                if (_value != AttributeValue.NONE) {
                        return (ASTNode) _value;
                }
                return super.getChildNoTransformBase(i);
        }

The getd_value field is not part of class A because the NTA is only an abstract attribute in A. The following compilation error results from the above code:

    [junit] Compilation failed when expected to pass:
    [junit] tmp/nta/concurrent_01p/A.java:102: error: cannot find symbol
    [junit]                       _value = getd_value.get();
    [junit]                                ^

Comments (3)

  1. Jesper Öqvist reporter

    Fix problem in concurrent code gen with NTAs

    Avoid generating a child access for NTAs which don't have an equation on the current class.

    fixes #298 (bitbucket)

    → <<cset a52e949b1d0b>>

  2. Log in to comment