Default Method for Groovy 3

2016-12-08 Thread Daniel Sun
Hi all,

 The new parser(Parrot) supports default method now. You can find
the new feature at  the enhancedInterface branch of groovy-parser project
  (
https://github.com/danielsun1106/groovy-parser/commit/89f45ac86e7945ef81283697b6ed9018e997a045
). If no problem with the implementation, I'll merge it into the master
later.

*Here is an example:*

interface Greetable {
String name();
default String hello() {
return 'hello'
}
}

class Person implements Greetable {
@Override
public String name() {
return 'Daniel'
}
}

def p = new Person()
assert 'hello, Daniel' == "${p.hello()}, ${p.name()}"

  *Another more complicated example can be found at:*
https://github.com/danielsun1106/groovy-parser/blob/enhancedInterface/src/test/resources/core/DefaultMethod_02x.groovy


Cheers,
Daniel.Sun




--
View this message in context: 
http://groovy.329449.n5.nabble.com/Default-Method-for-Groovy-3-tp5737154.html
Sent from the Groovy Dev mailing list archive at Nabble.com.


Re: Default Method for Groovy 3

2016-12-08 Thread Marcin Erdmann
That's great news. Not being able to use default interface methods,
especially when working with libraries using them in Java code, felt
limiting.

On Thu, 8 Dec 2016 at 17:40, Daniel Sun  wrote:

> Hi all,
>
>
>
>  The new parser(Parrot) supports default method now. You can find
>
> the new feature at  the enhancedInterface branch of groovy-parser project
>
>   (
>
>
> https://github.com/danielsun1106/groovy-parser/commit/89f45ac86e7945ef81283697b6ed9018e997a045
>
> ). If no problem with the implementation, I'll merge it into the master
>
> later.
>
>
>
> *Here is an example:*
>
>
>
> interface Greetable {
>
> String name();
>
> default String hello() {
>
> return 'hello'
>
> }
>
> }
>
>
>
> class Person implements Greetable {
>
> @Override
>
> public String name() {
>
> return 'Daniel'
>
> }
>
> }
>
>
>
> def p = new Person()
>
> assert 'hello, Daniel' == "${p.hello()}, ${p.name()}"
>
>
>
>   *Another more complicated example can be found at:*
>
>
> https://github.com/danielsun1106/groovy-parser/blob/enhancedInterface/src/test/resources/core/DefaultMethod_02x.groovy
>
>
>
>
>
> Cheers,
>
> Daniel.Sun
>
>
>
>
>
>
>
>
>
> --
>
> View this message in context:
> http://groovy.329449.n5.nabble.com/Default-Method-for-Groovy-3-tp5737154.html
>
> Sent from the Groovy Dev mailing list archive at Nabble.com.
>
>


Re: Default Method for Groovy 3

2016-12-08 Thread Guillaume Laforge
Awesome!

On Thu, Dec 8, 2016 at 6:40 PM, Daniel Sun  wrote:

> Hi all,
>
>  The new parser(Parrot) supports default method now. You can find
> the new feature at  the enhancedInterface branch of groovy-parser project
>   (
> https://github.com/danielsun1106/groovy-parser/commit/
> 89f45ac86e7945ef81283697b6ed9018e997a045
> ). If no problem with the implementation, I'll merge it into the master
> later.
>
> *Here is an example:*
>
> interface Greetable {
> String name();
> default String hello() {
> return 'hello'
> }
> }
>
> class Person implements Greetable {
> @Override
> public String name() {
> return 'Daniel'
> }
> }
>
> def p = new Person()
> assert 'hello, Daniel' == "${p.hello()}, ${p.name()}"
>
>   *Another more complicated example can be found at:*
> https://github.com/danielsun1106/groovy-parser/blob/enhancedInterface/src/
> test/resources/core/DefaultMethod_02x.groovy
>
>
> Cheers,
> Daniel.Sun
>
>
>
>
> --
> View this message in context: http://groovy.329449.n5.
> nabble.com/Default-Method-for-Groovy-3-tp5737154.html
> Sent from the Groovy Dev mailing list archive at Nabble.com.
>



-- 
Guillaume Laforge
Apache Groovy committer & PMC Vice-President
Developer Advocate @ Google Cloud Platform

Blog: http://glaforge.appspot.com/
Social: @glaforge  / Google+



Re: Default Method for Groovy 3

2016-12-08 Thread Remi Forax
Hi Daniel,
as you have discovered, there is no flag for specifying a default method in the 
JVM spec, hence no ACC_DEFAULT flag in ASM,
a default method is just a non abstract method in an interface.

Also default and static methods in interface can be either public or private.

cheers,
Rémi

- Mail original -
> De: "Daniel Sun" 
> À: d...@groovy.incubator.apache.org
> Envoyé: Jeudi 8 Décembre 2016 18:40:14
> Objet: Default Method for Groovy 3

