Community
Participate
Working Groups
import com.google.common.base.Optional import static java.lang.Enum.* class C { def static void valueOf(Object o, Object context) {} def Object m() { val idx = valueOf(null, null) return idx } } Due to the static import, #valueOf is overloaded with C.valueOf(Object, Object) and Enum.<T>valueOf(Class<T>, String). The latter is more specific in the sense that the argument types match both overloaded signatures but Class and String are more specific parameter types than Object, Object. Java does not support this kind of overloading and would always bind to the local declaration, independently from the given arguments - even for obvious mismatches like static void valueOf(Object o, Integer context) {} Object m() { valueOf(RetentionPolicy.class, ""); return null; } where the local signature does not match at all. Generally speaking, Xtend has an advantage here. However, since the given invocation valueOf(null, null) does not give any hints on the value of the type parameter <T> of Enum.valueOf thus it has to be bound to <?> which would not fulfill the constraints of T extends Enum<T>. Therefore, the local valueOf(Object,Object) declaration would be a better choice in this scenario.
see org.eclipse.xtend.core.tests.compiler.CompilerBug435133Test.testBug436483_01()