Daniel Sun created GROOVY-8542:

             Summary: Support creating instances of non-static inner classes 
with Java-Like syntax 
                 Key: GROOVY-8542
                 URL: https://issues.apache.org/jira/browse/GROOVY-8542
             Project: Groovy
          Issue Type: New Feature
            Reporter: Daniel Sun
             Fix For: 3.0.0-alpha-2, 2.6.0-alpha-4



public class Y {
    public class X {
        def name

        public X(String name) {
            this.name = name

    public static Y createY() {
        return new Y()

    public static X createX(Y y) {
        return y.new X('Daniel')

    public static X createX() {
        return createY().new X('Daniel')

    public static String getXName() {
        return createY().new X('Daniel').name

    public static String getXName2() {
        return createY().
                        new X('Daniel')

def createY() {
    return new Y()

assert 'Daniel' == Y.createX(new Y()).name
assert 'Daniel' == Y.createX().name
assert 'Daniel' == Y.getXName()
assert 'Daniel' == Y.getXName2()


This message was sent by Atlassian JIRA

Reply via email to