This page is no longer maintained — Please continue to the home page at www.scala-lang.org

Type definitions within blocks

No replies
Vladimir Reshetnikov
Joined: 2009-06-16,
User offline. Last seen 42 years 45 weeks ago.

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

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland