Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-1265

using 'this' in field assignments

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.0-JSR-5
    • 1.0-JSR-6
    • None

    Description

      > ----
      > class Bla

      { > @Property Bla self = this > }

      > println new Bla()
      > ----
      > throws NPE.

      It's probably helpful to say that it causes an NPE in the compiler:

      Caught: java.lang.NullPointerException
      java.lang.NullPointerException
      at org.codehaus.groovy.ast.ClassNode.equals(ClassNode.java:540)
      at org.codehaus.groovy.ast.ClassNode.equals(ClassNode.java:538)
      at org.codehaus.groovy.classgen.AsmClassGenerator.doConvertAndCast
      (AsmClassGenerator.java:993)
      at org.codehaus.groovy.classgen.AsmClassGenerator.visitCastExpression
      (AsmClassGenerator.java:1429)
      at org.codehaus.groovy.classgen.AsmClassGenerator.evaluateEqual
      (AsmClassGenerator.java:2812)
      at
      org.codehaus.groovy.classgen.AsmClassGenerator.visitBinaryExpression
      (AsmClassGenerator.java:1055)
      at org.codehaus.groovy.ast.expr.BinaryExpression.visit
      (BinaryExpression.java:79)
      at
      org.codehaus.groovy.classgen.AsmClassGenerator.visitAndAutoboxBoolean
      (AsmClassGenerator.java:2876)
      at
      org.codehaus.groovy.classgen.AsmClassGenerator.visitExpressionStatement(
      AsmClassGenerator.java:1021)
      at org.codehaus.groovy.ast.stmt.ExpressionStatement.visit
      (ExpressionStatement.java:70)
      at org.codehaus.groovy.ast.CodeVisitorSupport.visitBlockStatement
      (CodeVisitorSupport.java:165)
      at
      org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitBlockStatement
      (ClassCodeVisitorSupport.java:93)
      at org.codehaus.groovy.classgen.AsmClassGenerator.visitBlockStatement
      (AsmClassGenerator.java:465)
      at org.codehaus.groovy.ast.stmt.BlockStatement.visit
      (BlockStatement.java:82)

      Attachments

        Activity

          People

            blackdrag Jochen Theodorou
            codevise Dierk König
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: