Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
REPL encoding
➜ scala-public-pickle git:(topic/public-pickle) printf 'object foo { def bar = 42}\nimport foo._\nbar\n val bar = 43\nbar\n' | scala -Xprint:parser -Yrepl-class-based
Welcome to Scala 2.13.1 (OpenJDK 64-Bit Server VM, Java 1.8.0_212).
Type in expressions for evaluation. Or try :help.
scala> object foo { def bar = 42}
[[syntax trees at end of parser]] // <console>
package $line3 {
sealed class $read extends _root_.scala.Serializable {
def <init>() = {
super.<init>();
()
};
sealed class $iw extends _root_.java.io.Serializable {
def <init>() = {
super.<init>();
()
};
sealed class $iw extends _root_.java.io.Serializable {
def <init>() = {
super.<init>();
()
};
object foo extends scala.AnyRef {
def <init>() = {
super.<init>();
()
};
def bar = 42
}
};
val $iw = new $iw()
};
val $iw = new $iw()
};
object $read extends scala.AnyRef {
def <init>() = {
super.<init>();
()
};
val INSTANCE = new $read()
}
}
defined object foo
scala> import foo._
[[syntax trees at end of parser]] // <console>
package $line4 {
sealed class $read extends _root_.scala.Serializable {
def <init>() = {
super.<init>();
()
};
sealed class $iw extends _root_.java.io.Serializable {
def <init>() = {
super.<init>();
()
};
val $line3$read: $line3.$read.INSTANCE.type = $line3.$read.INSTANCE;
import $line3$read.$iw.$iw.foo;
sealed class $iw extends _root_.java.io.Serializable {
def <init>() = {
super.<init>();
()
};
import foo._
};
val $iw = new $iw()
};
val $iw = new $iw()
};
object $read extends scala.AnyRef {
def <init>() = {
super.<init>();
()
};
val INSTANCE = new $read()
}
}
import foo._
[[syntax trees at end of parser]] // <synthetic>
package $line7 {
sealed class $read extends _root_.scala.Serializable {
def <init>() = {
super.<init>();
()
};
sealed class $iw extends _root_.java.io.Serializable {
def <init>() = {
super.<init>();
()
};
val $line3$read: $line3.$read.INSTANCE.type = $line3.$read.INSTANCE;
import $line3$read.$iw.$iw.foo;
sealed class $iw extends _root_.java.io.Serializable {
def <init>() = {
super.<init>();
()
};
import foo._;
sealed class $iw extends _root_.java.io.Serializable {
def <init>() = {
super.<init>();
()
};
sealed class $iw extends _root_.java.io.Serializable {
def <init>() = {
super.<init>();
()
};
def $ires2 = foo
};
val $iw = new $iw()
};
val $iw = new $iw()
};
val $iw = new $iw()
};
val $iw = new $iw()
};
object $read extends scala.AnyRef {
def <init>() = {
super.<init>();
()
};
val INSTANCE = new $read()
}
}
[[syntax trees at end of parser]] // <synthetic>
package $line6 {
sealed class $read extends _root_.scala.Serializable {
def <init>() = {
super.<init>();
()
};
sealed class $iw extends _root_.java.io.Serializable {
def <init>() = {
super.<init>();
()
};
val $line3$read: $line3.$read.INSTANCE.type = $line3.$read.INSTANCE;
import $line3$read.$iw.$iw.foo;
sealed class $iw extends _root_.java.io.Serializable {
def <init>() = {
super.<init>();
()
};
import foo._;
sealed class $iw extends _root_.java.io.Serializable {
def <init>() = {
super.<init>();
()
};
sealed class $iw extends _root_.java.io.Serializable {
def <init>() = {
super.<init>();
()
};
def $ires1 = foo
};
val $iw = new $iw()
};
val $iw = new $iw()
};
val $iw = new $iw()
};
val $iw = new $iw()
};
object $read extends scala.AnyRef {
def <init>() = {
super.<init>();
()
};
val INSTANCE = new $read()
}
}
[[syntax trees at end of parser]] // <synthetic>
package $line5 {
sealed class $read extends _root_.scala.Serializable {
def <init>() = {
super.<init>();
()
};
sealed class $iw extends _root_.java.io.Serializable {
def <init>() = {
super.<init>();
()
};
val $line3$read: $line3.$read.INSTANCE.type = $line3.$read.INSTANCE;
import $line3$read.$iw.$iw.foo;
sealed class $iw extends _root_.java.io.Serializable {
def <init>() = {
super.<init>();
()
};
import foo._;
sealed class $iw extends _root_.java.io.Serializable {
def <init>() = {
super.<init>();
()
};
sealed class $iw extends _root_.java.io.Serializable {
def <init>() = {
super.<init>();
()
};
def $ires0 = foo
};
val $iw = new $iw()
};
val $iw = new $iw()
};
val $iw = new $iw()
};
val $iw = new $iw()
};
object $read extends scala.AnyRef {
def <init>() = {
super.<init>();
()
};
val INSTANCE = new $read()
}
}
scala> bar
[[syntax trees at end of parser]] // <console>
package $line8 {
sealed class $read extends _root_.scala.Serializable {
def <init>() = {
super.<init>();
()
};
sealed class $iw extends _root_.java.io.Serializable {
def <init>() = {
super.<init>();
()
};
val $line3$read: $line3.$read.INSTANCE.type = $line3.$read.INSTANCE;
import $line3$read.$iw.$iw.foo;
sealed class $iw extends _root_.java.io.Serializable {
def <init>() = {
super.<init>();
()
};
import foo._;
sealed class $iw extends _root_.java.io.Serializable {
def <init>() = {
super.<init>();
()
};
sealed class $iw extends _root_.java.io.Serializable {
def <init>() = {
super.<init>();
()
};
val res0 = bar
};
val $iw = new $iw()
};
val $iw = new $iw()
};
val $iw = new $iw()
};
val $iw = new $iw()
};
object $read extends scala.AnyRef {
def <init>() = {
super.<init>();
()
};
val INSTANCE = new $read()
}
}
res0: Int = 42
scala> val bar = 43
[[syntax trees at end of parser]] // <console>
package $line9 {
sealed class $read extends _root_.scala.Serializable {
def <init>() = {
super.<init>();
()
};
sealed class $iw extends _root_.java.io.Serializable {
def <init>() = {
super.<init>();
()
};
val $line3$read: $line3.$read.INSTANCE.type = $line3.$read.INSTANCE;
import $line3$read.$iw.$iw.foo;
sealed class $iw extends _root_.java.io.Serializable {
def <init>() = {
super.<init>();
()
};
import foo._;
sealed class $iw extends _root_.java.io.Serializable {
def <init>() = {
super.<init>();
()
};
sealed class $iw extends _root_.java.io.Serializable {
def <init>() = {
super.<init>();
()
};
val bar = 43
};
val $iw = new $iw()
};
val $iw = new $iw()
};
val $iw = new $iw()
};
val $iw = new $iw()
};
object $read extends scala.AnyRef {
def <init>() = {
super.<init>();
()
};
val INSTANCE = new $read()
}
}
bar: Int = 43
scala> bar
[[syntax trees at end of parser]] // <console>
package $line10 {
sealed class $read extends _root_.scala.Serializable {
def <init>() = {
super.<init>();
()
};
sealed class $iw extends _root_.java.io.Serializable {
def <init>() = {
super.<init>();
()
};
val $line3$read: $line3.$read.INSTANCE.type = $line3.$read.INSTANCE;
import $line3$read.$iw.$iw.foo;
sealed class $iw extends _root_.java.io.Serializable {
def <init>() = {
super.<init>();
()
};
import foo._;
sealed class $iw extends _root_.java.io.Serializable {
def <init>() = {
super.<init>();
()
};
val $line9$read: $line9.$read.INSTANCE.type = $line9.$read.INSTANCE;
import $line9$read.$iw.$iw.$iw.$iw.bar;
sealed class $iw extends _root_.java.io.Serializable {
def <init>() = {
super.<init>();
()
};
val res1 = bar
};
val $iw = new $iw()
};
val $iw = new $iw()
};
val $iw = new $iw()
};
val $iw = new $iw()
};
object $read extends scala.AnyRef {
def <init>() = {
super.<init>();
()
};
val INSTANCE = new $read()
}
}
res1: Int = 43
scala> :quit
➜ scala-public-pickle git:(topic/public-pickle)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.