Take the 2-minute tour ×  This problem arose in a module I'm
writing, but I have made a minimal case that exhibits the same
behaviour.  class Minimal[T](x : T) {   def doSomething = x
object Sugar {   type S[T] = { def doSomething : T }   def
apply[T, X <: S[T]] (x: X) = x.doSomething  object Error {   val
a = new Minimal(4)   Sugar(a) // error: inferred [Nothing,
Minimal[Int]] does not fit the bounds of apply   Sugar[Int,
Minimal[Int]](a) // works as expected  The problem is that the
compiler manages to figure out the inner parameter for Minimal
(Int), but then sets the other occurrence of T to Nothing, which
obviously does not match apply. These are definitely the same T,
as removing the first parameter makes the second complain that T
is not defined.  Is there some ambiguity that means that the
compiler cannot infer the first parameter, or is this a bug? Can
I work around this gracefully?  Further information: This code
is a simple example of an attempt at syntactic sugar. The
original code tries to make