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-8215) Implicit .call doesn't work with operators
Date Thu, 01 Jun 2017 13:48:04 GMT
Daniil Ovchinnikov created GROOVY-8215:
------------------------------------------

             Summary: Implicit .call doesn't work with operators
                 Key: GROOVY-8215
                 URL: https://issues.apache.org/jira/browse/GROOVY-8215
             Project: Groovy
          Issue Type: Bug
            Reporter: Daniil Ovchinnikov


{code}
interface Callable {
  def call(it)
}

class ClassWithPlusClosure {
  def getPlus() { return { println it } }
}

def cwpc = new ClassWithPlusClosure()
cwpc.getPlus().call(1)  // explicit
cwpc.plus.call(2)       // plus as a property
cwpc.plus(3)         // implicit .call on plus property
cwpc + 4                // works as expected


class ClassWithPlusCallable {
  def getPlus() {
    new Callable() {
      def call(it) { println it }
    }
  }
}

def cwpcallable = new ClassWithPlusCallable()
cwpcallable.getPlus().call(1)
cwpcallable.plus.call(2)
cwpcallable.plus(3)               // MME; see linked issue
cwpcallable + 4                   // MME
{code}



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

Mime
View raw message