Created
May 2, 2025 05:52
-
-
Save xuwei-k/2c3cad639cc21740d8de72ad24f71164 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ scala -Xprint:typer -e "for { a <- Option(2) ; b <- Option(a) } yield b" | |
[[syntax trees at end of typer]] // scalacmd15102494186904250690.scala | |
package <empty> { | |
object Main extends scala.AnyRef { | |
def <init>(): Main.type = { | |
Main.super.<init>(); | |
() | |
}; | |
def main(args: Array[String]): Unit = { | |
final class $anon extends scala.AnyRef { | |
def <init>(): <$anon: AnyRef> = { | |
$anon.super.<init>(); | |
() | |
}; | |
scala.Option.apply[Int](2).flatMap[Int](((a: Int) => scala.Option.apply[Int](a).map[Int](((b: Int) => b)))) | |
}; | |
{ | |
new $anon(); | |
() | |
} | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ scala -Xprint:typer -e "for { a <- Option(2) ; b = a } yield b" | |
[[syntax trees at end of typer]] // scalacmd460138560044168679.scala | |
package <empty> { | |
object Main extends scala.AnyRef { | |
def <init>(): Main.type = { | |
Main.super.<init>(); | |
() | |
}; | |
def main(args: Array[String]): Unit = { | |
final class $anon extends scala.AnyRef { | |
def <init>(): <$anon: AnyRef> = { | |
$anon.super.<init>(); | |
() | |
}; | |
scala.Option.apply[Int](2).map[(Int, Int)](((a: Int) => { | |
val b: Int = a; | |
scala.Tuple2.apply[Int, Int](a, b) | |
})).map[Int](((x$1: (Int, Int)) => (x$1: (Int, Int) @unchecked) match { | |
case (_1: Int, _2: Int): (Int, Int)((a @ _), (b @ _)) => b | |
})) | |
}; | |
{ | |
new $anon(); | |
() | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment