You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Welcome to Scala version 2.10.0-RC2 (JavaHotSpot(TM) ClientVM, Java1.7.0_09).
Type in expressions to have them evaluated.
Type:help for more information.
scala>importreflect.runtime.universe._importreflect.runtime.universe._
scala>Block(Ident("foo"))
res0: reflect.runtime.universe.Block=
{
foo;
()
}
The pair of brackets change the result type to Unit, and I want it just be a foo.
@xeno-by said:
@杨博: Use Block(Nil, Ident("foo")) instead.
@jason: It looks like we need to jettison all the "helper" tree factory methods I exposed from the compiler. Ident("foo") without explicitly specifying newTermName gives me shivers.
Activity
scabug commentedon Nov 21, 2012
Imported From: https://issues.scala-lang.org/browse/SI-6696?orig=1
Reporter: @Atry
Affected Versions: 2.10.0-RC2
scabug commentedon Nov 21, 2012
@retronym said (edited on Nov 21, 2012 8:30:17 AM UTC):
Eugene: is this intentional?
{code:title=src/reflect/scala/reflect/internal/Trees.scala}
/** Block factory that flattens directly nested blocks.
/
def Block(stats: Tree): Block = {
if (stats.isEmpty) Block(Nil, Literal(Constant(())))
else stats match {
case Seq(b @ Block(_, )) => b
case Seq(stat) => Block(stats.toList, Literal(Constant(())))
case Seq(, rest @ _*) => Block(stats.init.toList, stats.last)
}
}
{code}
scabug commentedon Nov 21, 2012
@xeno-by said:
@杨博: Use Block(Nil, Ident("foo")) instead.
@jason: It looks like we need to jettison all the "helper" tree factory methods I exposed from the compiler. Ident("foo") without explicitly specifying newTermName gives me shivers.
scabug commentedon Nov 21, 2012
@xeno-by said:
I'm closing this issue, because it's not a bug per se, just a problem with misleading methods that made it to the public API.
scabug commentedon Nov 21, 2012
@xeno-by said:
scala/scala#1654