> Hi all,
> 
> The new parser(Parrot) supports default method now. You can find
> the new feature at  the enhancedInterface branch of groovy-parser project
>   (
> https://github.com/danielsun1106/groovy-parser/commit/89f45ac86e7945ef81283697b6ed9018e997a045
> ). If no problem with the implementation, I'll merge it into the master
> later.
> 
> *Here is an example:*
> 
> interface Greetable {
>String name();
>default String hello() {
>return 'hello'
>}
> }
> 
> class Person implements Greetable {
>@Override
>public String name() {
>return 'Daniel'
>}
> }
> 
> def p = new Person()
> assert 'hello, Daniel' == "${p.hello()}, ${p.name()}"
> 
>  *Another more complicated example can be found at:*
> https://github.com/danielsun1106/groovy-parser/blob/enhancedInterface/src/test/resources/core/DefaultMethod_02x.groovy
> 
> 
> Cheers,
> Daniel.Sun
> 
> 
> 
> 
> --
> View this message in context:
> http://groovy.329449.n5.nabble.com/Default-Method-for-Groovy-3-tp5737154.html
> Sent from the Groovy Dev mailing list archive at Nabble.com.


Re: Default Method for Groovy 3

2016-12-08 Thread Daniel Sun
Hi Rémi,

 As to the "default" modifier, we have to wait for the release of newer ASM 
to support it ;)

  Thanks for your reminding.

Cheers,
Daniel.Sun




在 "Remi Forax [via Groovy]" 
,2016年12月9日 上午4:38写道:

Hi Daniel,
as you have discovered, there is no flag for specifying a default method in the 
JVM spec, hence no ACC_DEFAULT flag in ASM,
a default method is just a non abstract method in an interface.

Also default and static methods in interface can be either public or private.

cheers,
Rémi

- Mail original -
> De: "Daniel Sun" <[hidden email]>
> À: [hidden email]
> Envoyé: Jeudi 8 Décembre 2016 18:40:14
> Objet: Default Method for Groovy 3

> Hi all,
>
> The new parser(Parrot) supports default method now. You can find
> the new feature at  the enhancedInterface branch of groovy-parser project
>   (
> https://github.com/danielsun1106/groovy-parser/commit/89f45ac86e7945ef81283697b6ed9018e997a045
> ). If no problem with the implementation, I'll merge it into the master
> later.
>
> *Here is an example:*
>
> interface Greetable {
>String name();
>default String hello() {
>return 'hello'
>}
> }
>
> class Person implements Greetable {
>@Override
>public String name() {
>return 'Daniel'
>}
> }
>
> def p = new Person()
> assert 'hello, Daniel' == "${p.hello()}, ${p.name()}"
>
>  *Another more complicated example can be found at:*
> https://github.com/danielsun1106/groovy-parser/blob/enhancedInterface/src/test/resources/core/DefaultMethod_02x.groovy
>
>
> Cheers,
> Daniel.Sun
>
>
>
>
> --
> View this message in context:
> http://groovy.329449.n5.nabble.com/Default-Method-for-Groovy-3-tp5737154.html
> Sent from the Groovy Dev mailing list archive at Nabble.com.



If you reply to this email, your message will be added to the discussion below:
http://groovy.329449.n5.nabble.com/Default-Method-for-Groovy-3-tp5737154p5737158.html
To unsubscribe from Default Method for Groovy 3, click 
here.
NAML




--
View this message in context: 
http://groovy.329449.n5.nabble.com/Default-Method-for-Groovy-3-tp5737154p5737161.html
Sent from the Groovy Dev mailing list archive at Nabble.com.

Re: Default Method for Groovy 3

2016-12-08 Thread Daniel Sun
Hi Rémi,
  I did not catch your words just now. That is great that we do not need 
wait for the release of ASM :)

Cheers,
Daniel.Sun



在 "Remi Forax [via Groovy]" 
,2016年12月9日 上午4:38写道:

Hi Daniel,
as you have discovered, there is no flag for specifying a default method in the 
JVM spec, hence no ACC_DEFAULT flag in ASM,
a default method is just a non abstract method in an interface.

Also default and static methods in interface can be either public or private.

cheers,
Rémi

- Mail original -
> De: "Daniel Sun" <[hidden email]>
> À: [hidden email]
> Envoyé: Jeudi 8 Décembre 2016 18:40:14
> Objet: Default Method for Groovy 3

> Hi all,
>
> The new parser(Parrot) supports default method now. You can find
> the new feature at  the enhancedInterface branch of groovy-parser project
>   (
> https://github.com/danielsun1106/groovy-parser/commit/89f45ac86e7945ef81283697b6ed9018e997a045
> ). If no problem with the implementation, I'll merge it into the master
> later.
>
> *Here is an example:*
>
> interface Greetable {
>String name();
>default String hello() {
>return 'hello'
>}
> }
>
> class Person implements Greetable {
>@Override
>public String name() {
>return 'Daniel'
>}
> }
>
> def p = new Person()
> assert 'hello, Daniel' == "${p.hello()}, ${p.name()}"
>
>  *Another more complicated example can be found at:*
> https://github.com/danielsun1106/groovy-parser/blob/enhancedInterface/src/test/resources/core/DefaultMethod_02x.groovy
>
>
> Cheers,
> Daniel.Sun
>
>
>
>
> --
> View this message in context:
> http://groovy.329449.n5.nabble.com/Default-Method-for-Groovy-3-tp5737154.html
> Sent from the Groovy Dev mailing list archive at Nabble.com.



