[scala] Type definitions within blocks

View: New views
1 Messages — Rating Filter:   Alert me  

[scala] Type definitions within blocks

by nikov :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

Consider the following definitions:

//////////////////////////////////
class C[T](val x : T)

object A {
  def f[T](x : T) = {
    type S = T
    new C[S](x)
  }
}
//////////////////////////////////

scala> A.f(1)
res4: C[S] = C@126a408

So, type S escapes from the block. According to SLS, 6.11 Blocks, I
would expect that the type A.f(1) is C[_ >: Int <: Int]. Is it a bug?

Thanks,
Vladimir