eclipse-archived / ceylon

The Ceylon compiler, language module, and command line tools
http://ceylon-lang.org
Apache License 2.0
397 stars 62 forks source link

constructor delegation in nested class breaks Java backend #7316

Open MikhailMalyutin opened 6 years ago

MikhailMalyutin commented 6 years ago

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
gavinking commented 6 years ago

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

gavinking commented 6 years ago

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;
        }

    }
}