ceylon icon indicating copy to clipboard operation
ceylon copied to clipboard

constructor delegation in nested class breaks Java backend

Open MikhailMalyutin opened this issue 8 years ago • 2 comments

Next code:

shared void run(){
    A();
}

class A(){
    shared class B{
        shared Integer i;

        shared new(Integer i){
            this.i = i;
        }

        shared new custom(Integer i, Integer j) extends B(i+j){}

    }
}

produce next error:

Error:ceylon: An unknown error occurred in the Java backend. See previous messages for more information.
/home/workspace/test/source/test/run.ceylon
Error:(9, 9) ceylon: Ceylon backend error: cannot find symbol
symbol:   class B$$delegation$
  location: class test.A
Error:ceylon: Ceylon backend error: cannot find symbol
symbol:   class B$$delegation$
  location: class test.A
Error:(13, 61) ceylon: Ceylon backend error: cannot find symbol
symbol:   variable B$$delegation$
  location: class test.A

MikhailMalyutin avatar Jan 12 '18 12:01 MikhailMalyutin

@FroMage apparently I don't have permission to label issues ;-)

gavinking avatar Jan 13 '18 14:01 gavinking

To be clear, the problem here is with constructor delegation in nested classes. The workaround is to not use constructor delegation, like this:

class A(){
    shared class B{
        shared Integer i;
         
        shared new(Integer i){
            this.i = i;
        }
        
        shared new custom(Integer i, Integer j) {
            this.i = i+j;
        }
        
    }
}

gavinking avatar Apr 19 '18 00:04 gavinking