As @jsuereth already pointed out, there is a mismatch between the setAttribute and setAttributeLocal , namely that the former accepts Key[T <: Number] , but captures the value that comes with the key to exactly be a Number , while the latter is more flexible and allows you to use the key and the value T <: Number . It looks rather strange, and you can reconsider this decision. This also leads to the problem explained by @Ben Schulz.
In any case, the compiler (2.9.1) is satisfied with the following setting:
MyI.java :
public interface MyI { public <T extends Number> void setAttribute(Key<T> key, Number value); }
Key.java :
public interface Key<T> { }
Test.scala :
object Test extends App { def setAttribute[T <: Number](key: Key[T], value: Number) = { setAttributeLocal(key, value) } private def setAttributeLocal[T](key: Key[T], value: Number) = { /* Notice that value is now also of type Number. */ } }
Malte schwerhoff
source share