Using XScalaWT, this compiled under Scala 2.7:
class NodeView(parent: Composite) extends Composite(parent) { var nodeName: Label = null this.contains( label( nodeName = _ ) ) } With 2.8.0 RC1, I get this error:
type mismatch; found : main.scala.NodeView required: org.eclipse.swt.widgets.Label
The types are:
label(setups: (Label => Unit)*)(parent: Composite) : Label contains(setups: (W => Unit)*) : W So it looks like _ now binds to the outer function instead of inner.
Is this change intentional?
UPDATE: Here is a minimized example:
Scala 2.7.7:
scala> var i = 0 i: Int = 0 scala> def conv(f: Int => Unit) = if (_:Boolean) f(1) else f(0) conv: ((Int) => Unit)(Boolean) => Unit scala> def foo(g: Boolean => Unit) { g(true) } foo: ((Boolean) => Unit)Unit scala> foo(conv(i = _)) scala> i res4: Int = 1 Scala 2.8.0RC3:
scala> var i = 0 i: Int = 0 scala> def conv(f: Int => Unit) = if (_:Boolean) f(1) else f(0) conv: (f: (Int) => Unit)(Boolean) => Unit scala> def foo(g: Boolean => Unit) { g(true) } foo: (g: (Boolean) => Unit)Unit scala> foo(conv(i = _)) <console>:9: error: type mismatch; found : Boolean required: Int foo(conv(i = _)) ^ scala> foo(conv(j => i = j)) scala> i res3: Int = 1 Interestingly enough, this works:
scala> foo(conv(println _)) 1