Hi all, I experimented with overload resolution. And faced with two such examples:
*First* public class Base {} public class Derived extends Base{} class DefaultRouter { def method__(arg1) { return 1 } def method__(Base arg1, Integer x = 4) { return 2 } } trait baseSupplier { def getBase() { return new Base(); } } trait derivedSupplier { def getDerived() { return new Derived(); } } class TraitSupplier implements baseSupplier, derivedSupplier {} println("Default Router") dr = new DefaultRouter() ts = new TraitSupplier() assert dr.method__(ts.getDerived()) == *2* assert dr.method__(ts.getBase()) == *2* *Second* import groovy.transform.CompileStatic @CompileStatic public class BaseStatic {} @CompileStatic public class DerivedStatic extends BaseStatic {} @CompileStatic class DefaultRouterStatic { def method__(arg1) { return 1 } def method__(BaseStatic arg1, Integer x = 4) { return 2 } } @CompileStatic trait baseSupplierStatic { def getBase() { return new BaseStatic(); } } @CompileStatic trait derivedSupplierStatic { def getDerived() { return new DerivedStatic(); } } @CompileStatic class TraitSupplierStatic implements baseSupplierStatic, derivedSupplierStatic {} @CompileStatic class staticResolver { public static void main(String[] args) { println("Default Static Router") DefaultRouterStatic dr = new DefaultRouterStatic() TraitSupplierStatic ts = new TraitSupplierStatic(); assert dr.method__(ts.getDerived()) == *1* assert dr.method__(ts.getBase()) == *1* } } To summarize, when using CompileStatic, we are seeing a call to another method. It is a bug or feature? If this feature, you can comments why it was decided to do? Thanks. -- View this message in context: http://groovy.329449.n5.nabble.com/Overload-resolution-and-CompileStatic-tp5736491.html Sent from the Groovy Dev mailing list archive at Nabble.com.