diff options
Diffstat (limited to 'test/files/run')
41 files changed, 449 insertions, 198 deletions
diff --git a/test/files/run/delambdafy_uncurry_byname_inline.check b/test/files/run/delambdafy_uncurry_byname_inline.check index 0dc69b379a..d96a995f44 100644 --- a/test/files/run/delambdafy_uncurry_byname_inline.check +++ b/test/files/run/delambdafy_uncurry_byname_inline.check @@ -7,7 +7,7 @@ package <empty> { }; def bar(x: () => Int): Int = x.apply(); def foo(): Int = Foo.this.bar({ - @SerialVersionUID(0) final <synthetic> class $anonfun extends scala.runtime.AbstractFunction0[Int] with Serializable { + @SerialVersionUID(value = 0) final <synthetic> class $anonfun extends scala.runtime.AbstractFunction0[Int] with Serializable { def <init>(): <$anon: () => Int> = { $anonfun.super.<init>(); () diff --git a/test/files/run/delambdafy_uncurry_inline.check b/test/files/run/delambdafy_uncurry_inline.check index e2b024b462..5521cc4a2c 100644 --- a/test/files/run/delambdafy_uncurry_inline.check +++ b/test/files/run/delambdafy_uncurry_inline.check @@ -7,7 +7,7 @@ package <empty> { }; def bar(): Unit = { val f: Int => Int = { - @SerialVersionUID(0) final <synthetic> class $anonfun extends scala.runtime.AbstractFunction1[Int,Int] with Serializable { + @SerialVersionUID(value = 0) final <synthetic> class $anonfun extends scala.runtime.AbstractFunction1[Int,Int] with Serializable { def <init>(): <$anon: Int => Int> = { $anonfun.super.<init>(); () diff --git a/test/files/run/iterator-concat.check b/test/files/run/iterator-concat.check deleted file mode 100644 index 23835b07ae..0000000000 --- a/test/files/run/iterator-concat.check +++ /dev/null @@ -1,4 +0,0 @@ -100 -1000 -10000 -100000 diff --git a/test/files/run/iterator-concat.scala b/test/files/run/iterator-concat.scala deleted file mode 100644 index f11363410f..0000000000 --- a/test/files/run/iterator-concat.scala +++ /dev/null @@ -1,15 +0,0 @@ -object Test { - // Create `size` Function0s, each of which evaluates to an Iterator - // which produces 1. Then fold them over ++ to get a single iterator, - // which should sum to "size". - def mk(size: Int): Iterator[Int] = { - val closures = (1 to size).toList.map(x => (() => Iterator(1))) - closures.foldLeft(Iterator.empty: Iterator[Int])((res, f) => res ++ f()) - } - def main(args: Array[String]): Unit = { - println(mk(100).sum) - println(mk(1000).sum) - println(mk(10000).sum) - println(mk(100000).sum) - } -} diff --git a/test/files/run/iterator-iterate-lazy.scala b/test/files/run/iterator-iterate-lazy.scala deleted file mode 100644 index 92b170062e..0000000000 --- a/test/files/run/iterator-iterate-lazy.scala +++ /dev/null @@ -1,5 +0,0 @@ -object Test { - def main(args: Array[String]): Unit = { - Iterator.iterate((1 to 5).toList)(_.tail).takeWhile(_.nonEmpty).map(_.head).toList - } -} diff --git a/test/files/run/iterators.check b/test/files/run/iterators.check deleted file mode 100644 index bb139c1610..0000000000 --- a/test/files/run/iterators.check +++ /dev/null @@ -1,13 +0,0 @@ -test check_from was successful -test check_range was successful -test check_range2 was successful -test check_range3 was successful -test check_take was successful -test check_drop was successful -test check_foreach was successful -test check_forall was successful -test check_fromArray was successful -test check_toSeq was successful -test check_indexOf was successful -test check_findIndexOf was successful - diff --git a/test/files/run/iterators.scala b/test/files/run/iterators.scala deleted file mode 100644 index 57e05d3472..0000000000 --- a/test/files/run/iterators.scala +++ /dev/null @@ -1,136 +0,0 @@ -//############################################################################ -// Iterators -//############################################################################ - -//############################################################################ - -import scala.language.postfixOps - -object Test { - - def check_from: Int = { - val it1 = Iterator.from(-1) - val it2 = Iterator.from(0, -1) - it1.next + it2.next - } - - def check_range: Int = { - val xs1 = Iterator.range(0, 10, 2) toList; - val xs2 = Iterator.range(0, 10, -2) toList; - val xs3 = Iterator.range(10, 0, -2) toList; - val xs4 = Iterator.range(10, 0, 2) toList; - val xs5 = Iterator.range(0, 10, 11) toList; - xs1.length + xs2.length + xs3.length + xs4.length + xs5.length - } - - def check_range2: Int = { - val r1start = 0 - val r1end = 10 - val r1step = 1 - val r1 = Iterator.range(r1start, r1end, r1step) toList; - val r2 = Iterator.range(r1start, r1end, r1step + 1) toList; - val r3 = Iterator.range(r1end, r1start, -r1step) toList; - val r4 = Iterator.range(0, 10, 11) toList; - // 10 + 5 + 10 + 1 - r1.length + r2.length + r3.length + r4.length - } - - def check_range3: Int = { - def trues(xs: List[Boolean]) = xs.foldLeft(0)((a, b) => if (b) a+1 else a) - val r1 = Iterator.range(0, 10) - val xs1 = List(r1 contains 5, r1 contains 6) - val r2a = Iterator.range(0, 10, 2) - val r2b = Iterator.range(0, 10, 2) - val xs2 = List(r2a contains 5, r2b contains 6) - val r3 = Iterator.range(0, 10, 11) - val xs3 = List(r3 contains 5, r3 contains 6) - // 2 + 1 + 0 - trues(xs1) + trues(xs2) + trues(xs3) - } - - def check_take: Int = { - val it1 = Iterator.from(0) - val xs1 = it1 take 10 toList; - xs1.length - } - - def check_drop: Int = { - val it1 = Iterator.from(0) - val it2 = it1 map { 2 * _ } - val n1 = it1 drop 2 next - val n2 = it2 drop 2 next; - n1 + n2 - } - - def check_foreach: Int = { - val it1 = Iterator.from(0) take 20 - var n = 0 - it1 foreach { n += _ } - n - } - - def check_forall: Int = { - val it1 = Iterator.from(0) - val it2 = Iterator.from(1) - 0 - } - - def check_fromArray: Int = { // ticket #429 - val a = List(1, 2, 3, 4).toArray - var xs0 = a.iterator.toList; - var xs1 = a.slice(0, 1).iterator.toList; - var xs2 = a.slice(0, 2).iterator.toList; - var xs3 = a.slice(0, 3).iterator.toList; - var xs4 = a.slice(0, 4).iterator.toList; - xs0.length + xs1.length + xs2.length + xs3.length + xs4.length - } - - def check_toSeq: String = - List(1, 2, 3, 4, 5).iterator.toSeq.mkString("x") - - def check_indexOf: String = { - val i = List(1, 2, 3, 4, 5).indexOf(4) - val j = List(1, 2, 3, 4, 5).indexOf(16) - "" + i + "x" + j - } - - def check_findIndexOf: String = { - val i = List(1, 2, 3, 4, 5).indexWhere { x: Int => x >= 4 } - val j = List(1, 2, 3, 4, 5).indexWhere { x: Int => x >= 16 } - "" + i + "x" + j - } - - def check_success[A](name: String, closure: => A, expected: A) { - print("test " + name) - try { - val actual: A = closure - if (actual == expected) - print(" was successful") - else - print(" failed: expected "+ expected +", found "+ actual) - } - catch { - case exception: Throwable => - print(" raised exception " + exception) - } - println() - } - - def main(args: Array[String]) { - check_success("check_from", check_from, -1) - check_success("check_range", check_range, 11) - check_success("check_range2", check_range2, 26) - check_success("check_range3", check_range3, 3) - check_success("check_take", check_take, 10) - check_success("check_drop", check_drop, 12) - check_success("check_foreach", check_foreach, 190) - check_success("check_forall", check_forall, 0) - check_success("check_fromArray",check_fromArray, 14) - check_success("check_toSeq", check_toSeq, "1x2x3x4x5") - check_success("check_indexOf", check_indexOf, "3x-1") - check_success("check_findIndexOf", check_findIndexOf, "3x-1") - println() - } -} - -//############################################################################ diff --git a/test/files/run/repl-javap-outdir-funs.flags b/test/files/run/repl-javap-outdir-funs.flags new file mode 100644 index 0000000000..ac96850b69 --- /dev/null +++ b/test/files/run/repl-javap-outdir-funs.flags @@ -0,0 +1 @@ +-Ydelambdafy:inline
\ No newline at end of file diff --git a/test/files/run/repl-javap-outdir-funs/run-repl_7.scala b/test/files/run/repl-javap-outdir-funs/run-repl_7.scala index 6c6fe2d515..af9651a8a3 100644 --- a/test/files/run/repl-javap-outdir-funs/run-repl_7.scala +++ b/test/files/run/repl-javap-outdir-funs/run-repl_7.scala @@ -1,6 +1,8 @@ import scala.tools.partest.JavapTest object Test extends JavapTest { + // note the '-fun': it makes :javap search for some anonfun. + // for that reason, this test has a flags file that forces delambdafy:inline (doesn't allow :method) def code = """ |:javap -fun disktest/Foo.class """.stripMargin @@ -11,7 +13,8 @@ object Test extends JavapTest { if (scala.tools.partest.utils.Properties.isAvian) true else { - def filtered = res filter (_ contains "public final class disktest.Foo") + val r = "public final class disktest.Foo.*extends scala.runtime.AbstractFunction1".r + def filtered = res filter (r.findFirstIn(_).nonEmpty) 1 == filtered.size } } diff --git a/test/files/run/sammy_repeated.check b/test/files/run/sammy_repeated.check new file mode 100644 index 0000000000..1cff0f067c --- /dev/null +++ b/test/files/run/sammy_repeated.check @@ -0,0 +1 @@ +WrappedArray(1) diff --git a/test/files/run/sammy_repeated.flags b/test/files/run/sammy_repeated.flags new file mode 100644 index 0000000000..e1b37447c9 --- /dev/null +++ b/test/files/run/sammy_repeated.flags @@ -0,0 +1 @@ +-Xexperimental
\ No newline at end of file diff --git a/test/files/run/sammy_repeated.scala b/test/files/run/sammy_repeated.scala new file mode 100644 index 0000000000..c24dc41909 --- /dev/null +++ b/test/files/run/sammy_repeated.scala @@ -0,0 +1,8 @@ +trait RepeatedSink { def accept(a: Any*): Unit } + +object Test { + def main(args: Array[String]): Unit = { + val f: RepeatedSink = (a) => println(a) + f.accept(1) + } +}
\ No newline at end of file diff --git a/test/files/run/t1994.scala b/test/files/run/t1994.scala new file mode 100644 index 0000000000..0b463e3444 --- /dev/null +++ b/test/files/run/t1994.scala @@ -0,0 +1,20 @@ +class A { + protected def x = 0 + protected[A] def y = 0 +} + +class B extends A { + override def x = 1 + def superY = super[A].y + override def y = 1 +} + + +object Test { + def main(args: Array[String]): Unit = { + val b = new B + assert(b.x == 1) + assert(b.y == 1) + assert(b.superY == 0) + } +} diff --git a/test/files/run/t2866.check b/test/files/run/t2866.check new file mode 100644 index 0000000000..7f52da85fb --- /dev/null +++ b/test/files/run/t2866.check @@ -0,0 +1,3 @@ +t2866.scala:30: warning: imported `one' is permanently hidden by definition of value one + import A.one // warning: imported `one' is permanently hidden by definition of value one. + ^ diff --git a/test/files/run/t2866.scala b/test/files/run/t2866.scala new file mode 100644 index 0000000000..8059107583 --- /dev/null +++ b/test/files/run/t2866.scala @@ -0,0 +1,44 @@ +// for 2.7.x compatibility + +object A { + implicit val one = 1 +} + +object Test extends App { + + locally { + import A._ + locally { + // assert(implicitly[Int] == 1) // error: could not find implicit value for parameter e: Int. + // !!! Why one A.one? + // (I assume you mean: why _not_ A.one? A.one is shadowed by local one. + // but the local one cannot be used yet because it does not have an explicit type. + implicit val one = 2 + assert(implicitly[Int] == 2) + assert(one == 2) + } + } + + locally { + import A._ + implicit val one: Int = 2 + assert(implicitly[Int] == 2) + assert(one == 2) + } + + locally { + import A.one // warning: imported `one' is permanently hidden by definition of value one. + // !!! Really? + //assert(implicitly[Int] == 1) + implicit val one = 2 + assert(implicitly[Int] == 2) // !!! why not 2? + assert(one == 2) + } + + locally { + import A.{one => _, _} + implicit val two = 2 + assert(implicitly[Int] == 2) // not ambiguous in 2.8.0 nor im ambiguous in 2.7.6 + } + +} diff --git a/test/files/run/t3516.check b/test/files/run/t3516.check deleted file mode 100644 index d0d10d82fa..0000000000 --- a/test/files/run/t3516.check +++ /dev/null @@ -1,3 +0,0 @@ -1 -1 -21 diff --git a/test/files/run/t3516.scala b/test/files/run/t3516.scala deleted file mode 100644 index aa302ce85a..0000000000 --- a/test/files/run/t3516.scala +++ /dev/null @@ -1,13 +0,0 @@ -object Test { - def mkIterator = (1 to 5).iterator map (x => { println(x) ; x }) - def mkInfinite = Iterator continually { println(1) ; 1 } - - def main(args: Array[String]): Unit = { - // Stream is strict in its head so we should see 1 from each of them. - val s1 = mkIterator.toStream - val s2 = mkInfinite.toStream - // back and forth without slipping into nontermination. - println((Stream from 1).toIterator.drop(10).toStream.drop(10).toIterator.next) - () - } -} diff --git a/test/files/run/t5665.scala b/test/files/run/t5665.scala new file mode 100644 index 0000000000..3ac498b5c0 --- /dev/null +++ b/test/files/run/t5665.scala @@ -0,0 +1,13 @@ +object O { + trait T { + private[this] val c: Int = 42 + def f = + { x: Int => c } + } +} + +object Test { + def main(args: Array[String]): Unit = { + assert(new O.T{}.f(0) == 42) + } +} diff --git a/test/files/run/t6028.check b/test/files/run/t6028.check index 55ff42d8d7..edc8b22d6d 100644 --- a/test/files/run/t6028.check +++ b/test/files/run/t6028.check @@ -24,7 +24,7 @@ package <empty> { (new <$anon: Function0>(T.this, tryyParam, tryyLocal): Function0) } }; - @SerialVersionUID(0) final <synthetic> class $anonfun$foo$1 extends scala.runtime.AbstractFunction0$mcI$sp with Serializable { + @SerialVersionUID(value = 0) final <synthetic> class $anonfun$foo$1 extends scala.runtime.AbstractFunction0$mcI$sp with Serializable { def <init>($outer: T, methodParam$1: Int, methodLocal$1: Int): <$anon: Function0> = { $anonfun$foo$1.super.<init>(); () @@ -60,7 +60,7 @@ package <empty> { }; scala.this.Predef.print(scala.Int.box(barParam$1)) }; - @SerialVersionUID(0) final <synthetic> class $anonfun$tryy$1 extends scala.runtime.AbstractFunction0$mcV$sp with Serializable { + @SerialVersionUID(value = 0) final <synthetic> class $anonfun$tryy$1 extends scala.runtime.AbstractFunction0$mcV$sp with Serializable { def <init>($outer: T, tryyParam$1: Int, tryyLocal$1: runtime.IntRef): <$anon: Function0> = { $anonfun$tryy$1.super.<init>(); () diff --git a/test/files/run/t6260c.check b/test/files/run/t6260c.check index 1a57f2d741..78e9b27371 100644 --- a/test/files/run/t6260c.check +++ b/test/files/run/t6260c.check @@ -1,5 +1,9 @@ f(C@2e) +#partest !-Ydelambdafy:method Test$$anonfun$$apply +#partest -Ydelambdafy:method +Test$lambda$1$$apply +#partest apply g(C@2e) diff --git a/test/files/run/t6502.check b/test/files/run/t6502.check new file mode 100644 index 0000000000..95d36ee221 --- /dev/null +++ b/test/files/run/t6502.check @@ -0,0 +1,8 @@ +test1 res1: true +test1 res2: true +test2 res1: true +test2 res2: true +test3 res1: true +test3 res2: true +test4 res1: true +test4 res2: true diff --git a/test/files/run/t6502.scala b/test/files/run/t6502.scala new file mode 100644 index 0000000000..ced1b5812d --- /dev/null +++ b/test/files/run/t6502.scala @@ -0,0 +1,101 @@ +import scala.tools.partest._ +import java.io.File +import scala.tools.nsc.interpreter.ILoop + +object Test extends StoreReporterDirectTest { + def code = ??? + + def compileCode(code: String, jarFileName: String) = { + val classpath = List(sys.props("partest.lib"), testOutput.path) mkString sys.props("path.separator") + compileString(newCompiler("-cp", classpath, "-d", s"${testOutput.path}/$jarFileName"))(code) + } + + def app1 = """ + package test + + object Test extends App { + def test(): Unit = { + println("testing...") + } + }""" + + def app2 = """ + package test + + object Test extends App { + def test(): Unit = { + println("testing differently...") + } + }""" + + def app3 = """ + package test + + object Test3 extends App { + def test(): Unit = { + println("new object in existing package") + } + }""" + + def test1(): Unit = { + val jar = "test1.jar" + compileCode(app1, jar) + + val output = ILoop.run(List(s":require ${testOutput.path}/$jar", "test.Test.test()")) + val lines = output.split("\n") + val res1 = lines(4).contains("Added") && lines(4).contains("test1.jar") + val res2 = lines(lines.length-3).contains("testing...") + + println(s"test1 res1: $res1") + println(s"test1 res2: $res2") + } + + def test2(): Unit = { + // should reject jars with conflicting entries + val jar1 = "test1.jar" + val jar2 = "test2.jar" + compileCode(app2, jar2) + + val output = ILoop.run(List(s":require ${testOutput.path}/$jar1", s":require ${testOutput.path}/$jar2")) + val lines = output.split("\n") + val res1 = lines(4).contains("Added") && lines(4).contains("test1.jar") + val res2 = lines(lines.length-3).contains("test2.jar") && lines(lines.length-3).contains("existing classpath entries conflict") + + println(s"test2 res1: $res1") + println(s"test2 res2: $res2") + } + + def test3(): Unit = { + // should accept jars with overlapping packages, but no conflicts + val jar1 = "test1.jar" + val jar3 = "test3.jar" + compileCode(app3, jar3) + + val output = ILoop.run(List(s":require ${testOutput.path}/$jar1", s":require ${testOutput.path}/$jar3", "test.Test3.test()")) + val lines = output.split("\n") + val res1 = lines(4).contains("Added") && lines(4).contains("test1.jar") + val res2 = lines(lines.length-3).contains("new object in existing package") + + println(s"test3 res1: $res1") + println(s"test3 res2: $res2") + } + + def test4(): Unit = { + // twice the same jar should be rejected + val jar1 = "test1.jar" + val output = ILoop.run(List(s":require ${testOutput.path}/$jar1", s":require ${testOutput.path}/$jar1")) + val lines = output.split("\n") + val res1 = lines(4).contains("Added") && lines(4).contains("test1.jar") + val res2 = lines(lines.length-3).contains("test1.jar") && lines(lines.length-3).contains("existing classpath entries conflict") + + println(s"test4 res1: $res1") + println(s"test4 res2: $res2") + } + + def show(): Unit = { + test1() + test2() + test3() + test4() + } +} diff --git a/test/files/run/t6555.check b/test/files/run/t6555.check index 9ac115a13f..e3b467ce7c 100644 --- a/test/files/run/t6555.check +++ b/test/files/run/t6555.check @@ -6,7 +6,7 @@ package <empty> { () }; private[this] val f: Int => Int = { - @SerialVersionUID(0) final <synthetic> class $anonfun extends scala.runtime.AbstractFunction1$mcII$sp with Serializable { + @SerialVersionUID(value = 0) final <synthetic> class $anonfun extends scala.runtime.AbstractFunction1$mcII$sp with Serializable { def <init>(): <$anon: Int => Int> = { $anonfun.super.<init>(); () diff --git a/test/files/run/t7019.scala b/test/files/run/t7019.scala new file mode 100644 index 0000000000..5dcc09d2b6 --- /dev/null +++ b/test/files/run/t7019.scala @@ -0,0 +1,10 @@ +final class Foo(val i: Int) extends AnyVal { + def foo() = go(i) + private[this] def go(i: Int) = i * 2 +} + +object Test { + def main(args: Array[String]): Unit = { + assert(new Foo(1).foo() == 2) + } +} diff --git a/test/files/run/t7407.flags b/test/files/run/t7407.flags index c8547a27dc..be4ef0798a 100644 --- a/test/files/run/t7407.flags +++ b/test/files/run/t7407.flags @@ -1 +1 @@ --Ynooptimise -Ybackend:GenBCode +-Ynooptimise -Yopt:l:none -Ybackend:GenBCode diff --git a/test/files/run/t8253.check b/test/files/run/t8253.check new file mode 100644 index 0000000000..0b4cb2d1f7 --- /dev/null +++ b/test/files/run/t8253.check @@ -0,0 +1,40 @@ + +<sample xmlns='ns1'/> +{ + var $tmpscope: _root_.scala.xml.NamespaceBinding = $scope; + $tmpscope = new _root_.scala.xml.NamespaceBinding(null, "ns1", $tmpscope); + { + val $scope: _root_.scala.xml.NamespaceBinding = $tmpscope; + new _root_.scala.xml.Elem(null, "sample", _root_.scala.xml.Null, $scope, true) + } +} + +<sample xmlns={identity(ns1)}/> +{ + var $tmpscope: _root_.scala.xml.NamespaceBinding = $scope; + $tmpscope = new _root_.scala.xml.NamespaceBinding(null, ns1, $tmpscope); + { + val $scope: _root_.scala.xml.NamespaceBinding = $tmpscope; + new _root_.scala.xml.Elem(null, "sample", _root_.scala.xml.Null, $scope, true) + } +} + +<sample xmlns:foo='ns1'/> +{ + var $tmpscope: _root_.scala.xml.NamespaceBinding = $scope; + $tmpscope = new _root_.scala.xml.NamespaceBinding("foo", "ns1", $tmpscope); + { + val $scope: _root_.scala.xml.NamespaceBinding = $tmpscope; + new _root_.scala.xml.Elem(null, "sample", _root_.scala.xml.Null, $scope, true) + } +} + +<sample xmlns:foo={identity(ns1)}/> +{ + var $tmpscope: _root_.scala.xml.NamespaceBinding = $scope; + $tmpscope = new _root_.scala.xml.NamespaceBinding("foo", ns1, $tmpscope); + { + val $scope: _root_.scala.xml.NamespaceBinding = $tmpscope; + new _root_.scala.xml.Elem(null, "sample", _root_.scala.xml.Null, $scope, true) + } +} diff --git a/test/files/run/t8253.scala b/test/files/run/t8253.scala new file mode 100644 index 0000000000..c4800b4491 --- /dev/null +++ b/test/files/run/t8253.scala @@ -0,0 +1,14 @@ +object Test extends App { + import reflect.runtime.universe._ // not using the XML library in compiler tests + + def show(code: String, t: Tree) = println(s"\n$code\n$t") + + val ns1 = "ns1" + show("<sample xmlns='ns1'/>", q"<sample xmlns='ns1'/>") + show("<sample xmlns={identity(ns1)}/>", q"<sample xmlns={ns1}/>") + show("<sample xmlns:foo='ns1'/>", q"<sample xmlns:foo='ns1'/>") + show("<sample xmlns:foo={identity(ns1)}/>", q"<sample xmlns:foo={ns1}/>") + + // `identity(foo)` used to match the overly permissive match in SymbolXMLBuilder + // which was intented to more specifically match `_root_.scala.xml.Text(...)` +} diff --git a/test/files/run/t8549.scala b/test/files/run/t8549.scala index d3355208fa..cb254e3810 100644 --- a/test/files/run/t8549.scala +++ b/test/files/run/t8549.scala @@ -79,9 +79,12 @@ object Test extends App { } } - // Generated on 20140505-14:47:14 with Scala version 2.11.1-20140505-142300-e8562571d2) + // Generated on 20141010-14:01:28 with Scala version 2.11.2) overwrite.foreach(updateComment) + check(Some(1))("rO0ABXNyAApzY2FsYS5Tb21lESLyaV6hi3QCAAFMAAF4dAASTGphdmEvbGFuZy9PYmplY3Q7eHIADHNjYWxhLk9wdGlvbv5pN/3bDmZ0AgAAeHBzcgARamF2YS5sYW5nLkludGVnZXIS4qCk94GHOAIAAUkABXZhbHVleHIAEGphdmEubGFuZy5OdW1iZXKGrJUdC5TgiwIAAHhwAAAAAQ==") + check(None)("rO0ABXNyAAtzY2FsYS5Ob25lJEZQJPZTypSsAgAAeHIADHNjYWxhLk9wdGlvbv5pN/3bDmZ0AgAAeHA=") + check(List(1, 2, 3))( "rO0ABXNyADJzY2FsYS5jb2xsZWN0aW9uLmltbXV0YWJsZS5MaXN0JFNlcmlhbGl6YXRpb25Qcm94eQAAAAAAAAABAwAAeHBzcgARamF2YS5sYW5nLkludGVnZXIS4qCk94GHOAIAAUkABXZhbHVleHIAEGphdmEubGFuZy5OdW1iZXKGrJUdC5TgiwIAAHhwAAAAAXNxAH4AAgAAAAJzcQB+AAIAAAADc3IALHNjYWxhLmNvbGxlY3Rpb24uaW1tdXRhYmxlLkxpc3RTZXJpYWxpemVFbmQkilxjW/dTC20CAAB4cHg=") check(Nil)( "rO0ABXNyADJzY2FsYS5jb2xsZWN0aW9uLmltbXV0YWJsZS5MaXN0JFNlcmlhbGl6YXRpb25Qcm94eQAAAAAAAAABAwAAeHBzcgAsc2NhbGEuY29sbGVjdGlvbi5pbW11dGFibGUuTGlzdFNlcmlhbGl6ZUVuZCSKXGNb91MLbQIAAHhweA==") diff --git a/test/files/run/t8601-closure-elim.flags b/test/files/run/t8601-closure-elim.flags index 49d036a887..2b5fd8a7b2 100644 --- a/test/files/run/t8601-closure-elim.flags +++ b/test/files/run/t8601-closure-elim.flags @@ -1 +1 @@ --optimize +-optimize -Ydelambdafy:inline diff --git a/test/files/run/t8925.check b/test/files/run/t8925.check new file mode 100644 index 0000000000..112e7005df --- /dev/null +++ b/test/files/run/t8925.check @@ -0,0 +1,2 @@ +bar +abcd diff --git a/test/files/run/t8925.flags b/test/files/run/t8925.flags new file mode 100644 index 0000000000..be4ef0798a --- /dev/null +++ b/test/files/run/t8925.flags @@ -0,0 +1 @@ +-Ynooptimise -Yopt:l:none -Ybackend:GenBCode diff --git a/test/files/run/t8925.scala b/test/files/run/t8925.scala new file mode 100644 index 0000000000..33f4505f03 --- /dev/null +++ b/test/files/run/t8925.scala @@ -0,0 +1,31 @@ +object Ex { + def unapply(t: Throwable): Option[Throwable] = Some(t) +} + +class A { + var x = "" + + def bar = + try { + "bar" + } finally { + try { + x += "a" + } finally { + x += "b" + try { + x += "c" + throw null + } catch { + case Ex(_) => + x += "d" + } + } + } +} + +object Test extends App { + val a = new A + println(a.bar) + println(a.x) +} diff --git a/test/files/run/t8931.check b/test/files/run/t8931.check new file mode 100644 index 0000000000..d08546b5a9 --- /dev/null +++ b/test/files/run/t8931.check @@ -0,0 +1 @@ +List(interface B) diff --git a/test/files/run/t8931.scala b/test/files/run/t8931.scala new file mode 100644 index 0000000000..11718471bc --- /dev/null +++ b/test/files/run/t8931.scala @@ -0,0 +1,15 @@ + +trait A + +trait B extends A + +class C extends A with B + +object Test extends App { + val c = classOf[C] + + println(c.getGenericInterfaces.toList) + + assert(c.getGenericInterfaces.length == c.getInterfaces.length, + s"mismatch between ${c.getGenericInterfaces} and ${c.getInterfaces}") +} diff --git a/test/files/run/t8933.check b/test/files/run/t8933.check new file mode 100644 index 0000000000..d5ef468b98 --- /dev/null +++ b/test/files/run/t8933.check @@ -0,0 +1 @@ +'traitSymbol diff --git a/test/files/run/t8933/A_1.scala b/test/files/run/t8933/A_1.scala new file mode 100644 index 0000000000..996e3b4a2c --- /dev/null +++ b/test/files/run/t8933/A_1.scala @@ -0,0 +1,6 @@ +class MotherClass + +trait MixinWithSymbol { + self: MotherClass => + def symbolFromTrait: Symbol = 'traitSymbol +} diff --git a/test/files/run/t8933/Test_2.scala b/test/files/run/t8933/Test_2.scala new file mode 100644 index 0000000000..c506a7c51f --- /dev/null +++ b/test/files/run/t8933/Test_2.scala @@ -0,0 +1,10 @@ +class MotherClass extends MixinWithSymbol { + val classSymbol = 'classSymbol +} + +object Test { + def main(args: Array[String]) { + val symbol = (new MotherClass).symbolFromTrait + println(symbol) + } +} diff --git a/test/files/run/t8933b/A.scala b/test/files/run/t8933b/A.scala new file mode 100644 index 0000000000..d25d893c6f --- /dev/null +++ b/test/files/run/t8933b/A.scala @@ -0,0 +1,4 @@ +trait MixinWithSymbol { + self: MotherClass => + def symbolFromTrait: Any = 'traitSymbol +} diff --git a/test/files/run/t8933b/Test.scala b/test/files/run/t8933b/Test.scala new file mode 100644 index 0000000000..46eedd660f --- /dev/null +++ b/test/files/run/t8933b/Test.scala @@ -0,0 +1,9 @@ +class MotherClass extends MixinWithSymbol { + def foo = 'sym1 +} + +object Test { + def main(args: Array[String]) { + (new MotherClass).symbolFromTrait + } +} diff --git a/test/files/run/t8933c.scala b/test/files/run/t8933c.scala new file mode 100644 index 0000000000..22011bc323 --- /dev/null +++ b/test/files/run/t8933c.scala @@ -0,0 +1,14 @@ +object Test { + def main(args: Array[String]): Unit = { + try { + {throw T; Symbol}.apply("a") + assert(false, "exception not thrown") + } catch { + case T => // ok + case t: Throwable => + assert(false, "wrong not thrown: " + t) + } + } +} + +object T extends Throwable diff --git a/test/files/run/t8960.scala b/test/files/run/t8960.scala new file mode 100644 index 0000000000..a58ac53d33 --- /dev/null +++ b/test/files/run/t8960.scala @@ -0,0 +1,72 @@ +object Test extends App { + def test(o: AnyRef, sp: Boolean = false) = { + val isSpecialized = o.getClass.getSuperclass.getName contains "$sp" + val isDelambdafyMethod = o.getClass.getName contains "$lambda$" + assert( + // delambdafy:method doesn't currently emit specialized anonymous function classes + if (sp) (isSpecialized || isDelambdafyMethod) else !isSpecialized, + o.getClass.getName) + + val Some(f) = o.getClass.getDeclaredFields.find(_.getName == "serialVersionUID") + assert(f.getLong(null) == 0l) + } + + test(() => (), sp = true) + test(() => 1, sp = true) + test(() => "") + + test((x: Int) => x, sp = true) + test((x: Boolean) => x) + test((x: Int) => "") + + test((x1: Int, x2: Int) => 0d, sp = true) + test((x1: Int, x2: AnyRef) => 0d) + test((x1: Any, x2: Any) => x1) + + // scala> println((for (i <- 3 to 22) yield (for (j <- 1 to i) yield s"x$j: Int").mkString(" test((", ", ", ") => x1)")).mkString("\n")) + + test((x1: Int, x2: Int, x3: Int) => x1) + test((x1: Int, x2: Int, x3: Int, x4: Int) => x1) + test((x1: Int, x2: Int, x3: Int, x4: Int, x5: Int) => x1) + test((x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int) => x1) + test((x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int) => x1) + test((x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int) => x1) + test((x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int) => x1) + test((x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int) => x1) + test((x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int) => x1) + test((x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int) => x1) + test((x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int) => x1) + test((x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int) => x1) + test((x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int) => x1) + test((x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int) => x1) + test((x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int, x17: Int) => x1) + test((x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int, x17: Int, x18: Int) => x1) + test((x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int, x17: Int, x18: Int, x19: Int) => x1) + test((x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int, x17: Int, x18: Int, x19: Int, x20: Int) => x1) + test((x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int, x17: Int, x18: Int, x19: Int, x20: Int, x21: Int) => x1) + test((x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int, x17: Int, x18: Int, x19: Int, x20: Int, x21: Int, x22: Int) => x1) + + test({ + case x: Int => x + }: PartialFunction[Int, Int], sp = true) + + test({ + case x: Int => x + }: PartialFunction[Any, Any]) + + test({ + case x: Int => () + }: PartialFunction[Int, Unit], sp = true) + + test({ + case x: String => 1 + }: PartialFunction[String, Int]) + + test({ + case x: String => () + }: PartialFunction[String, Unit]) + + test({ + case x: String => x + }: PartialFunction[String, String]) +} |