You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by GitBox <gi...@apache.org> on 2019/07/08 01:32:36 UTC

[GitHub] [groovy] eric-milles opened a new pull request #963: GROOVY-9168: emit more specific error for use of uninitialized this

eric-milles opened a new pull request #963:  GROOVY-9168: emit more specific error for use of uninitialized this
URL: https://github.com/apache/groovy/pull/963
 
 
   Improved error message for cases like:
   ```groovy
   class Outer {
     class Inner {}
     Outer(Inner inner) {}
     Outer() { this(new Inner()) } // uninitialized this passed to inner class constructor
   }
   ```
   Simplified `StaticVerifier` and handle `this.@foo` and `this.&foo` in addition to `this.foo` and implicit-this `foo()`.  Special constructor call args and parameter defaults have unified handling.
   
   One test case was disabled.  It is not possible to distinguish this case from other error cases.  And you can add `Outer.this.` qualifier to reference the property (next test case in the unit test source).
   ```groovy
       void _FIXME_testAccessOuterClassMethodFromInnerClassConstructor() {
           assertScript '''
               class Parent {
                   String str
                   Parent(String s) { str = s }
               }
               class Outer {
                   String a
   
                   private class Inner extends Parent {
                      Inner() { super(getA()) } // Is this a reference to instance property or outer property?
                   }
   
                   String test() { new Inner().str }
               }
               def o = new Outer(a:'ok')
               assert o.test() == 'ok'
           '''
       }
   ```
   
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services