If you reply to this email, your message will be added to the discussion below:
http://groovy.329449.n5.nabble.com/Default-Method-for-Groovy-3-tp5737154p5737158.html
To unsubscribe from Default Method for Groovy 3, click 
here.
NAML




--
View this message in context: 
http://groovy.329449.n5.nabble.com/Default-Method-for-Groovy-3-tp5737154p5737162.html
Sent from the Groovy Dev mailing list archive at Nabble.com.

Re: Default Method for Groovy 3

2016-12-08 Thread Daniel Sun
It will be a good test case to cover :)

Cheers,
Daniel.Sun



在 "Marcin Erdmann [via Groovy]" 
,2016年12月9日 上午1:51写道:

That's great news. Not being able to use default interface methods, especially 
when working with libraries using them in Java code, felt limiting.

On Thu, 8 Dec 2016 at 17:40, Daniel Sun <[hidden email]> wrote:
Hi all,



 The new parser(Parrot) supports default method now. You can find

the new feature at  the enhancedInterface branch of groovy-parser project

  (

https://github.com/danielsun1106/groovy-parser/commit/89f45ac86e7945ef81283697b6ed9018e997a045

). If no problem with the implementation, I'll merge it into the master

later.



*Here is an example:*



interface Greetable {

String name();

default String hello() {

return 'hello'

}

}



class Person implements Greetable {

@Override

public String name() {

return 'Daniel'

}

}



def p = new Person()

assert 'hello, Daniel' == "${p.hello()}, ${p.name()}"



  *Another more complicated example can be found at:*

https://github.com/danielsun1106/groovy-parser/blob/enhancedInterface/src/test/resources/core/DefaultMethod_02x.groovy





Cheers,

Daniel.Sun









--

View this message in context: 
http://groovy.329449.n5.nabble.com/Default-Method-for-Groovy-3-tp5737154.html

Sent from the Groovy Dev mailing list archive at Nabble.com.




If you reply to this email, your message will be added to the discussion below:
http://groovy.329449.n5.nabble.com/Default-Method-for-Groovy-3-tp5737154p5737155.html
To unsubscribe from Default Method for Groovy 3, click 
here.
NAML




--
View this message in context: 
http://groovy.329449.n5.nabble.com/Default-Method-for-Groovy-3-tp5737154p5737163.html
Sent from the Groovy Dev mailing list archive at Nabble.com.

Re: Default Method for Groovy 3

2016-12-08 Thread Daniel Sun
Thanks ;)



在 "Guillaume Laforge [via Groovy]" 
,2016年12月9日 上午2:21写道:

Awesome!

On Thu, Dec 8, 2016 at 6:40 PM, Daniel Sun <[hidden email]> wrote:
Hi all,

 The new parser(Parrot) supports default method now. You can find
the new feature at  the enhancedInterface branch of groovy-parser project
  (
https://github.com/danielsun1106/groovy-parser/commit/89f45ac86e7945ef81283697b6ed9018e997a045
). If no problem with the implementation, I'll merge it into the master
later.

*Here is an example:*

interface Greetable {
String name();
default String hello() {
return 'hello'
}
}

class Person implements Greetable {
@Override
public String name() {
return 'Daniel'
}
}

def p = new Person()
assert 'hello, Daniel' == "${p.hello()}, ${p.name()}"

  *Another more complicated example can be found at:*
https://github.com/danielsun1106/groovy-parser/blob/enhancedInterface/src/test/resources/core/DefaultMethod_02x.groovy


Cheers,
Daniel.Sun




--
View this message in context: 
http://groovy.329449.n5.nabble.com/Default-Method-for-Groovy-3-tp5737154.html
Sent from the Groovy Dev mailing list archive at Nabble.com.



--
Guillaume Laforge
Apache Groovy committer & PMC Vice-President
Developer Advocate @ Google Cloud Platform

Blog: http://glaforge.appspot.com/
Social: @glaforge / 
Google+



If you reply to this email, your message will be added to the discussion below:
http://groovy.329449.n5.nabble.com/Default-Method-for-Groovy-3-tp5737154p5737156.html
To unsubscribe from Default Method for Groovy 3, click 
here.
NAML




--
View this message in context: 
http://groovy.329449.n5.nabble.com/Default-Method-for-Groovy-3-tp5737154p5737164.html
Sent from the Groovy Dev mailing list archive at Nabble.com.