diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2016-11-23 15:54:03 +1000 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2016-11-28 15:57:54 +1000 |
commit | 1b2cd1be9790bf9c14fd68c78f784d6cb4f7c907 (patch) | |
tree | faf895234a20def5d929a6e476f1d9a4a1d4b488 /test/files | |
parent | 753e848f3d6ac453871450161292139902669695 (diff) | |
download | scala-1b2cd1be9790bf9c14fd68c78f784d6cb4f7c907.tar.gz scala-1b2cd1be9790bf9c14fd68c78f784d6cb4f7c907.tar.bz2 scala-1b2cd1be9790bf9c14fd68c78f784d6cb4f7c907.zip |
Support inlining under -Yrepl-class-based REPL
By marking the wrapper classes as sealed, the inliner will be
able to assume finality of defs introduces in the REPL without
requiring the user to mark them as `final`, which is an odd thing
to do in single line of REPL input.
Diffstat (limited to 'test/files')
-rw-r--r-- | test/files/run/repl-inline.check | 5 | ||||
-rw-r--r-- | test/files/run/repl-inline.scala | 18 | ||||
-rw-r--r-- | test/files/run/t7747-repl.check | 6 |
3 files changed, 20 insertions, 9 deletions
diff --git a/test/files/run/repl-inline.check b/test/files/run/repl-inline.check index 3b29f4d047..db729a67dd 100644 --- a/test/files/run/repl-inline.check +++ b/test/files/run/repl-inline.check @@ -4,3 +4,8 @@ g: String h: String g: String h: String +callerOfCaller: String +g: String +h: String +g: String +h: String diff --git a/test/files/run/repl-inline.scala b/test/files/run/repl-inline.scala index 5a5f205ad8..260ed28a4f 100644 --- a/test/files/run/repl-inline.scala +++ b/test/files/run/repl-inline.scala @@ -1,7 +1,8 @@ import scala.tools.nsc._ object Test { - val testCode = """ + val testCode = + """ def callerOfCaller = Thread.currentThread.getStackTrace.drop(2).head.getMethodName def g = callerOfCaller def h = g @@ -12,10 +13,15 @@ assert(h == "h", h) """ def main(args: Array[String]) { - val settings = new Settings() - settings.processArgumentString("-opt:l:classpath") - settings.usejavacp.value = true - val repl = new interpreter.IMain(settings) - testCode.linesIterator.foreach(repl.interpret(_)) + def test(f: Settings => Unit): Unit = { + val settings = new Settings() + settings.processArgumentString("-opt:l:classpath") + f(settings) + settings.usejavacp.value = true + val repl = new interpreter.IMain(settings) + testCode.linesIterator.foreach(repl.interpret(_)) + } + test(_ => ()) + test(_.Yreplclassbased.value = true) } } diff --git a/test/files/run/t7747-repl.check b/test/files/run/t7747-repl.check index 621a70205e..ab37da5722 100644 --- a/test/files/run/t7747-repl.check +++ b/test/files/run/t7747-repl.check @@ -246,12 +246,12 @@ scala> case class Bingo() defined class Bingo scala> List(BippyBups(), PuppyPups(), Bingo()) // show -class $read extends _root_.java.io.Serializable { +sealed class $read extends _root_.java.io.Serializable { def <init>() = { super.<init>; () }; - class $iw extends _root_.java.io.Serializable { + sealed class $iw extends _root_.java.io.Serializable { def <init>() = { super.<init>; () @@ -262,7 +262,7 @@ class $read extends _root_.java.io.Serializable { import $line45.$read.INSTANCE.$iw.$iw.PuppyPups; import $line46.$read.INSTANCE.$iw.$iw.Bingo; import $line46.$read.INSTANCE.$iw.$iw.Bingo; - class $iw extends _root_.java.io.Serializable { + sealed class $iw extends _root_.java.io.Serializable { def <init>() = { super.<init>; () |