, , , - , . , , .
script scala -print:
var m: Option[String] = _
m match {
case Some(s) => "Some: " + s
case None => "None"
}
desugared, ( ):
final class Main$$anon$1 extends java.lang.Object {
private[this] var m: Option = _;
private <accessor> def m(): Option = Main$$anon$1.this.m;
def this(): anonymous class Main$$anon$1 = {
<synthetic> val temp1: Option = Main$$anon$1.this.m();
if (temp1.$isInstanceOf[Some]()) {
"Some: ".+(temp1.$asInstanceOf[Some]().x())
else if (scala.this.None.==(temp1))
"None"
else
throw new MatchError(temp1)
}
}
, , m, temp1, , m , , - m . , ( global_point TwoDim ) .
, , , !
script:
case class X(var f: Int, var x: X)
var x = new X(-1, new X(1, null))
x match {
case X(f, ix) if f > 0 || ix.f > 0 => "gt0"
case X(f, ix) if f <= 0 || ix.f <= 0 => "lte0"
}
:
private[this] var x: anonymous class Main$$anon$1$X = _;
private <accessor> def x(): anonymous class Main$$anon$1$X = Main$$anon$1.this.x;
final <synthetic> private[this] def gd2$1(x$1: Int, x$2: anonymous class Main$$anon$1$X): Boolean = x$1.>(0).||(x$2.f().>(0));
final <synthetic> private[this] def gd3$1(x$1: Int, x$2: anonymous class Main$$anon$1$X): Boolean = x$1.<=(0).||(x$2.f().<=(0));
def this(): anonymous class Main$$anon$1 = {
<synthetic> val temp6: anonymous class Main$$anon$1$X = Main$$anon$1.this.x();
if (temp6.ne(null)) {
<synthetic> val temp7: Int = temp6.f();
<synthetic> val temp8: anonymous class Main$$anon$1$X = temp6.x();
if (Main$$anon$1.this.gd2$1(temp7, temp8))
"gt0"
else if (Main$$anon$1.this.gd3$1(temp7, temp8))
"lte0"
else
throw new MatchError(temp6)
} else
throw new MatchError(temp6)
}
x, , - x.f ( f) x.x ( ix), ix.f. , , , , , , . , - .