Skip to content

Instantly share code, notes, and snippets.

@lyricallogical
Created January 31, 2012 14:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lyricallogical/1710853 to your computer and use it in GitHub Desktop.
Save lyricallogical/1710853 to your computer and use it in GitHub Desktop.
virtpatmat
m:.../quick/bin % cat vpm.scala
object vpm {
Option(0) match {
case Some(0) => 1
case None => 2
}
}
m:.../quick/bin % ./scalac -Xprint:typer vpm.scala
[[syntax trees at end of typer]]// Scala source: vpm.scala
package <empty> {
final object vpm extends Object with ScalaObject {
def <init>(): object vpm = {
vpm.super.<init>();
()
};
scala.Option.apply[Int](0) match {
case (x: Int)Some[Int](0) => 1
case scala.None => 2
}
}
}
m:.../quick/bin % ./scalac -Xprint:typer -Yvirtpatmat vpm.scala
[[syntax trees at end of typer]]// Scala source: vpm.scala
package <empty> {
final object vpm extends Object with ScalaObject {
def <init>(): object vpm = {
vpm.super.<init>();
()
};
scala.this.MatchingStrategy.OptionMatchingStrategy.runOrElse[Option[Int], Int](scala.Option.apply[Int](0))(((x1: Option[Int]) => scala.this.MatchingStrategy.OptionMatchingStrategy.guard[Some[Int]](x1.isInstanceOf[Some[Int]], x1.asInstanceOf[Some[Int]]).flatMap[Int](((x3: Some[Int]) => if (x3.ne(null))
scala.this.MatchingStrategy.OptionMatchingStrategy.guard[Int](0.==(x3.x), x3.x).flatMap[Int](((x4: Int) => scala.this.MatchingStrategy.OptionMatchingStrategy.one[Int](1)))
else
scala.this.MatchingStrategy.OptionMatchingStrategy.zero)).orElse[Int](scala.this.MatchingStrategy.OptionMatchingStrategy.guard[Option[Int]](scala.None.==(x1), x1).flatMap[Int](((x5: Option[Int]) => scala.this.MatchingStrategy.OptionMatchingStrategy.one[Int](2))))))
}
}
-----------------------
# orElse の型エラー直してない場合
m:.../quick/bin % ./scalac -Xprint:typer -Yvirtpatmat vpm.scala
vpm.scala:2: error: type arguments [Option[Int]] do not conform to method orElse's type parameter bounds [B >: Int]
Option(0) match {
^
[[syntax trees at end of typer]]// Scala source: vpm.scala
package <empty> {
final object vpm extends Object with ScalaObject {
def <init>(): object vpm = {
vpm.super.<init>();
()
};
scala.this.MatchingStrategy.OptionMatchingStrategy.runOrElse[Option[Int], Int](scala.Option.apply[Int](0))(((x1: Option[Int]) => scala.this.MatchingStrategy.OptionMatchingStrategy.guard[Some[Int]](x1.isInstanceOf[Some[Int]], x1.asInstanceOf[Some[Int]]).flatMap(((x3: Some[Int]) => if (x3.ne(null))
scala.this.MatchingStrategy.OptionMatchingStrategy.guard[Int](0.==(x3.x), x3.x).flatMap(((x4: Int) => scala.this.MatchingStrategy.OptionMatchingStrategy.one(1.asInstanceOf[Int(1)])))
else
scala.this.MatchingStrategy.OptionMatchingStrategy.zero)).orElse[Option[Int]](scala.this.MatchingStrategy.OptionMatchingStrategy.guard[Option[Int]](scala.None.==(x1), x1).flatMap(((x5: Option[Int]) => scala.this.MatchingStrategy.OptionMatchingStrategy.one(2.asInstanceOf[Int(2)]))))))
}
}
one error found
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment