groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Daniil Ovchinnikov (JIRA)" <j...@apache.org>
Subject [jira] [Created] (GROOVY-8214) Implicit .call is inconsistent
Date Thu, 01 Jun 2017 13:30:12 GMT
Daniil Ovchinnikov created GROOVY-8214:
------------------------------------------

             Summary: Implicit .call is inconsistent
                 Key: GROOVY-8214
                 URL: https://issues.apache.org/jira/browse/GROOVY-8214
             Project: Groovy
          Issue Type: Bug
            Reporter: Daniil Ovchinnikov


{code}
interface Callable {
  def call()
}

def callable = new Callable() {
  def call() { println "callable local var" }
}
callable.call()
callable()

class ClassWithCallableField {
  public ppp = new Callable() {
    def call() { println "callable field" }
  }
}

def cwcp = new ClassWithCallableField()
cwcp.ppp.call()
cwcp.ppp() // MME

def foo(Callable p) {
  p.call()
  p()
}

foo new Callable() {
  def call() { println "callable parameter" }
}

class ClassWithCallableGetter {
  def getGetter() {
    new Callable() {
      def call() { println "callable getter" }
    }
  }
}

def cwcg = new ClassWithCallableGetter()
cwcg.getter.call()
cwcg.getter() // MME

class ClassWithCallableFieldInside {
  public bbb = new Callable() {
    def call() { println "callable field inside class" }
  }

  def foo() {
    bbb.call()
    bbb()
  }
}

new ClassWithCallableFieldInside().foo()

class ClassWithCallableGetterInside {

  def getGetter() {
    new Callable() {
      def call() { println "callable getter inside class" }
    }
  }

  def foo() {
    getter.call()
    getter() // MME
  }
}

new ClassWithCallableGetterInside().foo()
{code}



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Mime
View raw message