- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
Type definitions within blocks
Thu, 2009-06-18, 11:30
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