diff options
Diffstat (limited to 'test/files/run')
46 files changed, 783 insertions, 49 deletions
diff --git a/test/files/run/bcodeInlinerMixed.flags b/test/files/run/bcodeInlinerMixed.flags index 422d6be431..768ca4f13b 100644 --- a/test/files/run/bcodeInlinerMixed.flags +++ b/test/files/run/bcodeInlinerMixed.flags @@ -1 +1 @@ --Yopt:l:classpath
\ No newline at end of file +-opt:l:classpath
\ No newline at end of file diff --git a/test/files/run/classfile-format-51.scala b/test/files/run/classfile-format-51.scala index 3ef0640b84..3a6c4861f1 100644 --- a/test/files/run/classfile-format-51.scala +++ b/test/files/run/classfile-format-51.scala @@ -16,7 +16,7 @@ import Opcodes._ // verify. So the test includes a version check that short-circuits the whole test // on JDK 6 object Test extends DirectTest { - override def extraSettings: String = "-Yopt:l:classpath -usejavacp -d " + testOutput.path + " -cp " + testOutput.path + override def extraSettings: String = "-opt:l:classpath -usejavacp -d " + testOutput.path + " -cp " + testOutput.path def generateClass() { val invokerClassName = "DynamicInvoker" diff --git a/test/files/run/classfile-format-52.scala b/test/files/run/classfile-format-52.scala index ebd0826303..03ceeb074f 100644 --- a/test/files/run/classfile-format-52.scala +++ b/test/files/run/classfile-format-52.scala @@ -13,7 +13,7 @@ import Opcodes._ // By its nature the test can only work on JDK 8+ because under JDK 7- the // interface won't verify. object Test extends DirectTest { - override def extraSettings: String = "-Yopt:l:classpath -usejavacp -d " + testOutput.path + " -cp " + testOutput.path + override def extraSettings: String = "-opt:l:classpath -usejavacp -d " + testOutput.path + " -cp " + testOutput.path def generateInterface() { val interfaceName = "HasDefaultMethod" diff --git a/test/files/run/finalvar.flags b/test/files/run/finalvar.flags index a8c7600a03..c74d0cd327 100644 --- a/test/files/run/finalvar.flags +++ b/test/files/run/finalvar.flags @@ -1 +1 @@ --Yoverride-vars -Yopt:l:project
\ No newline at end of file +-Yoverride-vars -opt:l:project
\ No newline at end of file diff --git a/test/files/run/icode-reader-dead-code.scala b/test/files/run/icode-reader-dead-code.scala index df31219dd5..f646455c89 100644 --- a/test/files/run/icode-reader-dead-code.scala +++ b/test/files/run/icode-reader-dead-code.scala @@ -36,7 +36,7 @@ object Test extends DirectTest { // If inlining fails, the compiler will issue an inliner warning that is not present in the // check file - compileString(newCompiler("-usejavacp", "-Yopt:l:classpath"))(bCode) + compileString(newCompiler("-usejavacp", "-opt:l:classpath"))(bCode) } def readClass(file: String) = { diff --git a/test/files/run/inferred-type-constructors-hou.check b/test/files/run/inferred-type-constructors-hou.check new file mode 100644 index 0000000000..6b09823341 --- /dev/null +++ b/test/files/run/inferred-type-constructors-hou.check @@ -0,0 +1,56 @@ +warning: there were two feature warnings; re-run with -feature for details + p.Iterable[Int] + p.Set[Int] + p.Seq[Int] + p.m.Set[Int] + p.m.Seq[Int] + private[m] p.m.ASet[Int] + p.i.Seq[Int] + private[i] p.i.ASet[Int] + private[i] p.i.ASeq[Int] + p.Iterable[Int] + p.Iterable[Int] + p.Iterable[Int] + p.Iterable[Int] + p.Iterable[Int] + p.Iterable[Int] + p.Iterable[Int] + p.Iterable[Int] + p.Iterable[Int] + p.Set[Int] + p.Iterable[Int] + p.Set[Int] + p.Iterable[Int] + p.Set[Int] + p.Iterable[Int] + p.Iterable[Int] + p.Seq[Int] + p.Iterable[Int] + p.Seq[Int] + p.Iterable[Int] + p.Seq[Int] + p.Iterable[Int] + p.m.Set[Int] + p.Iterable[Int] + p.Set[Int] + p.Iterable[Int] + p.Iterable[Int] + p.Seq[Int] + p.Iterable[Int] + p.Seq[Int] + p.Iterable[Int] + private[p] p.ASet[Int] + private[p] p.AIterable[Int] + p.Iterable[Int] + p.i.Seq[Int] + private[p] p.AIterable[Int] + List[Nothing] + scala.collection.immutable.Vector[Nothing] + scala.collection.immutable.Map[Int,Int] + scala.collection.immutable.Set[Int] + Seq[Int] + Array[Int] + scala.collection.AbstractSet[Int] + Comparable[java.lang.String] + scala.collection.immutable.LinearSeq[Int] + Iterable[Int] diff --git a/test/files/run/inferred-type-constructors-hou.flags b/test/files/run/inferred-type-constructors-hou.flags new file mode 100644 index 0000000000..41565c7e32 --- /dev/null +++ b/test/files/run/inferred-type-constructors-hou.flags @@ -0,0 +1 @@ +-Ypartial-unification diff --git a/test/files/run/inferred-type-constructors-hou.scala b/test/files/run/inferred-type-constructors-hou.scala new file mode 100644 index 0000000000..79a8653f68 --- /dev/null +++ b/test/files/run/inferred-type-constructors-hou.scala @@ -0,0 +1,125 @@ +package p { + trait TCon[+CC[X]] { + def fPublic: CC[Int] = ??? + private[p] def fPackagePrivate: CC[Int] = ??? + protected[p] def fPackageProtected: CC[Int] = ??? + } + trait Iterable[+A] extends TCon[Iterable] + trait Set[A] extends Iterable[A] with TCon[Set] + trait Seq[+A] extends Iterable[A] with TCon[Seq] + + private[p] abstract class AIterable[+A] extends Iterable[A] + private[p] abstract class ASeq[+A] extends AIterable[A] with Seq[A] + private[p] abstract class ASet[A] extends AIterable[A] with Set[A] + + package m { + private[m] abstract class ASeq[A] extends p.ASeq[A] with Seq[A] + private[m] abstract class ASet[A] extends p.ASet[A] with Set[A] + trait Set[A] extends p.Set[A] with TCon[Set] + trait Seq[A] extends p.Seq[A] with TCon[Seq] + trait BitSet extends ASet[Int] + trait IntSeq extends ASeq[Int] + } + + package i { + private[i] abstract class ASeq[+A] extends p.ASeq[A] with Seq[A] + private[i] abstract class ASet[A] extends p.ASet[A] with Set[A] + trait Set[A] extends p.Set[A] with TCon[Set] + trait Seq[+A] extends p.Seq[A] with TCon[Seq] + trait BitSet extends ASet[Int] + trait IntSeq extends ASeq[Int] + } +} + +object Test { + import scala.reflect.runtime.universe._ + // Complicated by the absence of usable type constructor type tags. + def extract[A, CC[X]](xs: CC[A]): CC[A] = xs + def whatis[T: TypeTag](x: T): Unit = { + val tpe = typeOf[T] + val access = tpe.typeSymbol.asInstanceOf[scala.reflect.internal.HasFlags].accessString.replaceAllLiterally("package ", "") + println(f"$access%15s $tpe") + } + + trait IntIterable extends p.Iterable[Int] + trait IntSet extends p.Set[Int] + trait IntSeq extends p.Seq[Int] + + trait MutableIntSet extends p.m.Set[Int] + trait MutableIntSeq extends p.m.Seq[Int] + + trait ImmutableIntSet extends p.i.Set[Int] + trait ImmutableIntSeq extends p.i.Seq[Int] + + def f1: IntIterable = null + def f2: IntSet = null + def f3: IntSeq = null + + def g1: MutableIntSet = null + def g2: MutableIntSeq = null + def g3: p.m.BitSet = null + + def h1: ImmutableIntSeq = null + def h2: p.i.BitSet = null + def h3: p.i.IntSeq = null + + def main(args: Array[String]): Unit = { + whatis(extract(f1)) + whatis(extract(f2)) + whatis(extract(f3)) + whatis(extract(g1)) + whatis(extract(g2)) + whatis(extract(g3)) + whatis(extract(h1)) + whatis(extract(h2)) + whatis(extract(h3)) + + whatis(extract(if (true) f1 else f2)) + whatis(extract(if (true) f1 else f3)) + whatis(extract(if (true) f1 else g1)) + whatis(extract(if (true) f1 else g2)) + whatis(extract(if (true) f1 else g3)) + whatis(extract(if (true) f1 else h1)) + whatis(extract(if (true) f1 else h2)) + whatis(extract(if (true) f1 else h3)) + whatis(extract(if (true) f2 else f3)) + whatis(extract(if (true) f2 else g1)) + whatis(extract(if (true) f2 else g2)) + whatis(extract(if (true) f2 else g3)) + whatis(extract(if (true) f2 else h1)) + whatis(extract(if (true) f2 else h2)) + whatis(extract(if (true) f2 else h3)) + whatis(extract(if (true) f3 else g1)) + whatis(extract(if (true) f3 else g2)) + whatis(extract(if (true) f3 else g3)) + whatis(extract(if (true) f3 else h1)) + whatis(extract(if (true) f3 else h2)) + whatis(extract(if (true) f3 else h3)) + whatis(extract(if (true) g1 else g2)) + whatis(extract(if (true) g1 else g3)) + whatis(extract(if (true) g1 else h1)) + whatis(extract(if (true) g1 else h2)) + whatis(extract(if (true) g1 else h3)) + whatis(extract(if (true) g2 else g3)) + whatis(extract(if (true) g2 else h1)) + whatis(extract(if (true) g2 else h2)) + whatis(extract(if (true) g2 else h3)) + whatis(extract(if (true) g3 else h1)) + whatis(extract(if (true) g3 else h2)) + whatis(extract(if (true) g3 else h3)) + whatis(extract(if (true) h1 else h2)) + whatis(extract(if (true) h1 else h3)) + whatis(extract(if (true) h2 else h3)) + + whatis(extract(Nil)) + whatis(extract(Vector())) + whatis(extract(Map[Int,Int]())) + whatis(extract(Set[Int]())) + whatis(extract(Seq[Int]())) + whatis(extract(Array[Int]())) + whatis(extract(scala.collection.immutable.BitSet(1))) + whatis(extract("abc")) + whatis(extract(if (true) Stream(1) else List(1))) + whatis(extract(if (true) Seq(1) else Set(1))) + } +} diff --git a/test/files/run/noInlineUnknownIndy/Test.scala b/test/files/run/noInlineUnknownIndy/Test.scala index 8d2d20a3cd..c6d227b6f2 100644 --- a/test/files/run/noInlineUnknownIndy/Test.scala +++ b/test/files/run/noInlineUnknownIndy/Test.scala @@ -11,7 +11,7 @@ object Test extends DirectTest { def compileCode(code: String) = { val classpath = List(sys.props("partest.lib"), testOutput.path) mkString sys.props("path.separator") - compileString(newCompiler("-cp", classpath, "-d", testOutput.path, "-Yopt:l:classpath", "-Yopt-inline-heuristics:everything", "-Yopt-warnings:_"))(code) + compileString(newCompiler("-cp", classpath, "-d", testOutput.path, "-opt:l:classpath", "-Yopt-inline-heuristics:everything", "-opt-warnings:_"))(code) } def show(): Unit = { diff --git a/test/files/run/nothingTypeDce.flags b/test/files/run/nothingTypeDce.flags index 8785c036f6..475f6db67c 100644 --- a/test/files/run/nothingTypeDce.flags +++ b/test/files/run/nothingTypeDce.flags @@ -1 +1 @@ --Yopt:unreachable-code +-opt:unreachable-code diff --git a/test/files/run/nothingTypeDce.scala b/test/files/run/nothingTypeDce.scala index 5c3a0731fd..cb1e59e45c 100644 --- a/test/files/run/nothingTypeDce.scala +++ b/test/files/run/nothingTypeDce.scala @@ -1,6 +1,6 @@ // See comment in BCodeBodyBuilder -// -Yopt:unreachable-code +// -opt:unreachable-code class C { // can't just emit a call to ???, that returns value of type Nothing$ (not Int). diff --git a/test/files/run/nothingTypeNoOpt.flags b/test/files/run/nothingTypeNoOpt.flags index bc22511cff..213d7425d1 100644 --- a/test/files/run/nothingTypeNoOpt.flags +++ b/test/files/run/nothingTypeNoOpt.flags @@ -1 +1 @@ --Yopt:l:none +-opt:l:none diff --git a/test/files/run/nothingTypeNoOpt.scala b/test/files/run/nothingTypeNoOpt.scala index 33b20ba851..cc68364bf9 100644 --- a/test/files/run/nothingTypeNoOpt.scala +++ b/test/files/run/nothingTypeNoOpt.scala @@ -1,6 +1,6 @@ // See comment in BCodeBodyBuilder -// -target:jvm-1.6 -Yopt:l:none +// -target:jvm-1.6 -opt:l:none // target enables stack map frame generation class C { diff --git a/test/files/run/repl-no-imports-no-predef-classbased.check b/test/files/run/repl-no-imports-no-predef-classbased.check new file mode 100644 index 0000000000..a796600061 --- /dev/null +++ b/test/files/run/repl-no-imports-no-predef-classbased.check @@ -0,0 +1,23 @@ + +scala> case class K(s: java.lang.String) +defined class K + +scala> class C { implicit val k: K = K("OK?"); override def toString = "C(" + k.toString + ")" } +defined class C + +scala> val c = new C +c: C = C(K(OK?)) + +scala> import c.k +import c.k + +scala> scala.Predef.implicitly[K] +res0: K = K(OK?) + +scala> val k = 42 +k: Int = 42 + +scala> k // was K(OK?) +res1: Int = 42 + +scala> :quit diff --git a/test/files/run/repl-no-imports-no-predef-classbased.scala b/test/files/run/repl-no-imports-no-predef-classbased.scala new file mode 100644 index 0000000000..86bd07b2f2 --- /dev/null +++ b/test/files/run/repl-no-imports-no-predef-classbased.scala @@ -0,0 +1,19 @@ +object Test extends scala.tools.partest.ReplTest { + + override def transformSettings(settings: scala.tools.nsc.Settings) = { + settings.noimports.value = true + settings.nopredef.value = true + settings.Yreplclassbased.value = true + settings + } + + def code = """ +case class K(s: java.lang.String) +class C { implicit val k: K = K("OK?"); override def toString = "C(" + k.toString + ")" } +val c = new C +import c.k +scala.Predef.implicitly[K] +val k = 42 +k // was K(OK?) +""" +} diff --git a/test/files/run/repl-no-imports-no-predef-power.check b/test/files/run/repl-no-imports-no-predef-power.check new file mode 100644 index 0000000000..0d4a30b8e3 --- /dev/null +++ b/test/files/run/repl-no-imports-no-predef-power.check @@ -0,0 +1,29 @@ + +scala> :power +Power mode enabled. :phase is at typer. +import scala.tools.nsc._, intp.global._, definitions._ +Try :help or completions for vals._ and power._ + +scala> // guarding against "error: reference to global is ambiguous" + +scala> global.emptyValDef // "it is imported twice in the same scope by ..." +warning: there was one deprecation warning; re-run with -deprecation for details +res0: $r.global.noSelfType.type = private val _ = _ + +scala> val tp = ArrayClass[scala.util.Random] // magic with tags +warning: there was one feature warning; re-run with -feature for details +tp: $r.global.Type = Array[scala.util.Random] + +scala> tp.memberType(Array_apply) // evidence +res1: $r.global.Type = (i: Int)scala.util.Random + +scala> val m = LIT(10) // treedsl +m: $r.treedsl.global.Literal = 10 + +scala> typed(m).tpe // typed is in scope +res2: $r.treedsl.global.Type = Int(10) + +scala> """escaping is hard, m'kah""" +res3: String = escaping is hard, m'kah + +scala> :quit diff --git a/test/files/run/repl-no-imports-no-predef-power.scala b/test/files/run/repl-no-imports-no-predef-power.scala new file mode 100644 index 0000000000..24d4dceef2 --- /dev/null +++ b/test/files/run/repl-no-imports-no-predef-power.scala @@ -0,0 +1,21 @@ +object Test extends scala.tools.partest.ReplTest { + + override def transformSettings(settings: scala.tools.nsc.Settings) = { + settings.noimports.value = true + settings.nopredef.value = true + settings + } + + def tripleQuote(s: String) = "\"\"\"" + s + "\"\"\"" + + def code = s""" +:power +// guarding against "error: reference to global is ambiguous" +global.emptyValDef // "it is imported twice in the same scope by ..." +val tp = ArrayClass[scala.util.Random] // magic with tags +tp.memberType(Array_apply) // evidence +val m = LIT(10) // treedsl +typed(m).tpe // typed is in scope +${tripleQuote("escaping is hard, m'kah")} + """.trim +} diff --git a/test/files/run/repl-no-imports-no-predef.check b/test/files/run/repl-no-imports-no-predef.check new file mode 100644 index 0000000000..c2c8d21c0a --- /dev/null +++ b/test/files/run/repl-no-imports-no-predef.check @@ -0,0 +1,360 @@ + +scala> 1 +res0: Int = 1 + +scala> 1.0 +res1: Double = 1.0 + +scala> () + +scala> "abc" +res3: String = abc + +scala> (1, 2) +res4: (Int, Int) = (1,2) + +scala> + +scala> { import scala.Predef.ArrowAssoc; 1 -> 2 } +res5: (Int, Int) = (1,2) + +scala> { import scala.Predef.ArrowAssoc; 1 → 2 } +res6: (Int, Int) = (1,2) + +scala> 1 -> 2 +<console>:12: error: value -> is not a member of Int + 1 -> 2 + ^ + +scala> 1 → 2 +<console>:12: error: value → is not a member of Int + 1 → 2 + ^ + +scala> + +scala> val answer = 42 +answer: Int = 42 + +scala> { import scala.StringContext; s"answer: $answer" } +res9: String = answer: 42 + +scala> s"answer: $answer" +<console>:13: error: not found: value StringContext + s"answer: $answer" + ^ + +scala> + +scala> "abc" + true +res11: String = abctrue + +scala> + +scala> { import scala.Predef.any2stringadd; true + "abc" } +res12: String = trueabc + +scala> true + "abc" +<console>:12: error: value + is not a member of Boolean + true + "abc" + ^ + +scala> + +scala> var x = 10 +x: Int = 10 + +scala> var y = 11 +y: Int = 11 + +scala> x = 12 +x: Int = 12 + +scala> y = 13 +y: Int = 13 + +scala> + +scala> 2 ; 3 +<console>:11: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses + 2 ;; + ^ +res14: Int = 3 + +scala> { 2 ; 3 } +<console>:12: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses + { 2 ; 3 } + ^ +res15: Int = 3 + +scala> 5 ; 10 ; case object Cow ; 20 ; class Moo { override def toString = "Moooooo" } ; 30 ; def +bippy = { + 1 + + 2 + + 3 } ; bippy+88+11 +<console>:11: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses + 5 ; 10 ; case object Cow ; 20 ; class Moo { override def toString = "Moooooo" } ; 30 ; def + ^ +<console>:11: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses + 5 ; 10 ; case object Cow ; 20 ; class Moo { override def toString = "Moooooo" } ; 30 ; def + ^ +<console>:11: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses + 5 ; 10 ; case object Cow ; 20 ; class Moo { override def toString = "Moooooo" } ; 30 ; def + ^ +<console>:11: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses + 5 ; 10 ; case object Cow ; 20 ; class Moo { override def toString = "Moooooo" } ; 30 ; def + ^ +defined object Cow +defined class Moo +bippy: Int +res16: Int = 105 + +scala> + +scala> object Bovine { var x: scala.List[_] = null } ; case class Ruminant(x: scala.Int) ; bippy * bippy * bippy +defined object Bovine +defined class Ruminant +res17: Int = 216 + +scala> Bovine.x = scala.List(Ruminant(5), Cow, new Moo) +Bovine.x: List[Any] = List(Ruminant(5), Cow, Moooooo) + +scala> Bovine.x +res18: List[Any] = List(Ruminant(5), Cow, Moooooo) + +scala> + +scala> (2) +res19: Int = 2 + +scala> (2 + 2) +res20: Int = 4 + +scala> ((2 + 2)) +res21: Int = 4 + +scala> ((2 + 2)) +res22: Int = 4 + +scala> ( (2 + 2)) +res23: Int = 4 + +scala> ( (2 + 2 ) ) +res24: Int = 4 + +scala> 5 ; ( (2 + 2 ) ) ; ((5)) +<console>:11: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses + 5 ; ( (2 + 2 ) ) ;; + ^ +<console>:11: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses + 5 ; ( (2 + 2 ) ) ;; + ^ +res25: Int = 5 + +scala> (((2 + 2)), ((2 + 2))) +res26: (Int, Int) = (4,4) + +scala> (((2 + 2)), ((2 + 2)), 2) +res27: (Int, Int, Int) = (4,4,2) + +scala> (((((2 + 2)), ((2 + 2)), 2).productIterator ++ scala.Iterator(3)).mkString) +res28: String = 4423 + +scala> + +scala> 55 ; ((2 + 2)) ; (1, 2, 3) +<console>:11: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses + 55 ; ((2 + 2)) ;; + ^ +<console>:11: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses + 55 ; ((2 + 2)) ;; + ^ +res29: (Int, Int, Int) = (1,2,3) + +scala> 55 ; (x: scala.Int) => x + 1 ; () => ((5)) +<console>:12: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses + 55 ; (x: scala.Int) => x + 1 ;; + ^ +res30: () => Int = <function0> + +scala> + +scala> () => 5 +res31: () => Int = <function0> + +scala> 55 ; () => 5 +<console>:11: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses + 55 ;; + ^ +res32: () => Int = <function0> + +scala> () => { class X ; new X } +res33: () => AnyRef = <function0> + +scala> + +scala> def foo(x: scala.Int)(y: scala.Int)(z: scala.Int) = x+y+z +foo: (x: Int)(y: Int)(z: Int)Int + +scala> foo(5)(10)(15)+foo(5)(10)(15) +res34: Int = 60 + +scala> + +scala> scala.List(1) ++ scala.List('a') +res35: List[AnyVal] = List(1, a) + +scala> + +scala> :paste < EOF +// Entering paste mode (EOF to finish) + +class C { def c = 42 } +EOF + +// Exiting paste mode, now interpreting. + +defined class C + +scala> new C().c +res36: Int = 42 + +scala> :paste <| EOF +// Entering paste mode (EOF to finish) + +class D { def d = 42 } +EOF + +// Exiting paste mode, now interpreting. + +defined class D + +scala> new D().d +res37: Int = 42 + +scala> + +scala> :paste < EOF +// Entering paste mode (EOF to finish) + +class Dingus +{ + private val x = 5 + def y = Dingus.x * 2 +} +object Dingus +{ + private val x = 55 +} +EOF + +// Exiting paste mode, now interpreting. + +defined class Dingus +defined object Dingus + +scala> val x = (new Dingus).y +x: Int = 110 + +scala> + +scala> val x1 = 1 +x1: Int = 1 + +scala> val x2 = 2 +x2: Int = 2 + +scala> val x3 = 3 +x3: Int = 3 + +scala> case class BippyBungus() +defined class BippyBungus + +scala> x1 + x2 + x3 +res38: Int = 6 + +scala> :reset +Resetting interpreter state. +Forgetting this session history: + +1 +1.0 +() +"abc" +(1, 2) +{ import scala.Predef.ArrowAssoc; 1 -> 2 } +{ import scala.Predef.ArrowAssoc; 1 → 2 } +val answer = 42 +{ import scala.StringContext; s"answer: $answer" } +"abc" + true +{ import scala.Predef.any2stringadd; true + "abc" } +var x = 10 +var y = 11 +x = 12 +y = 13 +2 ; 3 +{ 2 ; 3 } +5 ; 10 ; case object Cow ; 20 ; class Moo { override def toString = "Moooooo" } ; 30 ; def +bippy = { + 1 + + 2 + + 3 } ; bippy+88+11 +object Bovine { var x: scala.List[_] = null } ; case class Ruminant(x: scala.Int) ; bippy * bippy * bippy +Bovine.x = scala.List(Ruminant(5), Cow, new Moo) +Bovine.x +(2) +(2 + 2) +((2 + 2)) + ((2 + 2)) + ( (2 + 2)) + ( (2 + 2 ) ) +5 ; ( (2 + 2 ) ) ; ((5)) +(((2 + 2)), ((2 + 2))) +(((2 + 2)), ((2 + 2)), 2) +(((((2 + 2)), ((2 + 2)), 2).productIterator ++ scala.Iterator(3)).mkString) +55 ; ((2 + 2)) ; (1, 2, 3) +55 ; (x: scala.Int) => x + 1 ; () => ((5)) +() => 5 +55 ; () => 5 +() => { class X ; new X } +def foo(x: scala.Int)(y: scala.Int)(z: scala.Int) = x+y+z +foo(5)(10)(15)+foo(5)(10)(15) +scala.List(1) ++ scala.List('a') +new C().c +new D().d +val x = (new Dingus).y +val x1 = 1 +val x2 = 2 +val x3 = 3 +case class BippyBungus() +x1 + x2 + x3 + +Forgetting all expression results and named terms: $intp, BippyBungus, Bovine, Cow, Dingus, Ruminant, answer, bippy, foo, x, x1, x2, x3, y +Forgetting defined types: BippyBungus, C, D, Dingus, Moo, Ruminant + +scala> x1 + x2 + x3 +<console>:12: error: not found: value x1 + x1 + x2 + x3 + ^ +<console>:12: error: not found: value x2 + x1 + x2 + x3 + ^ +<console>:12: error: not found: value x3 + x1 + x2 + x3 + ^ + +scala> val x1 = 4 +x1: Int = 4 + +scala> new BippyBungus +<console>:12: error: not found: type BippyBungus + new BippyBungus + ^ + +scala> class BippyBungus() { def f = 5 } +defined class BippyBungus + +scala> { new BippyBungus ; x1 } +res2: Int = 4 + +scala> :quit diff --git a/test/files/run/repl-no-imports-no-predef.scala b/test/files/run/repl-no-imports-no-predef.scala new file mode 100644 index 0000000000..39f43c534d --- /dev/null +++ b/test/files/run/repl-no-imports-no-predef.scala @@ -0,0 +1,108 @@ +object Test extends scala.tools.partest.ReplTest { + + override def transformSettings(settings: scala.tools.nsc.Settings) = { + settings.noimports.value = true + settings.nopredef.value = true + settings + } + + // replace indylambda function names by <function0> + override def normalize(s: String) = """\$\$Lambda.*""".r.replaceAllIn(s, "<function0>") + + def code = """ +1 +1.0 +() +"abc" +(1, 2) + +{ import scala.Predef.ArrowAssoc; 1 -> 2 } +{ import scala.Predef.ArrowAssoc; 1 → 2 } +1 -> 2 +1 → 2 + +val answer = 42 +{ import scala.StringContext; s"answer: $answer" } +s"answer: $answer" + +"abc" + true + +{ import scala.Predef.any2stringadd; true + "abc" } +true + "abc" + +var x = 10 +var y = 11 +x = 12 +y = 13 + +2 ; 3 +{ 2 ; 3 } +5 ; 10 ; case object Cow ; 20 ; class Moo { override def toString = "Moooooo" } ; 30 ; def +bippy = { + 1 + + 2 + + 3 } ; bippy+88+11 + +object Bovine { var x: scala.List[_] = null } ; case class Ruminant(x: scala.Int) ; bippy * bippy * bippy +Bovine.x = scala.List(Ruminant(5), Cow, new Moo) +Bovine.x + +(2) +(2 + 2) +((2 + 2)) + ((2 + 2)) + ( (2 + 2)) + ( (2 + 2 ) ) +5 ; ( (2 + 2 ) ) ; ((5)) +(((2 + 2)), ((2 + 2))) +(((2 + 2)), ((2 + 2)), 2) +(((((2 + 2)), ((2 + 2)), 2).productIterator ++ scala.Iterator(3)).mkString) + +55 ; ((2 + 2)) ; (1, 2, 3) +55 ; (x: scala.Int) => x + 1 ; () => ((5)) + +() => 5 +55 ; () => 5 +() => { class X ; new X } + +def foo(x: scala.Int)(y: scala.Int)(z: scala.Int) = x+y+z +foo(5)(10)(15)+foo(5)(10)(15) + +scala.List(1) ++ scala.List('a') + +:paste < EOF +class C { def c = 42 } +EOF +new C().c +:paste <| EOF +class D { def d = 42 } +EOF +new D().d + +:paste < EOF +class Dingus +{ + private val x = 5 + def y = Dingus.x * 2 +} +object Dingus +{ + private val x = 55 +} +EOF +val x = (new Dingus).y + +val x1 = 1 +val x2 = 2 +val x3 = 3 +case class BippyBungus() +x1 + x2 + x3 +:reset +x1 + x2 + x3 +val x1 = 4 +new BippyBungus +class BippyBungus() { def f = 5 } +{ new BippyBungus ; x1 } + +""" +} diff --git a/test/files/run/repl-parens.scala b/test/files/run/repl-parens.scala index 43e642a806..613bb6f6af 100644 --- a/test/files/run/repl-parens.scala +++ b/test/files/run/repl-parens.scala @@ -1,6 +1,9 @@ import scala.tools.partest.ReplTest object Test extends ReplTest { + // replace indylambda function names by <function0> + override def normalize(s: String) = """\$\$Lambda.*""".r.replaceAllIn(s, "<function0>") + def code = """ (2) (2 + 2) @@ -26,11 +29,4 @@ foo(5)(10)(15)+foo(5)(10)(15) List(1) ++ List('a') """.trim - - // replace indylambda function names by <function0> - override def eval() = { - val lines = super.eval - val r = """\$\$Lambda.*""".r - lines.map(l => r.replaceAllIn(l, "<function0>")) - } } diff --git a/test/files/run/synchronized.flags b/test/files/run/synchronized.flags index 19c578e4ad..82eb1b9bdd 100644 --- a/test/files/run/synchronized.flags +++ b/test/files/run/synchronized.flags @@ -1 +1 @@ --Yopt:l:project +-opt:l:project diff --git a/test/files/run/t2106.flags b/test/files/run/t2106.flags index b0139685fa..cde9a0c4e6 100644 --- a/test/files/run/t2106.flags +++ b/test/files/run/t2106.flags @@ -1 +1 @@ --Yopt-warnings -Yopt:l:classpath +-opt-warnings -opt:l:classpath diff --git a/test/files/run/t3509.flags b/test/files/run/t3509.flags index 422d6be431..768ca4f13b 100644 --- a/test/files/run/t3509.flags +++ b/test/files/run/t3509.flags @@ -1 +1 @@ --Yopt:l:classpath
\ No newline at end of file +-opt:l:classpath
\ No newline at end of file diff --git a/test/files/run/t3569.flags b/test/files/run/t3569.flags index 422d6be431..768ca4f13b 100644 --- a/test/files/run/t3569.flags +++ b/test/files/run/t3569.flags @@ -1 +1 @@ --Yopt:l:classpath
\ No newline at end of file +-opt:l:classpath
\ No newline at end of file diff --git a/test/files/run/t4285.flags b/test/files/run/t4285.flags index 422d6be431..768ca4f13b 100644 --- a/test/files/run/t4285.flags +++ b/test/files/run/t4285.flags @@ -1 +1 @@ --Yopt:l:classpath
\ No newline at end of file +-opt:l:classpath
\ No newline at end of file diff --git a/test/files/run/t4935.flags b/test/files/run/t4935.flags index 65caa3736e..63535a7f4f 100644 --- a/test/files/run/t4935.flags +++ b/test/files/run/t4935.flags @@ -1 +1 @@ --Yopt:l:classpath +-opt:l:classpath diff --git a/test/files/run/t5676.flags b/test/files/run/t5676.flags index e1b37447c9..73f1330c31 100644 --- a/test/files/run/t5676.flags +++ b/test/files/run/t5676.flags @@ -1 +1 @@ --Xexperimental
\ No newline at end of file +-Yoverride-objects diff --git a/test/files/run/t5789.scala b/test/files/run/t5789.scala index 677c9ca229..893294b56b 100644 --- a/test/files/run/t5789.scala +++ b/test/files/run/t5789.scala @@ -5,7 +5,7 @@ import scala.tools.partest.ReplTest object Test extends ReplTest { - override def extraSettings = "-Yopt:l:classpath" + override def extraSettings = "-opt:l:classpath" def code = """ val n = 2 () => n diff --git a/test/files/run/t6102.flags b/test/files/run/t6102.flags index db58cf3b4c..7f938c550f 100644 --- a/test/files/run/t6102.flags +++ b/test/files/run/t6102.flags @@ -1 +1 @@ --Yopt:l:classpath -Xfatal-warnings +-opt:l:classpath -Xfatal-warnings diff --git a/test/files/run/t6188.flags b/test/files/run/t6188.flags index 422d6be431..768ca4f13b 100644 --- a/test/files/run/t6188.flags +++ b/test/files/run/t6188.flags @@ -1 +1 @@ --Yopt:l:classpath
\ No newline at end of file +-opt:l:classpath
\ No newline at end of file diff --git a/test/files/run/t7407.flags b/test/files/run/t7407.flags index bc22511cff..213d7425d1 100644 --- a/test/files/run/t7407.flags +++ b/test/files/run/t7407.flags @@ -1 +1 @@ --Yopt:l:none +-opt:l:none diff --git a/test/files/run/t7459b-optimize.flags b/test/files/run/t7459b-optimize.flags index 65caa3736e..63535a7f4f 100644 --- a/test/files/run/t7459b-optimize.flags +++ b/test/files/run/t7459b-optimize.flags @@ -1 +1 @@ --Yopt:l:classpath +-opt:l:classpath diff --git a/test/files/run/t7582.flags b/test/files/run/t7582.flags index 1f45833eff..7e64669429 100644 --- a/test/files/run/t7582.flags +++ b/test/files/run/t7582.flags @@ -1 +1 @@ --Yopt:l:classpath -Yopt-warnings
\ No newline at end of file +-opt:l:classpath -opt-warnings
\ No newline at end of file diff --git a/test/files/run/t7582b.flags b/test/files/run/t7582b.flags index 1f45833eff..7e64669429 100644 --- a/test/files/run/t7582b.flags +++ b/test/files/run/t7582b.flags @@ -1 +1 @@ --Yopt:l:classpath -Yopt-warnings
\ No newline at end of file +-opt:l:classpath -opt-warnings
\ No newline at end of file diff --git a/test/files/run/t7747-repl.check b/test/files/run/t7747-repl.check index d698ea668d..c5e92e9d79 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 Serializable { +class $read extends _root_.java.io.Serializable { def <init>() = { super.<init>; () }; - class $iw extends Serializable { + class $iw extends _root_.java.io.Serializable { def <init>() = { super.<init>; () @@ -262,7 +262,7 @@ class $read extends 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 Serializable { + class $iw extends _root_.java.io.Serializable { def <init>() = { super.<init>; () diff --git a/test/files/run/t7747-repl.scala b/test/files/run/t7747-repl.scala index 9b2d1c40be..c6a7e419aa 100644 --- a/test/files/run/t7747-repl.scala +++ b/test/files/run/t7747-repl.scala @@ -9,11 +9,7 @@ object Test extends ReplTest { } // replace indylambda function names by <function0> - override def eval() = { - val lines = super.eval - val r = """\$Lambda.*""".r - lines.map(l => r.replaceAllIn(l, "<function0>")) - } + override def normalize(s: String) = """\$Lambda.*""".r.replaceAllIn(s, "<function0>") def code = """ |var x = 10 diff --git a/test/files/run/t7852.flags b/test/files/run/t7852.flags index bc22511cff..213d7425d1 100644 --- a/test/files/run/t7852.flags +++ b/test/files/run/t7852.flags @@ -1 +1 @@ --Yopt:l:none +-opt:l:none diff --git a/test/files/run/t8601-closure-elim.flags b/test/files/run/t8601-closure-elim.flags index 642187ff4c..24396d4d02 100644 --- a/test/files/run/t8601-closure-elim.flags +++ b/test/files/run/t8601-closure-elim.flags @@ -1 +1 @@ --Ydelambdafy:method -Yopt:l:classpath +-Ydelambdafy:method -opt:l:classpath diff --git a/test/files/run/t8601.flags b/test/files/run/t8601.flags index 65caa3736e..63535a7f4f 100644 --- a/test/files/run/t8601.flags +++ b/test/files/run/t8601.flags @@ -1 +1 @@ --Yopt:l:classpath +-opt:l:classpath diff --git a/test/files/run/t8601b.flags b/test/files/run/t8601b.flags index 65caa3736e..63535a7f4f 100644 --- a/test/files/run/t8601b.flags +++ b/test/files/run/t8601b.flags @@ -1 +1 @@ --Yopt:l:classpath +-opt:l:classpath diff --git a/test/files/run/t8601c.flags b/test/files/run/t8601c.flags index 65caa3736e..63535a7f4f 100644 --- a/test/files/run/t8601c.flags +++ b/test/files/run/t8601c.flags @@ -1 +1 @@ --Yopt:l:classpath +-opt:l:classpath diff --git a/test/files/run/t8601d.flags b/test/files/run/t8601d.flags index 65caa3736e..63535a7f4f 100644 --- a/test/files/run/t8601d.flags +++ b/test/files/run/t8601d.flags @@ -1 +1 @@ --Yopt:l:classpath +-opt:l:classpath diff --git a/test/files/run/t8601e.flags b/test/files/run/t8601e.flags index 65caa3736e..63535a7f4f 100644 --- a/test/files/run/t8601e.flags +++ b/test/files/run/t8601e.flags @@ -1 +1 @@ --Yopt:l:classpath +-opt:l:classpath diff --git a/test/files/run/t8925.flags b/test/files/run/t8925.flags index bc22511cff..213d7425d1 100644 --- a/test/files/run/t8925.flags +++ b/test/files/run/t8925.flags @@ -1 +1 @@ --Yopt:l:none +-opt:l:none diff --git a/test/files/run/t9003.flags b/test/files/run/t9003.flags index 65caa3736e..63535a7f4f 100644 --- a/test/files/run/t9003.flags +++ b/test/files/run/t9003.flags @@ -1 +1 @@ --Yopt:l:classpath +-opt:l:classpath diff --git a/test/files/run/t9403.flags b/test/files/run/t9403.flags index 65caa3736e..63535a7f4f 100644 --- a/test/files/run/t9403.flags +++ b/test/files/run/t9403.flags @@ -1 +1 @@ --Yopt:l:classpath +-opt:l:classpath |