Aladdin - Scala Bugtracking
[#80] project: compiler priority: medium category: missing feature
submitter assigned to status date submitted
Matthias Martin won't fix 2003-07-21 14:26:37.0
subject Local type inference restriction?
code
trait X[A, B <: X[A, B]] {}
class Y[A] with X[A, Y[A]] {}
class Z[A, B <: X[A, B]](obj: B) {}
object Main {
    def main(args: Array[String]) = {
        val z = new Z(new Y[Int]);   
    }
}
what happened
I am not quite sure if this is a bug, or if this is a restriction of the local type inference algorithm. The pro\
gram above does not compile, it yields the following message:
U.scala:6: inferred type arguments [A,Y[scala.Int]] do not conform to constructor Z's type parameter bounds [A,B\
 <: X[A,B]]
        val z = new Z(new Y[Int]);
                     ^
Theoretically, it should be possible to infer that A == Int, but socos currently doesn't do it. I was sur\ prised about it, but it might be a neccessary restriction.
what expected No compile-time error.
[back to overview]
Changes of this bug report
Martin  edited on  2003-07-31 12:04:53.0
It's a shortcoming of the local type inference algorithm. The problem is that type parameters are minimized so that arguments fit formal parameters. The minimization might violate an F-bound. It seems to be quite hard to specify and implement an algorithm that takes care of F-bounds at the same time as solving minimization constraints.