[scala] Re: is this a bug?
Adriaan Moors wrote:
> when you write an identifier in a position where a type parameter is
> expected, you introduce a new variable (thus, the "Int" in the above
> snippets does not refer to the existing type Int, but is just some type
> parameter with an unfortunate name)
Yes, I was suffering from a temporary brain-melt when posting that.
Still there's something fishy about my original example, here's a slight
variation:
trait T[A[C] <: T[A, B], B] {
def x : T[A, B] = y
def y : A[Int]
}
This indicates to me that the compiler considers that "A[C] <: T[A, B]"
holds for all C. The problem is that now we can define a subtype like this:
class T2[B] extends T[T2, B] { def y = new T2[Int] }
Here's an example how this causes problems:
scala> val t = new T2[Float]
t: T2[Float] = T2@d01311
scala> val t2 = t.x
<console>:7: error: type arguments [T2,Float] do not conform to trait
T's type parameter bounds [A[C] <: T[A,B],B]
val t2 = t.x
^
Clearly something isn't right here.
/Jesper Nordenberg