Re: Traits and protected properties

2017-01-25 Thread Jim Northrop
Russel is looking to build GPars V2.0 as JDK8+ later this year, so timing for Groovy 3 would be nice. Sent from my iPad > On 25 Jan 2017, at 16:43, Cédric Champeau wrote: > > That's only ok once we generate Java 8+ class files only. Otherwise, you > create a language that, syntactically, sup

Re: Traits and protected properties

2017-01-25 Thread Cédric Champeau
Yes, that's why Groovy 3 really seems to be the "blow up everything" version to me 2017-01-25 17:00 GMT+01:00 Daniel Sun : > Hi Cédric, > > As far as I remember, Groovy 3+ will require Java 8. So maybe we could > upgrade the default version of class file to Java 8+ in Groovy 3+ releases? > >

Re: Traits and protected properties

2017-01-25 Thread Daniel Sun
Hi Cédric, As far as I remember, Groovy 3+ will require Java 8. So maybe we could upgrade the default version of class file to Java 8+ in Groovy 3+ releases? Cheers, Daniel.Sun -- View this message in context: http://groovy.329449.n5.nabble.com/Traits-and-protected-properties-tp5738002p5

Re: Traits and protected properties

2017-01-25 Thread Cédric Champeau
That's only ok once we generate Java 8+ class files only. Otherwise, you create a language that, syntactically, supports static methods on interfaces, but cannot compile them for older JDKs. Since we generate JDK 5+ class formats, we cannot do this without upgrading our requirements, or adding "con

Re: Traits and protected properties

2017-01-25 Thread Daniel Sun
Hi Cédric, > oh and that's written in the docs Groovy's documentation is so detail... it's hard for me to believe ;) BTW, Java 8 supports static methods and default methods in the interfaces, how about refining the implementation of traits based on the enhanced interfaces? then traits can have i

Re: Traits and protected properties

2017-01-25 Thread Cédric Champeau
oh and that's written in the docs: http://docs.groovy-lang.org/2.4.0/html/documentation/core-traits.html#_static_methods_properties_and_fields But who reads the f* manual? :) 2017-01-25 14:54 GMT+01:00 Cédric Champeau : > Static methods are *copied* to the weaved class. They do not belong to the

Re: Traits and protected properties

2017-01-25 Thread Cédric Champeau
Static methods are *copied* to the weaved class. They do not belong to the trait itself. 2017-01-25 14:53 GMT+01:00 Daniel Sun : > Hi Graeme, > > Here is my test code, which fails: > > trait A { > public static String m() { return '123' } > } > > A.m() > > error messages: > > groovy.lang

Re: Traits and protected properties

2017-01-25 Thread Daniel Sun
Hi Graeme, Here is my test code, which fails: trait A { public static String m() { return '123' } } A.m() error messages: groovy.lang.MissingMethodException: No signature of method: static A.m() is applicable for argument types: () values: [] Possible solutions: is(java.lang.Object),

Re: Traits and protected properties

2017-01-25 Thread Graeme Rocher
Maybe I'm missing something, but traits do support static methods. We use them extensively in GORM On Wed, Jan 25, 2017 at 1:47 PM, Daniel Sun wrote: > OK. I see. Thanks :) > > BTW, the interface with default methods is based on Traits, I found Traits > does not support static methods too... So m

Re: Traits and protected properties

2017-01-25 Thread Daniel Sun
OK. I see. Thanks :) BTW, the interface with default methods is based on Traits, I found Traits does not support static methods too... So maybe we should generate bytecode for default methods and static methods of interface as Java 8 do. Cheers, Daniel.Sun -- View this message in context: htt

Re: Traits and protected properties

2017-01-25 Thread Cédric Champeau
That's because of the way traits are wired into bytecode. They "look like" belonging to the same hierarchy, but we're delegating to static methods. So we cannot enforce the protected semantics. 2017-01-25 13:24 GMT+01:00 Daniel Sun : > Hi Cédric, > > > having a protected property just cannot wo

Re: Traits and protected properties

2017-01-25 Thread Daniel Sun
Hi Cédric, > having a protected property just cannot work Could you tell me why trait does not support protected property? Thanks, Daniel.Sun -- View this message in context: http://groovy.329449.n5.nabble.com/Traits-and-protected-properties-tp5738002p5738019.html Sent from the Groovy Dev m

Re: Traits and protected properties

2017-01-25 Thread Cédric Champeau
I don't think it's breaking change, since having a protected property just cannot work :) 2017-01-25 13:12 GMT+01:00 Andres Almiray : > +1. > > This being a potential breaking change should IMHO be scheduled for 3.0-ea. > > --- > Java Champion; Groovy Enthu

Re: Traits and protected properties

2017-01-25 Thread Andres Almiray
Any additional constraints that should be checked regarding static members? I'd assume "public static final" fields are injected as constants. What about static methods? I must confess I've never used Groovy traits so far. Cheers, Andres --- Java Champion

Re: Traits and protected properties

2017-01-25 Thread Andres Almiray
+1. This being a potential breaking change should IMHO be scheduled for 3.0-ea. --- Java Champion; Groovy Enthusiast http://jroller.com/aalmiray http://www.linkedin.com/in/aalmiray -- What goes up, must come down. Ask any system administrator. There are 10

Re: Traits and protected properties

2017-01-25 Thread Cédric Champeau
+1, this is an oversight from my side, protected properties should be prohibited too. 2017-01-25 12:56 GMT+01:00 Paul King : > Hi, for traits we explicitly prohibit protected (and package private) > methods - see the doco for some details. For properties however, we > never check (in 2.4.7 and ea