groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Daniel Sun (JIRA)" <j...@apache.org>
Subject [jira] [Created] (GROOVY-8947) Fail to resolve non-static inner class outside of outer class
Date Sat, 05 Jan 2019 15:07:00 GMT
Daniel Sun created GROOVY-8947:
----------------------------------

             Summary: Fail to resolve non-static inner class outside of outer class
                 Key: GROOVY-8947
                 URL: https://issues.apache.org/jira/browse/GROOVY-8947
             Project: Groovy
          Issue Type: Bug
            Reporter: Daniel Sun


{code:java}

public class Computer {
    public class Cpu {
        int coreNumber

        public Cpu(int coreNumber) {
            this.coreNumber = coreNumber
        }
    }
    public static newInstance() {
        return new Computer().new Cpu(4)
    }
}

assert 4 == new Computer().new Cpu(4).coreNumber // unable to resolve class Cpu 
// assert 4 == Computer.newInstance().coreNumber // resolve class Cpu successfully
{code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message