diff options
Diffstat (limited to 'test')
158 files changed, 1893 insertions, 393 deletions
diff --git a/test/files/jvm/future-spec/FutureTests.scala b/test/files/jvm/future-spec/FutureTests.scala index 8674be168c..0efa83fbd9 100644 --- a/test/files/jvm/future-spec/FutureTests.scala +++ b/test/files/jvm/future-spec/FutureTests.scala @@ -70,7 +70,19 @@ object FutureTests extends MinimalScalaTest { //FIXME should check } } - + + "The default ExecutionContext" should { + "report uncaught exceptions" in { + val p = Promise[Throwable]() + val logThrowable: Throwable => Unit = p.trySuccess(_) + val ec: ExecutionContext = ExecutionContext.fromExecutor(null, logThrowable) + + val t = new NotImplementedError("foo") + val f = Future(throw t)(ec) + Await.result(p.future, 2.seconds) mustBe t + } + } + "A future with global ExecutionContext" should { import ExecutionContext.Implicits._ diff --git a/test/files/jvm/interpreter.check b/test/files/jvm/interpreter.check index 477096fb7e..44930c2932 100644 --- a/test/files/jvm/interpreter.check +++ b/test/files/jvm/interpreter.check @@ -97,7 +97,7 @@ scala> case class Bar(n: Int) defined class Bar scala> implicit def foo2bar(foo: Foo) = Bar(foo.n) -warning: there were 1 feature warnings; re-run with -feature for details +warning: there were 1 feature warning(s); re-run with -feature for details foo2bar: (foo: Foo)Bar scala> val bar: Bar = Foo(3) @@ -271,7 +271,7 @@ scala> xs map (x => x) res6: Array[_] = Array(1, 2) scala> xs map (x => (x, x)) -warning: there were 1 feature warnings; re-run with -feature for details +warning: there were 1 feature warning(s); re-run with -feature for details res7: Array[(_$1, _$1)] forSome { type _$1 } = Array((1,1), (2,2)) scala> diff --git a/test/files/jvm/patmat_opt_ignore_underscore.check b/test/files/jvm/patmat_opt_ignore_underscore.check new file mode 100644 index 0000000000..43f53aba12 --- /dev/null +++ b/test/files/jvm/patmat_opt_ignore_underscore.check @@ -0,0 +1 @@ +bytecode identical diff --git a/test/files/jvm/patmat_opt_ignore_underscore.flags b/test/files/jvm/patmat_opt_ignore_underscore.flags new file mode 100644 index 0000000000..1182725e86 --- /dev/null +++ b/test/files/jvm/patmat_opt_ignore_underscore.flags @@ -0,0 +1 @@ +-optimize
\ No newline at end of file diff --git a/test/files/jvm/patmat_opt_ignore_underscore/Analyzed_1.scala b/test/files/jvm/patmat_opt_ignore_underscore/Analyzed_1.scala new file mode 100644 index 0000000000..fa3639380d --- /dev/null +++ b/test/files/jvm/patmat_opt_ignore_underscore/Analyzed_1.scala @@ -0,0 +1,29 @@ +// this class's bytecode, compiled under -optimize is analyzed by the test +// method a's bytecode should be identical to method b's bytecode +// this is not the best test for shielding against regressing on this particular issue, +// but it sets the stage for checking the bytecode emitted by the pattern matcher and +// comparing it to manually tuned code using if/then/else etc. +class SameBytecode { + case class Foo(x: Any, y: String) + + def a = + Foo(1, "a") match { + case Foo(_: String, y) => y + } + + // this method's body holds the tree that should be generated by the pattern matcher for method a (-Xprint:patmat) + // the test checks that bytecode for a and b is identical (modulo line numbers) + // we can't diff trees as they are quite different (patmat uses jumps to labels that cannot be expressed in source, for example) + // note that the actual tree is quite bad: we do an unnecessary null check, isInstanceOf and local val (x3) + // some of these will be fixed soon (the initial null check is for the scrutinee, which is harder to fix in patmat) + def b: String = { + val x1 = Foo(1, "a") + if (x1.ne(null)) { + if (x1.x.isInstanceOf[String]) { + return x1.y + } + } + + throw new MatchError(x1) + } +}
\ No newline at end of file diff --git a/test/files/jvm/patmat_opt_ignore_underscore/test.scala b/test/files/jvm/patmat_opt_ignore_underscore/test.scala new file mode 100644 index 0000000000..6179101a7e --- /dev/null +++ b/test/files/jvm/patmat_opt_ignore_underscore/test.scala @@ -0,0 +1,15 @@ +import scala.tools.partest.BytecodeTest + +import scala.tools.nsc.util.JavaClassPath +import java.io.InputStream +import scala.tools.asm +import asm.ClassReader +import asm.tree.{ClassNode, InsnList} +import scala.collection.JavaConverters._ + +object Test extends BytecodeTest { + def show: Unit = { + val classNode = loadClassNode("SameBytecode") + sameBytecode(getMethod(classNode, "a"), getMethod(classNode, "b")) + } +} diff --git a/test/files/jvm/patmat_opt_no_nullcheck.check b/test/files/jvm/patmat_opt_no_nullcheck.check new file mode 100644 index 0000000000..43f53aba12 --- /dev/null +++ b/test/files/jvm/patmat_opt_no_nullcheck.check @@ -0,0 +1 @@ +bytecode identical diff --git a/test/files/jvm/patmat_opt_no_nullcheck.flags b/test/files/jvm/patmat_opt_no_nullcheck.flags new file mode 100644 index 0000000000..1182725e86 --- /dev/null +++ b/test/files/jvm/patmat_opt_no_nullcheck.flags @@ -0,0 +1 @@ +-optimize
\ No newline at end of file diff --git a/test/files/jvm/patmat_opt_no_nullcheck/Analyzed_1.scala b/test/files/jvm/patmat_opt_no_nullcheck/Analyzed_1.scala new file mode 100644 index 0000000000..3a594c401e --- /dev/null +++ b/test/files/jvm/patmat_opt_no_nullcheck/Analyzed_1.scala @@ -0,0 +1,24 @@ +// this class's bytecode, compiled under -optimize is analyzed by the test +// method a's bytecode should be identical to method b's bytecode +case class Foo(x: Any) + +class SameBytecode { + def a = + (Foo(1): Any) match { + case Foo(_: String) => + } + + // there's no null check + def b: Unit = { + val x1: Any = Foo(1) + if (x1.isInstanceOf[Foo]) { + val x3 = x1.asInstanceOf[Foo] + if (x3.x.isInstanceOf[String]) { + val x = () + return + } + } + + throw new MatchError(x1) + } +}
\ No newline at end of file diff --git a/test/files/jvm/patmat_opt_no_nullcheck/test.scala b/test/files/jvm/patmat_opt_no_nullcheck/test.scala new file mode 100644 index 0000000000..2927e763d5 --- /dev/null +++ b/test/files/jvm/patmat_opt_no_nullcheck/test.scala @@ -0,0 +1,8 @@ +import scala.tools.partest.BytecodeTest + +object Test extends BytecodeTest { + def show: Unit = { + val classNode = loadClassNode("SameBytecode") + sameBytecode(getMethod(classNode, "a"), getMethod(classNode, "b")) + } +} diff --git a/test/files/jvm/patmat_opt_primitive_typetest.check b/test/files/jvm/patmat_opt_primitive_typetest.check new file mode 100644 index 0000000000..43f53aba12 --- /dev/null +++ b/test/files/jvm/patmat_opt_primitive_typetest.check @@ -0,0 +1 @@ +bytecode identical diff --git a/test/files/jvm/patmat_opt_primitive_typetest.flags b/test/files/jvm/patmat_opt_primitive_typetest.flags new file mode 100644 index 0000000000..49d036a887 --- /dev/null +++ b/test/files/jvm/patmat_opt_primitive_typetest.flags @@ -0,0 +1 @@ +-optimize diff --git a/test/files/jvm/patmat_opt_primitive_typetest/Analyzed_1.scala b/test/files/jvm/patmat_opt_primitive_typetest/Analyzed_1.scala new file mode 100644 index 0000000000..e5db6c4dd0 --- /dev/null +++ b/test/files/jvm/patmat_opt_primitive_typetest/Analyzed_1.scala @@ -0,0 +1,24 @@ +// this class's bytecode, compiled under -optimize is analyzed by the test +// method a's bytecode should be identical to method b's bytecode +class SameBytecode { + case class Foo(x: Int, y: String) + + def a = + Foo(1, "a") match { + case Foo(_: Int, y) => y + } + + // this method's body holds the tree that should be generated by the pattern matcher for method a (-Xprint:patmat) + // the test checks that bytecode for a and b is identical (modulo line numbers) + // we can't diff trees as they are quite different (patmat uses jumps to labels that cannot be expressed in source, for example) + // note that the actual tree is quite bad: we do an unnecessary null check, and local val (x3) + // some of these will be fixed soon (the initial null check is for the scrutinee, which is harder to fix in patmat) + def b: String = { + val x1 = Foo(1, "a") + if (x1.ne(null)) { + return x1.y + } + + throw new MatchError(x1) + } +}
\ No newline at end of file diff --git a/test/files/jvm/patmat_opt_primitive_typetest/test.scala b/test/files/jvm/patmat_opt_primitive_typetest/test.scala new file mode 100644 index 0000000000..2927e763d5 --- /dev/null +++ b/test/files/jvm/patmat_opt_primitive_typetest/test.scala @@ -0,0 +1,8 @@ +import scala.tools.partest.BytecodeTest + +object Test extends BytecodeTest { + def show: Unit = { + val classNode = loadClassNode("SameBytecode") + sameBytecode(getMethod(classNode, "a"), getMethod(classNode, "b")) + } +} diff --git a/test/files/jvm/t6941.check b/test/files/jvm/t6941.check new file mode 100644 index 0000000000..43f53aba12 --- /dev/null +++ b/test/files/jvm/t6941.check @@ -0,0 +1 @@ +bytecode identical diff --git a/test/files/jvm/t6941.flags b/test/files/jvm/t6941.flags new file mode 100644 index 0000000000..49d036a887 --- /dev/null +++ b/test/files/jvm/t6941.flags @@ -0,0 +1 @@ +-optimize diff --git a/test/files/jvm/t6941/Analyzed_1.scala b/test/files/jvm/t6941/Analyzed_1.scala new file mode 100644 index 0000000000..549abd5e64 --- /dev/null +++ b/test/files/jvm/t6941/Analyzed_1.scala @@ -0,0 +1,11 @@ +// this class's bytecode, compiled under -optimize is analyzed by the test +// method a's bytecode should be identical to method b's bytecode +class SameBytecode { + def a(xs: List[Int]) = xs match { + case x :: _ => x + } + + def b(xs: List[Int]) = xs match { + case xs: ::[Int] => xs.hd$1 + } +}
\ No newline at end of file diff --git a/test/files/jvm/t6941/test.scala b/test/files/jvm/t6941/test.scala new file mode 100644 index 0000000000..248617f71f --- /dev/null +++ b/test/files/jvm/t6941/test.scala @@ -0,0 +1,15 @@ +import scala.tools.partest.BytecodeTest + +import scala.tools.nsc.util.JavaClassPath +import java.io.InputStream +import scala.tools.asm +import asm.ClassReader +import asm.tree.{ClassNode, InsnList} +import scala.collection.JavaConverters._ + +object Test extends BytecodeTest { + def show: Unit = { + val classNode = loadClassNode("SameBytecode") + similarBytecode(getMethod(classNode, "a"), getMethod(classNode, "b"), equalsModuloVar) + } +} diff --git a/test/files/lib/javac-artifacts.jar.desired.sha1 b/test/files/lib/javac-artifacts.jar.desired.sha1 deleted file mode 100644 index a49c986386..0000000000 --- a/test/files/lib/javac-artifacts.jar.desired.sha1 +++ /dev/null @@ -1 +0,0 @@ -61931a51bb1a2d308d214b96d06e9a8808515dcf ?javac-artifacts.jar diff --git a/test/files/neg/package-ob-case.check b/test/files/neg/package-ob-case.check index 9031ad13e7..063a120db1 100644 --- a/test/files/neg/package-ob-case.check +++ b/test/files/neg/package-ob-case.check @@ -2,8 +2,6 @@ package-ob-case.scala:3: warning: it is not recommended to define classes/object If possible, define class X in package foo instead. case class X(z: Int) { } ^ -package-ob-case.scala:3: error: implementation restriction: package object foo cannot contain case class X. Instead, class X should be placed directly in package foo. - case class X(z: Int) { } - ^ +error: No warnings can be incurred under -Xfatal-warnings. one warning found one error found diff --git a/test/files/neg/t5675.check b/test/files/neg/t5675.check new file mode 100644 index 0000000000..da608a2b78 --- /dev/null +++ b/test/files/neg/t5675.check @@ -0,0 +1,2 @@ +error: there were 1 feature warning(s); re-run with -feature for details +one error found diff --git a/test/files/neg/t5675.flags b/test/files/neg/t5675.flags new file mode 100644 index 0000000000..e8fb65d50c --- /dev/null +++ b/test/files/neg/t5675.flags @@ -0,0 +1 @@ +-Xfatal-warnings
\ No newline at end of file diff --git a/test/files/neg/t5675.scala b/test/files/neg/t5675.scala new file mode 100644 index 0000000000..238ed0fcae --- /dev/null +++ b/test/files/neg/t5675.scala @@ -0,0 +1,7 @@ +class PostFix { + val list = List(1, 2, 3) + def main(args: Array[String]) { + val a = list filter (2 !=) + val b = list filter (2 != _) + } +} diff --git a/test/files/neg/t5954.check b/test/files/neg/t5954.check index 3ca47cd430..3950d14e4e 100644 --- a/test/files/neg/t5954.check +++ b/test/files/neg/t5954.check @@ -1,16 +1,18 @@ -t5954.scala:36: error: implementation restriction: package object A cannot contain case class D. Instead, class D should be placed directly in package A. +t5954.scala:36: warning: class D should be placed directly in package A instead of package object A. Under some circumstances companion objects and case classes in package objects can fail to recompile. See https://issues.scala-lang.org/browse/SI-5954. case class D() ^ -t5954.scala:35: error: implementation restriction: package object A cannot contain companion object C. Instead, object C should be placed directly in package A. +t5954.scala:35: warning: object C should be placed directly in package A instead of package object A. Under some circumstances companion objects and case classes in package objects can fail to recompile. See https://issues.scala-lang.org/browse/SI-5954. object C ^ -t5954.scala:34: error: implementation restriction: package object A cannot contain companion trait C. Instead, trait C should be placed directly in package A. +t5954.scala:34: warning: trait C should be placed directly in package A instead of package object A. Under some circumstances companion objects and case classes in package objects can fail to recompile. See https://issues.scala-lang.org/browse/SI-5954. trait C ^ -t5954.scala:33: error: implementation restriction: package object A cannot contain companion object B. Instead, object B should be placed directly in package A. +t5954.scala:33: warning: object B should be placed directly in package A instead of package object A. Under some circumstances companion objects and case classes in package objects can fail to recompile. See https://issues.scala-lang.org/browse/SI-5954. object B ^ -t5954.scala:32: error: implementation restriction: package object A cannot contain companion class B. Instead, class B should be placed directly in package A. +t5954.scala:32: warning: class B should be placed directly in package A instead of package object A. Under some circumstances companion objects and case classes in package objects can fail to recompile. See https://issues.scala-lang.org/browse/SI-5954. class B ^ -5 errors found +error: No warnings can be incurred under -Xfatal-warnings. +5 warnings found +one error found diff --git a/test/files/neg/t5954.flags b/test/files/neg/t5954.flags new file mode 100644 index 0000000000..85d8eb2ba2 --- /dev/null +++ b/test/files/neg/t5954.flags @@ -0,0 +1 @@ +-Xfatal-warnings diff --git a/test/files/neg/t5954.scala b/test/files/neg/t5954.scala index 9e6f5392c7..3ccb5ed3ff 100644 --- a/test/files/neg/t5954.scala +++ b/test/files/neg/t5954.scala @@ -1,4 +1,4 @@ -// if you ever think you've fixed the underlying reason for the implementation restrictions +// if you ever think you've fixed the underlying reason for the warning // imposed by SI-5954, then here's a test that should pass with two "succes"es // //import scala.tools.partest._ diff --git a/test/files/neg/t6539/Macro_1.scala b/test/files/neg/t6539/Macro_1.scala index ed52776d95..4f7d289e2e 100644 --- a/test/files/neg/t6539/Macro_1.scala +++ b/test/files/neg/t6539/Macro_1.scala @@ -5,6 +5,6 @@ object M { def m(a: Any, b: Any): Any = macro mImpl def mImpl(c: Context)(a: c.Expr[Any], b: c.Expr[Any]) = a - @reflect.macros.compileTimeOnly("cto may only be used as an argument to " + "m") + @reflect.internal.annotations.compileTimeOnly("cto may only be used as an argument to " + "m") def cto = 0 } diff --git a/test/files/neg/t6539/Test_2.scala b/test/files/neg/t6539/Test_2.scala index 5a602879ec..26f4504222 100644 --- a/test/files/neg/t6539/Test_2.scala +++ b/test/files/neg/t6539/Test_2.scala @@ -3,4 +3,10 @@ object Test { M.m(M.cto, ()) // error M.m((), M.cto) // okay M.cto // error + + locally { + val expr = scala.reflect.runtime.universe.reify(2) + val splice = expr.splice + val value = expr.value + } } diff --git a/test/files/neg/t6666.check b/test/files/neg/t6666.check index d0378173ea..6337d4c7d9 100644 --- a/test/files/neg/t6666.check +++ b/test/files/neg/t6666.check @@ -16,25 +16,22 @@ t6666.scala:54: error: Implementation restriction: access of value x$7 in class t6666.scala:58: error: Implementation restriction: access of method x$8 in class C3 from anonymous class 9, would require illegal premature access to the unconstructed `this` of class C3 F.hof(() => x) ^ -t6666.scala:62: error: Implementation restriction: access of method x$9 in class C4 from object Nested$5, would require illegal premature access to the unconstructed `this` of class C4 +t6666.scala:62: error: Implementation restriction: access of method x$9 in class C4 from object Nested$4, would require illegal premature access to the unconstructed `this` of class C4 object Nested { def xx = x} ^ -t6666.scala:68: error: Implementation restriction: access of method x$10 in class C5 from object Nested$6, would require illegal premature access to the unconstructed `this` of class C5 - object Nested { def xx = x} - ^ -t6666.scala:83: error: Implementation restriction: access of method x$12 in class C11 from anonymous class 12, would require illegal premature access to the unconstructed `this` of class C11 +t6666.scala:76: error: Implementation restriction: access of method x$11 in class C11 from anonymous class 12, would require illegal premature access to the unconstructed `this` of class C11 F.byname(x) ^ -t6666.scala:102: error: Implementation restriction: access of method x$13 in class C13 from anonymous class 13, would require illegal premature access to the unconstructed `this` of class C13 +t6666.scala:95: error: Implementation restriction: access of method x$12 in class C13 from anonymous class 13, would require illegal premature access to the unconstructed `this` of class C13 F.hof(() => x) ^ -t6666.scala:111: error: Implementation restriction: access of method x$14 in class C14 from object Nested$7, would require illegal premature access to the unconstructed `this` of class C14 +t6666.scala:104: error: Implementation restriction: access of method x$13 in class C14 from object Nested$5, would require illegal premature access to the unconstructed `this` of class C14 object Nested { def xx = x} ^ -t6666.scala:122: error: Implementation restriction: access of method x$15 in class C15 from object Nested$8, would require illegal premature access to the unconstructed `this` of class C15 - object Nested { def xx = x} - ^ -t6666.scala:131: error: Implementation restriction: access of method foo$1 in class COuter from class CInner$1, would require illegal premature access to the unconstructed `this` of class COuter +t6666.scala:112: error: Implementation restriction: access of method foo$1 in class COuter from class CInner$1, would require illegal premature access to the unconstructed `this` of class COuter class CInner extends C({foo}) ^ -13 errors found +t6666.scala:118: error: Implementation restriction: access of method x$14 in class CEarly from object Nested$6, would require illegal premature access to the unconstructed `this` of class CEarly + object Nested { def xx = x} + ^ +12 errors found diff --git a/test/files/neg/t6666.scala b/test/files/neg/t6666.scala index d37ffaf141..1919ea3ca9 100644 --- a/test/files/neg/t6666.scala +++ b/test/files/neg/t6666.scala @@ -62,13 +62,6 @@ class C4 extends C({ object Nested { def xx = x} Nested.xx }) -class C5 extends C({ - def x = "".toString - val y = { - object Nested { def xx = x} - Nested.xx - } -}) // okay, for same reason as O6 class C6 extends C({ @@ -114,19 +107,15 @@ class C14(a: Any) { } } -class C15(a: Any) { - def this() = { - this({ - def x = "".toString - val y = { - object Nested { def xx = x} - Nested.xx - } - }) - } -} - class COuter extends C({ def foo = 0 class CInner extends C({foo}) -})
\ No newline at end of file +}) + + +class CEarly(a: Any) extends { + val early = {def x = "".toString + object Nested { def xx = x} + Nested.xx + } +} with AnyRef
\ No newline at end of file diff --git a/test/files/neg/t6666b.check b/test/files/neg/t6666b.check new file mode 100644 index 0000000000..c3ffc7cfa9 --- /dev/null +++ b/test/files/neg/t6666b.check @@ -0,0 +1,7 @@ +t6666b.scala:11: error: Implementation restriction: access of method x$1 in class C5 from object Nested$3, would require illegal premature access to the unconstructed `this` of class C5 + object Nested { def xx = x} + ^ +t6666b.scala:22: error: Implementation restriction: access of method x$2 in class C15 from object Nested$4, would require illegal premature access to the unconstructed `this` of class C15 + object Nested { def xx = x} + ^ +two errors found diff --git a/test/files/neg/t6666b.scala b/test/files/neg/t6666b.scala new file mode 100644 index 0000000000..205ded76e5 --- /dev/null +++ b/test/files/neg/t6666b.scala @@ -0,0 +1,27 @@ +class C(a: Any) +object F { + def byname(a: => Any) = println(a) + def hof(a: () => Any) = println(a()) +} + + +class C5 extends C({ + def x = "".toString + val y = { + object Nested { def xx = x} + Nested.xx + } +}) + + +class C15(a: Any) { + def this() = { + this({ + def x = "".toString + val y = { + object Nested { def xx = x} + Nested.xx + } + }) + } +} diff --git a/test/files/neg/t6666c.check b/test/files/neg/t6666c.check new file mode 100644 index 0000000000..8fb9f4ba14 --- /dev/null +++ b/test/files/neg/t6666c.check @@ -0,0 +1,10 @@ +t6666c.scala:2: error: Implementation restriction: access of method x$1 in class D from object X$4, would require illegal premature access to the unconstructed `this` of class D +class D extends C({def x = 0; object X { x }}) + ^ +t6666c.scala:5: error: Implementation restriction: access of method x$2 in class D1 from object X$5, would require illegal premature access to the unconstructed `this` of class D1 +class D1 extends C1({def x = 0; () => {object X { x }}}) + ^ +t6666c.scala:8: error: Implementation restriction: access of method x$3 from object X$6, would require illegal premature access to the unconstructed `this` of anonymous class 2 +class D2 extends C2({def x = 0; object X { x }}) + ^ +three errors found diff --git a/test/files/neg/t6666c.scala b/test/files/neg/t6666c.scala new file mode 100644 index 0000000000..76cc358307 --- /dev/null +++ b/test/files/neg/t6666c.scala @@ -0,0 +1,8 @@ +class C(a: Any) +class D extends C({def x = 0; object X { x }}) + +class C1(a: () => Any) +class D1 extends C1({def x = 0; () => {object X { x }}}) + +class C2(a: => Any) +class D2 extends C2({def x = 0; object X { x }}) diff --git a/test/files/neg/t6666d.check b/test/files/neg/t6666d.check new file mode 100644 index 0000000000..b4785f0129 --- /dev/null +++ b/test/files/neg/t6666d.check @@ -0,0 +1,4 @@ +t6666d.scala:7: error: Implementation restriction: access of object TreeOrd$1 from object TreeOrd$2, would require illegal premature access to the unconstructed `this` of class Test + implicit object TreeOrd extends Ordering[K](){ + ^ +one error found diff --git a/test/files/neg/t6666d.scala b/test/files/neg/t6666d.scala new file mode 100644 index 0000000000..49a688f91b --- /dev/null +++ b/test/files/neg/t6666d.scala @@ -0,0 +1,18 @@ + +import scala.collection.immutable.TreeMap +import scala.math.Ordering + +class Test[K](param:TreeMap[K,Int]){ + def this() = this({ + implicit object TreeOrd extends Ordering[K](){ + def compare(a: K, b: K) = { + -1 + } + } + new TreeMap[K, Int]() + }) +} + +object Test extends App { + new Test() +} diff --git a/test/files/neg/t6666e.check b/test/files/neg/t6666e.check new file mode 100644 index 0000000000..9fcc3ab718 --- /dev/null +++ b/test/files/neg/t6666e.check @@ -0,0 +1,4 @@ +t6666e.scala:8: error: Implementation restriction: anonymous class $anonfun requires premature access to class Crash. + this(Nil.collect{case x =>}) + ^ +one error found diff --git a/test/files/neg/t6666e.scala b/test/files/neg/t6666e.scala new file mode 100644 index 0000000000..120a5878b2 --- /dev/null +++ b/test/files/neg/t6666e.scala @@ -0,0 +1,9 @@ + +import scala.collection.immutable.TreeMap +import scala.math.Ordering + + +class Crash(a: Any) { + def this() = + this(Nil.collect{case x =>}) +} diff --git a/test/files/pos/SI-7060.flags b/test/files/pos/SI-7060.flags new file mode 100644 index 0000000000..c926ad6493 --- /dev/null +++ b/test/files/pos/SI-7060.flags @@ -0,0 +1 @@ +-Yinline -Ydead-code diff --git a/test/files/pos/SI-7060.scala b/test/files/pos/SI-7060.scala new file mode 100644 index 0000000000..c87620e020 --- /dev/null +++ b/test/files/pos/SI-7060.scala @@ -0,0 +1,11 @@ +object Test { + + @inline final def mbarray_apply_minibox(array: Any, tag: Byte): Long = + if (tag == 0) { + array.asInstanceOf[Array[Long]](0) + } else + array.asInstanceOf[Array[Byte]](0).toLong + + def crash_method(): Unit = + mbarray_apply_minibox(null, 0) +} diff --git a/test/files/pos/SI-7100.scala b/test/files/pos/SI-7100.scala new file mode 100644 index 0000000000..7cb6356ec8 --- /dev/null +++ b/test/files/pos/SI-7100.scala @@ -0,0 +1,6 @@ +class Buffer { + def f[@specialized(Int) T](): T = 0 match { + case 0 => 0.asInstanceOf[T] + case 1 => 0.asInstanceOf[T] + } +} diff --git a/test/files/pos/package-case.flags b/test/files/pos/package-case.flags deleted file mode 100644 index 2f174c4732..0000000000 --- a/test/files/pos/package-case.flags +++ /dev/null @@ -1 +0,0 @@ --Ycompanions-in-pkg-objs diff --git a/test/files/pos/t2130-1.flags b/test/files/pos/t2130-1.flags deleted file mode 100644 index 2f174c4732..0000000000 --- a/test/files/pos/t2130-1.flags +++ /dev/null @@ -1 +0,0 @@ --Ycompanions-in-pkg-objs diff --git a/test/files/pos/t2130-2.flags b/test/files/pos/t2130-2.flags deleted file mode 100644 index 2f174c4732..0000000000 --- a/test/files/pos/t2130-2.flags +++ /dev/null @@ -1 +0,0 @@ --Ycompanions-in-pkg-objs diff --git a/test/files/pos/t3999b.flags b/test/files/pos/t3999b.flags deleted file mode 100644 index 2f174c4732..0000000000 --- a/test/files/pos/t3999b.flags +++ /dev/null @@ -1 +0,0 @@ --Ycompanions-in-pkg-objs diff --git a/test/files/pos/t4052.flags b/test/files/pos/t4052.flags deleted file mode 100644 index 2f174c4732..0000000000 --- a/test/files/pos/t4052.flags +++ /dev/null @@ -1 +0,0 @@ --Ycompanions-in-pkg-objs diff --git a/test/files/pos/t5082.scala b/test/files/pos/t5082.scala new file mode 100644 index 0000000000..63eeda38ba --- /dev/null +++ b/test/files/pos/t5082.scala @@ -0,0 +1,14 @@ +trait Something[T] +object Test { class A } +case class Test() extends Something[Test.A] + +object User { + val Test() = Test() +} + +object Wrap { + trait Something[T] + object Test { class A } + case class Test(a: Int, b: Int)(c: String) extends Something[Test.A] + val Test(x, y) = Test(1, 2)(""); (x + y).toString +} diff --git a/test/files/pos/t6146.flags b/test/files/pos/t6146.flags new file mode 100644 index 0000000000..e8fb65d50c --- /dev/null +++ b/test/files/pos/t6146.flags @@ -0,0 +1 @@ +-Xfatal-warnings
\ No newline at end of file diff --git a/test/files/pos/t6146.scala b/test/files/pos/t6146.scala new file mode 100644 index 0000000000..b5bde826b1 --- /dev/null +++ b/test/files/pos/t6146.scala @@ -0,0 +1,60 @@ +// No unreachable or exhaustiveness warnings, please. + +// +// The reported bug +// + +trait AxisCompanion { + sealed trait Format + object Format { + case object Decimal extends Format + case object Integer extends Format + // Gives an unrelated warning: The outer reference in this type test cannot be checked at run time. + //final case class Time( hours: Boolean = false, millis: Boolean = true ) extends Format + } +} +object Axis extends AxisCompanion +class Axis { + import Axis._ + def test( f: Format ) = f match { + case Format.Integer => "Int" + // case Format.Time( hours, millis ) => "Time" + case Format.Decimal => "Dec" + } +} + + +// +// Some tricksier variations +// + +trait T1[X] { + trait T2[Y] { + sealed trait Format + object Format { + case object Decimal extends Format + case object Integer extends Format + } + } +} + +object O1 extends T1[Any] { + object O2 extends T2[Any] { + + } +} + +case object Shorty extends O1.O2.Format + +class Test1 { + import O1.O2._ + val FI: Format.Integer.type = Format.Integer + def test( f: Format ) = { + val ff: f.type = f + ff match { + case FI => "Int" + case Format.Decimal => "Dec" + case Shorty => "Sho" + } + } +} diff --git a/test/files/pos/t7022.scala b/test/files/pos/t7022.scala new file mode 100644 index 0000000000..0609e2d250 --- /dev/null +++ b/test/files/pos/t7022.scala @@ -0,0 +1,9 @@ +class Catch[+T] { + def either[U >: T](body: => U): Either[Throwable, U] = ??? +} + +object Test { + implicit class RichCatch[T](val c: Catch[T]) extends AnyVal { + def validation[U >: T](u: => U): Either[Throwable, U] = c.either(u) + } +} diff --git a/test/files/pos/t7033.scala b/test/files/pos/t7033.scala new file mode 100644 index 0000000000..a4d256673b --- /dev/null +++ b/test/files/pos/t7033.scala @@ -0,0 +1,15 @@ +import language.higherKinds +object Wrap { + implicit class X[X](val a: X) + + X[Int](0) +} + +class Wrap { + implicit class Y[Y](val a: Y) + Y[Int](0) + implicit class Z[Z[_]](val a: Z[Wrap.this.Z[Z]]) + Z[List](List(new Z[List](null))) +} + +case class X[X](val a: X) diff --git a/test/files/presentation/doc.check b/test/files/presentation/doc.check index 62b3bfc2e3..e33756773d 100755..100644 --- a/test/files/presentation/doc.check +++ b/test/files/presentation/doc.check @@ -1,3 +1,4 @@ +reload: Test.scala body:Body(List(Paragraph(Chain(List(Summary(Chain(List(Text(This is a test comment), Text(.)))), Text( )))))) @example:Body(List(Paragraph(Chain(List(Summary(Monospace(Text("abb".permutations = Iterator(abb, bab, bba))))))))) diff --git a/test/files/presentation/doc.scala b/test/files/presentation/doc/doc.scala index 4b0d6baa1f..21eabeb284 100755 --- a/test/files/presentation/doc.scala +++ b/test/files/presentation/doc/doc.scala @@ -1,5 +1,5 @@ import scala.tools.nsc.doc -import scala.tools.nsc.doc.base.LinkTo +import scala.tools.nsc.doc.base._ import scala.tools.nsc.doc.base.comment._ import scala.tools.nsc.interactive._ import scala.tools.nsc.interactive.tests._ @@ -28,12 +28,39 @@ object Test extends InteractiveTest { |trait Commented {} |class User(c: %sCommented)""".stripMargin.format(comment, tags take nTags mkString "\n", caret) - override def main(args: Array[String]) { - val documenter = new Doc(settings) { - val global: compiler.type = compiler + override lazy val compiler = { + new { + override val settings = { + prepareSettings(Test.this.settings) + Test.this.settings + } + } with Global(settings, compilerReporter) with MemberLookupBase with CommentFactoryBase { + outer => + val global: this.type = this def chooseLink(links: List[LinkTo]): LinkTo = links.head + def internalLink(sym: Symbol, site: Symbol) = None + def toString(link: LinkTo) = link.toString + + override lazy val analyzer = new { + val global: outer.type = outer + } with doc.ScaladocAnalyzer + + def getComment(sym: Symbol, source: SourceFile) = { + val docResponse = new Response[(String, String, Position)] + askDocComment(sym, sym.owner, source, docResponse) + docResponse.get.left.toOption flatMap { + case (expanded, raw, pos) => + if (expanded.isEmpty) + None + else + Some(ask { () => parseAtSymbol(expanded, raw, pos, Some(sym.owner)) }) + } + } } + } + + override def runDefaultTests() { for (i <- 1 to tags.length) { val markedText = text(i) val idx = markedText.indexOf(caret) @@ -52,18 +79,17 @@ object Test extends InteractiveTest { treeResponse.get.left.toOption match { case Some(tree) => val sym = tree.tpe.typeSymbol - documenter.retrieve(sym, sym.owner) match { - case Some(HtmlResult(comment)) => - import comment._ - val tags: List[(String, Iterable[Body])] = - List(("@example", example), ("@version", version), ("@since", since.toList), ("@todo", todo), ("@note", note), ("@see", see)) - val str = ("body:" + body + "\n") + - tags.map{ case (name, bodies) => name + ":" + bodies.mkString("\n") }.mkString("\n") - reporter.println(str) - case Some(_) => reporter.println("Got unexpected result") - case None => reporter.println("Got no result") + compiler.getComment(sym, batch) match { + case None => println("Got no doc comment") + case Some(comment) => + import comment._ + val tags: List[(String, Iterable[Body])] = + List(("@example", example), ("@version", version), ("@since", since.toList), ("@todo", todo), ("@note", note), ("@see", see)) + val str = ("body:" + body + "\n") + + tags.map{ case (name, bodies) => name + ":" + bodies.mkString("\n") }.mkString("\n") + println(str) } - case None => reporter.println("Couldn't find a typedTree") + case None => println("Couldn't find a typedTree") } } } diff --git a/test/files/presentation/ide-t1001326.check b/test/files/presentation/ide-t1001326.check new file mode 100644 index 0000000000..0ac15faed4 --- /dev/null +++ b/test/files/presentation/ide-t1001326.check @@ -0,0 +1,4 @@ +Unique OK +Unattributed OK +NeverModify OK +AlwaysParseTree OK
\ No newline at end of file diff --git a/test/files/presentation/ide-t1001326/Test.scala b/test/files/presentation/ide-t1001326/Test.scala new file mode 100644 index 0000000000..3091da4b40 --- /dev/null +++ b/test/files/presentation/ide-t1001326/Test.scala @@ -0,0 +1,91 @@ +import scala.tools.nsc.interactive.tests.InteractiveTest +import scala.reflect.internal.util.SourceFile +import scala.tools.nsc.interactive.Response + +object Test extends InteractiveTest { + + override def execute(): Unit = { + val sf = sourceFiles.find(_.file.name == "A.scala").head + uniqueParseTree_t1001326(sf) + unattributedParseTree_t1001326(sf) + neverModifyParseTree_t1001326(sf) + shouldAlwaysReturnParseTree_t1001326(sf) + } + + /** + * Asking twice for a parseTree on the same source should always return a new tree + */ + private def uniqueParseTree_t1001326(sf: SourceFile) { + val parseTree1 = compiler.parseTree(sf) + val parseTree2 = compiler.parseTree(sf) + if (parseTree1 != parseTree2) { + reporter.println("Unique OK") + } else { + reporter.println("Unique FAILED") + } + } + + /** + * A parseTree should never contain any symbols or types + */ + private def unattributedParseTree_t1001326(sf: SourceFile) { + if (noSymbolsOrTypes(compiler.parseTree(sf))) { + reporter.println("Unattributed OK") + } else { + reporter.println("Unattributed FAILED") + } + } + + /** + * Once you have obtained a parseTree it should never change + */ + private def neverModifyParseTree_t1001326(sf: SourceFile) { + val parsedTree = compiler.parseTree(sf) + loadSourceAndWaitUntilTypechecked(sf) + if (noSymbolsOrTypes(parsedTree)) { + reporter.println("NeverModify OK") + } else { + reporter.println("NeverModify FAILED") + } + } + + /** + * Should always return a parse tree + */ + private def shouldAlwaysReturnParseTree_t1001326(sf: SourceFile) { + loadSourceAndWaitUntilTypechecked(sf) + if (noSymbolsOrTypes(compiler.parseTree(sf))) { + reporter.println("AlwaysParseTree OK") + } else { + reporter.println("AlwaysParseTree FAILED") + } + } + + /** + * Load a source and block while it is type-checking. + */ + private def loadSourceAndWaitUntilTypechecked(sf: SourceFile): Unit = { + compiler.askToDoFirst(sf) + val res = new Response[Unit] + compiler.askReload(List(sf), res) + res.get + askLoadedTyped(sf).get + } + + /** + * Traverses a tree and makes sure that there are no types or symbols present in the tree with + * the exception of the symbol for the package 'scala'. This is because that symbol will be + * present in some of the nodes that the compiler generates. + */ + private def noSymbolsOrTypes(tree: compiler.Tree): Boolean = { + tree.forAll { t => + (t.symbol == null || + t.symbol == compiler.NoSymbol || + t.symbol == compiler.definitions.ScalaPackage // ignore the symbol for the scala package for now + ) && ( + t.tpe == null || + t.tpe == compiler.NoType) + } + } + +}
\ No newline at end of file diff --git a/test/files/presentation/ide-t1001326/src/a/A.scala b/test/files/presentation/ide-t1001326/src/a/A.scala new file mode 100644 index 0000000000..c82ca02231 --- /dev/null +++ b/test/files/presentation/ide-t1001326/src/a/A.scala @@ -0,0 +1,5 @@ +package a + +class A { + def foo(s: String) = s + s +}
\ No newline at end of file diff --git a/test/files/run/class-symbol-contravariant.check b/test/files/run/class-symbol-contravariant.check new file mode 100644 index 0000000000..987f215bca --- /dev/null +++ b/test/files/run/class-symbol-contravariant.check @@ -0,0 +1,36 @@ +Type in expressions to have them evaluated. +Type :help for more information. + +scala> :power +** Power User mode enabled - BEEP WHIR GYVE ** +** :phase has been set to 'typer'. ** +** scala.tools.nsc._ has been imported ** +** global._, definitions._ also imported ** +** Try :help, :vals, power.<tab> ** + +scala> val u = rootMirror.universe +u: $r.intp.global.type = <global> + +scala> import u._, scala.reflect.internal.Flags +import u._ +import scala.reflect.internal.Flags + +scala> class C +defined class C + +scala> val sym = u.typeOf[C].typeSymbol +sym: u.Symbol = class C + +scala> sym.isContravariant +res0: Boolean = false + +scala> sym setFlag Flags.INCONSTRUCTOR +res1: sym.type = class C + +scala> sym.isClassLocalToConstructor +res2: Boolean = true + +scala> sym.isContravariant // was true +res3: Boolean = false + +scala> diff --git a/test/files/run/class-symbol-contravariant.scala b/test/files/run/class-symbol-contravariant.scala new file mode 100644 index 0000000000..6a84944e3b --- /dev/null +++ b/test/files/run/class-symbol-contravariant.scala @@ -0,0 +1,15 @@ +import scala.tools.partest.ReplTest + +object Test extends ReplTest { + override def code = """ + |:power + |val u = rootMirror.universe + |import u._, scala.reflect.internal.Flags + |class C + |val sym = u.typeOf[C].typeSymbol + |sym.isContravariant + |sym setFlag Flags.INCONSTRUCTOR + |sym.isClassLocalToConstructor + |sym.isContravariant // was true + |""".stripMargin.trim +}
\ No newline at end of file diff --git a/test/files/run/constrained-types.check b/test/files/run/constrained-types.check index d4b8692fa3..8b53e2391d 100644 --- a/test/files/run/constrained-types.check +++ b/test/files/run/constrained-types.check @@ -75,11 +75,11 @@ scala> var four = "four" four: String = four scala> val four2 = m(four) // should have an existential bound -warning: there were 1 feature warnings; re-run with -feature for details +warning: there were 1 feature warning(s); re-run with -feature for details four2: String @Annot(x) forSome { val x: String } = four scala> val four3 = four2 // should have the same type as four2 -warning: there were 1 feature warnings; re-run with -feature for details +warning: there were 1 feature warning(s); re-run with -feature for details four3: String @Annot(x) forSome { val x: String } = four scala> val stuff = m("stuff") // should not crash @@ -102,7 +102,7 @@ scala> def m = { val y : String @Annot(x) = x y } // x should not escape the local scope with a narrow type -warning: there were 1 feature warnings; re-run with -feature for details +warning: there were 1 feature warning(s); re-run with -feature for details m: String @Annot(x) forSome { val x: String } scala> @@ -116,7 +116,7 @@ scala> def n(y: String) = { } m("stuff".stripMargin) } // x should be existentially bound -warning: there were 1 feature warnings; re-run with -feature for details +warning: there were 1 feature warning(s); re-run with -feature for details n: (y: String)String @Annot(x) forSome { val x: String } scala> diff --git a/test/files/run/freetypes_false_alarm1.check b/test/files/run/freetypes_false_alarm1.check index a9df3544ac..085b3ee50b 100644 --- a/test/files/run/freetypes_false_alarm1.check +++ b/test/files/run/freetypes_false_alarm1.check @@ -1 +1 @@ -List[Int] +scala.List[Int] diff --git a/test/files/run/idempotency-case-classes.check b/test/files/run/idempotency-case-classes.check index 80d178cba3..e0453883ff 100644 --- a/test/files/run/idempotency-case-classes.check +++ b/test/files/run/idempotency-case-classes.check @@ -50,6 +50,6 @@ C(2,3) Some.apply[(Int, Int)](Tuple2.apply[Int, Int](x$0.x, x$0.y)); <synthetic> private def readResolve(): Object = C }; - scala.this.Predef.println(C.apply(2, 3)) + Predef.println(C.apply(2, 3)) } error! diff --git a/test/files/run/idempotency-lazy-vals.check b/test/files/run/idempotency-lazy-vals.check index 4dcbf96184..15afa5303c 100644 --- a/test/files/run/idempotency-lazy-vals.check +++ b/test/files/run/idempotency-lazy-vals.check @@ -18,6 +18,6 @@ }; val c: C = new C(); import c._; - c.x.*(scala.this.Predef.implicitly[Int](c.y)) + c.x.*(Predef.implicitly[Int](c.y)) } error! diff --git a/test/files/run/idempotency-partial-functions.scala b/test/files/run/idempotency-partial-functions.scala deleted file mode 100644 index dd5f1167f1..0000000000 --- a/test/files/run/idempotency-partial-functions.scala +++ /dev/null @@ -1,25 +0,0 @@ -import scala.reflect.runtime.universe._ -import scala.reflect.runtime.{currentMirror => cm} -import scala.tools.reflect.{ToolBox, ToolBoxError} -import scala.tools.reflect.Eval - -object Test extends App { - val partials = reify { - List((false,true)) collect { case (x,true) => x } - } - try { - println(partials.eval) - } catch { - case _: ToolBoxError => println("error!!") - } - try { - val tb = cm.mkToolBox() - val tpartials = tb.typeCheck(partials.tree) - println(tpartials) - val rtpartials = tb.resetAllAttrs(tpartials) - println(tb.eval(rtpartials)) - } catch { - // this is the current behaviour, rather than the desired behavior; see SI-6187 - case _: ToolBoxError => println("error!") - } -}
\ No newline at end of file diff --git a/test/files/run/idempotency-this.check b/test/files/run/idempotency-this.check index efabaf1ec4..88b8288adf 100644 --- a/test/files/run/idempotency-this.check +++ b/test/files/run/idempotency-this.check @@ -1,4 +1,4 @@ List() -immutable.this.List.apply[String]("") -Apply(TypeApply(Select(Select(This(TypeName("immutable")), scala.collection.immutable.List), TermName("apply")), List(TypeTree().setOriginal(Ident(TypeName("String"))))), List(Literal(Constant("")))) -error! +List.apply[String]("") +Apply(TypeApply(Select(Ident(scala.collection.immutable.List), TermName("apply")), List(TypeTree().setOriginal(Select(Ident(scala.Predef), TypeName("String"))))), List(Literal(Constant("")))) +List() diff --git a/test/files/run/inline-ex-handlers.check b/test/files/run/inline-ex-handlers.check index 282542a732..f2f0b60687 100644 --- a/test/files/run/inline-ex-handlers.check +++ b/test/files/run/inline-ex-handlers.check @@ -21,59 +21,60 @@ < 92 JUMP 7 < < 7: -395c391 +391c387 < locals: value args, variable result, value ex6, value x4, value x5, value message, value x --- > locals: value args, variable result, value ex6, value x4, value x5, value x -397c393 -< blocks: [1,2,3,4,5,8,11,13,14,16] +393c389 +< blocks: [1,2,3,4,5,8,10,11,13] --- -> blocks: [1,2,3,5,8,11,13,14,16,17] -421c417,426 +> blocks: [1,2,3,5,8,10,11,13,14] +417c413,422 < 103 THROW(MyException) --- > ? STORE_LOCAL(value ex6) -> ? JUMP 17 +> ? JUMP 14 > -> 17: +> 14: > 101 LOAD_LOCAL(value ex6) > 101 STORE_LOCAL(value x4) > 101 SCOPE_ENTER value x4 > 106 LOAD_LOCAL(value x4) > 106 IS_INSTANCE REF(class MyException) -> 106 CZJUMP (BOOL)NE ? 5 : 11 -434,436d438 +> 106 CZJUMP (BOOL)NE ? 5 : 8 +430,432d434 < 101 JUMP 4 < < 4: -450,453d451 +442,445d443 < 106 LOAD_LOCAL(value x5) < 106 CALL_METHOD MyException.message (dynamic) < 106 STORE_LOCAL(value message) < 106 SCOPE_ENTER value message -455c453,454 +447c445,446 < 106 LOAD_LOCAL(value message) --- > ? LOAD_LOCAL(value x5) > 106 CALL_METHOD MyException.message (dynamic) -527c526 +519c518 < blocks: [1,2,3,4,6,7,8,9,10] --- > blocks: [1,2,3,4,6,7,8,9,10,11,12,13] -556c555,560 +548c547 < 306 THROW(MyException) --- > ? JUMP 11 -> +549a549,553 > 11: > ? LOAD_LOCAL(variable monitor4) > 305 MONITOR_EXIT > ? JUMP 12 -562c566 +> +554c558 < ? THROW(Throwable) --- > ? JUMP 12 -568c572,579 +560c564,571 < ? THROW(Throwable) --- > ? STORE_LOCAL(value t) @@ -84,7 +85,7 @@ > 304 MONITOR_EXIT > ? STORE_LOCAL(value t) > ? JUMP 13 -583a595,606 +575a587,598 > 13: > 310 LOAD_MODULE object Predef > 310 CALL_PRIMITIVE(StartConcat) @@ -97,35 +98,35 @@ > 310 CALL_METHOD scala.Predef.println (dynamic) > 310 JUMP 2 > -592c615 +584c607 < catch (Throwable) in ArrayBuffer(7, 8, 9, 10) starting at: 6 --- > catch (Throwable) in ArrayBuffer(7, 8, 9, 10, 11) starting at: 6 -595c618 +587c610 < catch (Throwable) in ArrayBuffer(4, 6, 7, 8, 9, 10) starting at: 3 --- > catch (Throwable) in ArrayBuffer(4, 6, 7, 8, 9, 10, 11, 12) starting at: 3 -627c650 +619c642 < blocks: [1,2,3,4,5,6,7,9,10] --- > blocks: [1,2,3,4,5,6,7,9,10,11,12] -651c674,675 +643c666,667 < 78 THROW(IllegalArgumentException) --- > ? STORE_LOCAL(value e) > ? JUMP 11 -652a677,681 +644a669,673 > 11: > 81 LOAD_LOCAL(value e) > ? STORE_LOCAL(variable exc1) > ? JUMP 12 > -680c709,710 +672c701,702 < 81 THROW(Exception) --- > ? STORE_LOCAL(variable exc1) > ? JUMP 12 -696a727,739 +688a719,731 > 12: > 83 LOAD_MODULE object Predef > 83 CONSTANT("finally") @@ -139,88 +140,88 @@ > 84 LOAD_LOCAL(variable exc1) > 84 THROW(Throwable) > -702c745 +694c737 < catch (<none>) in ArrayBuffer(4, 6, 7, 9) starting at: 3 --- > catch (<none>) in ArrayBuffer(4, 6, 7, 9, 11) starting at: 3 -726c769 +718c761 < locals: value args, variable result, value ex6, variable exc2, value x4, value x5, value message, value x, value ex6, value x4, value x5, value message, value x --- > locals: value args, variable result, value ex6, variable exc2, value x4, value x5, value x, value ex6, value x4, value x5, value x -728c771 -< blocks: [1,2,3,4,5,6,9,12,14,17,18,19,22,25,27,28,30,31] +720c763 +< blocks: [1,2,3,4,5,6,9,11,14,15,16,19,21,22,24,25] --- -> blocks: [1,2,3,4,5,6,9,12,14,17,18,19,22,25,27,28,30,31,32,33,34] -752c795,802 +> blocks: [1,2,3,4,5,6,9,11,14,15,16,19,21,22,24,25,26,27,28] +744c787,794 < 172 THROW(MyException) --- > ? STORE_LOCAL(value ex6) -> ? JUMP 32 +> ? JUMP 26 > -> 32: +> 26: > 170 LOAD_LOCAL(value ex6) > 170 STORE_LOCAL(value x4) > 170 SCOPE_ENTER value x4 -> 170 JUMP 18 -799,802d848 +> 170 JUMP 15 +787,790d836 < 175 LOAD_LOCAL(value x5) < 175 CALL_METHOD MyException.message (dynamic) < 175 STORE_LOCAL(value message) < 175 SCOPE_ENTER value message -804c850,851 +792c838,839 < 176 LOAD_LOCAL(value message) --- > ? LOAD_LOCAL(value x5) > 176 CALL_METHOD MyException.message (dynamic) -808c855,856 +796c843,844 < 177 LOAD_LOCAL(value message) --- > ? LOAD_LOCAL(value x5) > 177 CALL_METHOD MyException.message (dynamic) -810c858,859 +798c846,847 < 177 THROW(MyException) --- > ? STORE_LOCAL(value ex6) -> ? JUMP 33 -814c863,864 +> ? JUMP 27 +802c851,852 < 170 THROW(Throwable) --- > ? STORE_LOCAL(value ex6) -> ? JUMP 33 -823a874,879 -> 33: +> ? JUMP 27 +811a862,867 +> 27: > 169 LOAD_LOCAL(value ex6) > 169 STORE_LOCAL(value x4) > 169 SCOPE_ENTER value x4 > 169 JUMP 5 > -838,841d893 +822,825d877 < 180 LOAD_LOCAL(value x5) < 180 CALL_METHOD MyException.message (dynamic) < 180 STORE_LOCAL(value message) < 180 SCOPE_ENTER value message -843c895,896 +827c879,880 < 181 LOAD_LOCAL(value message) --- > ? LOAD_LOCAL(value x5) > 181 CALL_METHOD MyException.message (dynamic) -847c900,901 +831c884,885 < 182 LOAD_LOCAL(value message) --- > ? LOAD_LOCAL(value x5) > 182 CALL_METHOD MyException.message (dynamic) -849c903,904 +833c887,888 < 182 THROW(MyException) --- > ? STORE_LOCAL(variable exc2) -> ? JUMP 34 -853c908,909 +> ? JUMP 28 +837c892,893 < 169 THROW(Throwable) --- > ? STORE_LOCAL(variable exc2) -> ? JUMP 34 -869a926,938 -> 34: +> ? JUMP 28 +853a910,922 +> 28: > 184 LOAD_MODULE object Predef > 184 CONSTANT("finally") > 184 CALL_METHOD scala.Predef.println (dynamic) @@ -233,159 +234,158 @@ > 185 LOAD_LOCAL(variable exc2) > 185 THROW(Throwable) > -875c944 -< catch (Throwable) in ArrayBuffer(17, 18, 19, 22, 25, 27, 28, 30) starting at: 4 +859c928 +< catch (Throwable) in ArrayBuffer(14, 15, 16, 19, 21, 22, 24) starting at: 4 --- -> catch (Throwable) in ArrayBuffer(17, 18, 19, 22, 25, 27, 28, 30, 32) starting at: 4 -878c947 -< catch (<none>) in ArrayBuffer(4, 5, 6, 9, 12, 17, 18, 19, 22, 25, 27, 28, 30) starting at: 3 +> catch (Throwable) in ArrayBuffer(14, 15, 16, 19, 21, 22, 24, 26) starting at: 4 +862c931 +< catch (<none>) in ArrayBuffer(4, 5, 6, 9, 14, 15, 16, 19, 21, 22, 24) starting at: 3 --- -> catch (<none>) in ArrayBuffer(4, 5, 6, 9, 12, 17, 18, 19, 22, 25, 27, 28, 30, 32, 33) starting at: 3 -902c971 +> catch (<none>) in ArrayBuffer(4, 5, 6, 9, 14, 15, 16, 19, 21, 22, 24, 26, 27) starting at: 3 +886c955 < locals: value args, variable result, value e, value ex6, value x4, value x5, value message, value x --- > locals: value args, variable result, value e, value ex6, value x4, value x5, value x -904c973 -< blocks: [1,2,3,6,7,8,11,14,16,17,19] +888c957 +< blocks: [1,2,3,6,7,8,11,13,14,16] --- -> blocks: [1,2,3,6,7,8,11,14,16,17,19,20] -928c997,1004 +> blocks: [1,2,3,6,7,8,11,13,14,16,17] +912c981,988 < 124 THROW(MyException) --- > ? STORE_LOCAL(value ex6) -> ? JUMP 20 +> ? JUMP 17 > -> 20: +> 17: > 122 LOAD_LOCAL(value ex6) > 122 STORE_LOCAL(value x4) > 122 SCOPE_ENTER value x4 > 122 JUMP 7 -957,960d1032 +937,940d1012 < 127 LOAD_LOCAL(value x5) < 127 CALL_METHOD MyException.message (dynamic) < 127 STORE_LOCAL(value message) < 127 SCOPE_ENTER value message -962c1034,1035 +942c1014,1015 < 127 LOAD_LOCAL(value message) --- > ? LOAD_LOCAL(value x5) > 127 CALL_METHOD MyException.message (dynamic) -991c1064 -< catch (IllegalArgumentException) in ArrayBuffer(6, 7, 8, 11, 14, 16, 17, 19) starting at: 3 +971c1044 +< catch (IllegalArgumentException) in ArrayBuffer(6, 7, 8, 11, 13, 14, 16) starting at: 3 --- -> catch (IllegalArgumentException) in ArrayBuffer(6, 7, 8, 11, 14, 16, 17, 19, 20) starting at: 3 -1015c1088 +> catch (IllegalArgumentException) in ArrayBuffer(6, 7, 8, 11, 13, 14, 16, 17) starting at: 3 +995c1068 < locals: value args, variable result, value ex6, value x4, value x5, value message, value x, value e --- > locals: value args, variable result, value ex6, value x4, value x5, value x, value e -1017c1090 -< blocks: [1,2,3,4,5,8,11,15,16,17,19] +997c1070 +< blocks: [1,2,3,4,5,8,12,13,14,16] --- -> blocks: [1,2,3,5,8,11,15,16,17,19,20] -1041c1114,1123 +> blocks: [1,2,3,5,8,12,13,14,16,17] +1021c1094,1103 < 148 THROW(MyException) --- > ? STORE_LOCAL(value ex6) -> ? JUMP 20 +> ? JUMP 17 > -> 20: +> 17: > 145 LOAD_LOCAL(value ex6) > 145 STORE_LOCAL(value x4) > 145 SCOPE_ENTER value x4 > 154 LOAD_LOCAL(value x4) > 154 IS_INSTANCE REF(class MyException) -> 154 CZJUMP (BOOL)NE ? 5 : 11 -1062,1064d1143 +> 154 CZJUMP (BOOL)NE ? 5 : 8 +1042,1044d1123 < 145 JUMP 4 < < 4: -1078,1081d1156 +1054,1057d1132 < 154 LOAD_LOCAL(value x5) < 154 CALL_METHOD MyException.message (dynamic) < 154 STORE_LOCAL(value message) < 154 SCOPE_ENTER value message -1083c1158,1159 +1059c1134,1135 < 154 LOAD_LOCAL(value message) --- > ? LOAD_LOCAL(value x5) > 154 CALL_METHOD MyException.message (dynamic) -1300c1376 +1276c1352 < blocks: [1,2,3,4,5,7] --- > blocks: [1,2,3,4,5,7,8] -1324c1400,1401 +1300c1376,1383 < 38 THROW(IllegalArgumentException) --- > ? STORE_LOCAL(value e) > ? JUMP 8 -1325a1403,1408 +> > 8: > 42 LOAD_MODULE object Predef > 42 CONSTANT("IllegalArgumentException") > 42 CALL_METHOD scala.Predef.println (dynamic) > 42 JUMP 2 -> -1371c1454 +1347c1430 < locals: value args, variable result, value ex6, value x4, value x5, value message, value x --- > locals: value args, variable result, value ex6, value x4, value x5, value x -1373c1456 -< blocks: [1,2,3,4,5,8,11,13,14,16,17,19] +1349c1432 +< blocks: [1,2,3,4,5,8,10,11,13,14,16] --- -> blocks: [1,2,3,5,8,11,13,14,16,17,19,20] -1397c1480,1481 +> blocks: [1,2,3,5,8,10,11,13,14,16,17] +1373c1456,1457 < 203 THROW(MyException) --- > ? STORE_LOCAL(value ex6) -> ? JUMP 20 -1417c1501,1510 +> ? JUMP 17 +1393c1477,1486 < 209 THROW(MyException) --- > ? STORE_LOCAL(value ex6) -> ? JUMP 20 +> ? JUMP 17 > -> 20: +> 17: > 200 LOAD_LOCAL(value ex6) > 200 STORE_LOCAL(value x4) > 200 SCOPE_ENTER value x4 > 212 LOAD_LOCAL(value x4) > 212 IS_INSTANCE REF(class MyException) -> 212 CZJUMP (BOOL)NE ? 5 : 11 -1430,1432d1522 +> 212 CZJUMP (BOOL)NE ? 5 : 8 +1406,1408d1498 < 200 JUMP 4 < < 4: -1446,1449d1535 +1418,1421d1507 < 212 LOAD_LOCAL(value x5) < 212 CALL_METHOD MyException.message (dynamic) < 212 STORE_LOCAL(value message) < 212 SCOPE_ENTER value message -1451c1537,1538 +1423c1509,1510 < 213 LOAD_LOCAL(value message) --- > ? LOAD_LOCAL(value x5) > 213 CALL_METHOD MyException.message (dynamic) -1495c1582 +1467c1554 < blocks: [1,2,3,4,5,7] --- > blocks: [1,2,3,4,5,7,8] -1519c1606,1607 +1491c1578,1579 < 58 THROW(IllegalArgumentException) --- > ? STORE_LOCAL(value e) > ? JUMP 8 -1520a1609,1614 +1492a1581,1586 > 8: > 62 LOAD_MODULE object Predef > 62 CONSTANT("RuntimeException") > 62 CALL_METHOD scala.Predef.println (dynamic) > 62 JUMP 2 > -1568c1662 +1540c1634 < blocks: [1,2,3,4] --- > blocks: [1,2,3,4,5] -1588c1682,1687 +1560c1654,1659 < 229 THROW(MyException) --- > ? JUMP 5 @@ -394,19 +394,19 @@ > ? LOAD_LOCAL(variable monitor1) > 228 MONITOR_EXIT > 228 THROW(Throwable) -1594c1693 +1566c1665 < ? THROW(Throwable) --- > 228 THROW(Throwable) -1622c1721 +1594c1693 < locals: value args, variable result, variable monitor2, variable monitorResult1 --- > locals: value exception$1, value args, variable result, variable monitor2, variable monitorResult1 -1624c1723 +1596c1695 < blocks: [1,2,3,4] --- > blocks: [1,2,3,4,5] -1647c1746,1754 +1619c1718,1726 < 245 THROW(MyException) --- > ? STORE_LOCAL(value exception$1) @@ -418,7 +418,7 @@ > ? LOAD_LOCAL(variable monitor2) > 244 MONITOR_EXIT > 244 THROW(Throwable) -1653c1760 +1625c1732 < ? THROW(Throwable) --- > 244 THROW(Throwable) diff --git a/test/files/run/macro-typecheck-macrosdisabled2.check b/test/files/run/macro-typecheck-macrosdisabled2.check index b958a95552..75fd693722 100644 --- a/test/files/run/macro-typecheck-macrosdisabled2.check +++ b/test/files/run/macro-typecheck-macrosdisabled2.check @@ -10,7 +10,7 @@ def apply[U >: Nothing <: scala.reflect.api.Universe with Singleton]($m$untyped: scala.reflect.api.Mirror[U]): U#Tree = { val $u: U = $m$untyped.universe; val $m: $u.Mirror = $m$untyped.asInstanceOf[$u.Mirror]; - $u.Apply.apply($u.Select.apply($u.Select.apply($u.build.Ident($m.staticPackage("scala")), $u.TermName.apply("Array")), $u.TermName.apply("apply")), scala.collection.immutable.List.apply[$u.Literal]($u.Literal.apply($u.Constant.apply(2)))) + $u.Apply.apply($u.Select.apply($u.build.Ident($m.staticModule("scala.Array")), $u.TermName.apply("apply")), scala.collection.immutable.List.apply[$u.Literal]($u.Literal.apply($u.Constant.apply(2)))) } }; new $treecreator1() diff --git a/test/files/run/reflection-java-annotations.check b/test/files/run/reflection-java-annotations.check index 53c53cfbcc..2d37fff1f4 100644 --- a/test/files/run/reflection-java-annotations.check +++ b/test/files/run/reflection-java-annotations.check @@ -1 +1 @@ -List(JavaComplexAnnotation(v1 = 1, v10 = "hello", v101 = [101, 101], v102 = [102, 102], v103 = ['g', 'g'], v104 = [104, 104], v105 = [105L, 105L], v106 = [106.0, 106.0], v107 = [107.0, 107.0], v108 = [false, true], v11 = classOf[JavaAnnottee], v110 = ["hello", "world"], v111 = [classOf[JavaSimpleAnnotation], classOf[JavaComplexAnnotation]], v112 = [FOO, BAR], v113 = [JavaSimpleAnnotation(v1 = 21, v10 = "world2", v11 = classOf[JavaComplexAnnotation], v12 = BAR, v2 = 22, v3 = '\027', v4 = 24, v5 = 25L, v6 = 26.0, v7 = 27.0, v8 = false)], v12 = FOO, v13 = JavaSimpleAnnotation(v1 = 11, v10 = "world1", v11 = classOf[JavaSimpleAnnotation], v12 = FOO, v2 = 12, v3 = '\r', v4 = 14, v5 = 15L, v6 = 16.0, v7 = 17.0, v8 = false), v2 = 2, v3 = '\03', v4 = 4, v5 = 5L, v6 = 6.0, v7 = 7.0, v8 = false)) +List(JavaComplexAnnotation_1(v1 = 1, v10 = "hello", v101 = [101, 101], v102 = [102, 102], v103 = ['g', 'g'], v104 = [104, 104], v105 = [105L, 105L], v106 = [106.0, 106.0], v107 = [107.0, 107.0], v108 = [false, true], v11 = classOf[JavaAnnottee_1], v110 = ["hello", "world"], v111 = [classOf[JavaSimpleAnnotation_1], classOf[JavaComplexAnnotation_1]], v112 = [FOO, BAR], v113 = [JavaSimpleAnnotation_1(v1 = 21, v10 = "world2", v11 = classOf[JavaComplexAnnotation_1], v12 = BAR, v2 = 22, v3 = '\027', v4 = 24, v5 = 25L, v6 = 26.0, v7 = 27.0, v8 = false)], v12 = FOO, v13 = JavaSimpleAnnotation_1(v1 = 11, v10 = "world1", v11 = classOf[JavaSimpleAnnotation_1], v12 = FOO, v2 = 12, v3 = '\r', v4 = 14, v5 = 15L, v6 = 16.0, v7 = 17.0, v8 = false), v2 = 2, v3 = '\03', v4 = 4, v5 = 5L, v6 = 6.0, v7 = 7.0, v8 = false)) diff --git a/test/files/run/reflection-java-annotations/JavaAnnottee_1.java b/test/files/run/reflection-java-annotations/JavaAnnottee_1.java new file mode 100644 index 0000000000..b241f5d25e --- /dev/null +++ b/test/files/run/reflection-java-annotations/JavaAnnottee_1.java @@ -0,0 +1,47 @@ +@JavaComplexAnnotation_1( + v1 = (byte)1, + v2 = (short)2, + v3 = (char)3, + v4 = (int)4, + v5 = (long)5, + v6 = (float)6, + v7 = (double)7, + v10 = "hello", + v11 = JavaAnnottee_1.class, + v12 = JavaSimpleEnumeration_1.FOO, + v13 = @JavaSimpleAnnotation_1( + v1 = (byte)11, + v2 = (short)12, + v3 = (char)13, + v4 = (int)14, + v5 = (long)15, + v6 = (float)16, + v7 = (double)17, + v10 = "world1", + v11 = JavaSimpleAnnotation_1.class, + v12 = JavaSimpleEnumeration_1.FOO + ), + v101 = {(byte)101, (byte)101}, + v102 = {(short)102, (short)102}, + v103 = {(char)103, (char)103}, + v104 = {(int)104, (int)104}, + v105 = {(long)105, (long)105}, + v106 = {(float)106, (float)106}, + v107 = {(double)107, (double)107}, + v108 = {false, true}, + v110 = {"hello", "world"}, + v111 = {JavaSimpleAnnotation_1.class, JavaComplexAnnotation_1.class}, + v112 = {JavaSimpleEnumeration_1.FOO, JavaSimpleEnumeration_1.BAR}, + v113 = {@JavaSimpleAnnotation_1( + v1 = (byte)21, + v2 = (short)22, + v3 = (char)23, + v4 = (int)24, + v5 = (long)25, + v6 = (float)26, + v7 = (double)27, + v10 = "world2", + v11 = JavaComplexAnnotation_1.class, + v12 = JavaSimpleEnumeration_1.BAR + )}) +public class JavaAnnottee_1 {}
\ No newline at end of file diff --git a/test/files/run/reflection-java-annotations/JavaComplexAnnotation_1.java b/test/files/run/reflection-java-annotations/JavaComplexAnnotation_1.java new file mode 100644 index 0000000000..645eeb9399 --- /dev/null +++ b/test/files/run/reflection-java-annotations/JavaComplexAnnotation_1.java @@ -0,0 +1,34 @@ +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.FIELD, ElementType.METHOD, ElementType.TYPE}) +public @interface JavaComplexAnnotation_1 { + byte v1(); + short v2(); + char v3(); + int v4(); + long v5(); + float v6(); + double v7(); + boolean v8() default false; + // void v9(); + String v10(); + Class<?> v11(); + JavaSimpleEnumeration_1 v12(); + JavaSimpleAnnotation_1 v13(); + byte[] v101(); + short[] v102(); + char[] v103(); + int[] v104(); + long[] v105(); + float[] v106(); + double[] v107(); + boolean[] v108(); + String[] v110(); + Class<?>[] v111(); + JavaSimpleEnumeration_1[] v112(); + JavaSimpleAnnotation_1[] v113(); +}
\ No newline at end of file diff --git a/test/files/run/reflection-java-annotations/JavaSimpleAnnotation_1.java b/test/files/run/reflection-java-annotations/JavaSimpleAnnotation_1.java new file mode 100644 index 0000000000..c0f92fad2c --- /dev/null +++ b/test/files/run/reflection-java-annotations/JavaSimpleAnnotation_1.java @@ -0,0 +1,21 @@ +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.FIELD, ElementType.METHOD, ElementType.TYPE}) +public @interface JavaSimpleAnnotation_1 { + byte v1(); + short v2(); + char v3(); + int v4(); + long v5(); + float v6(); + double v7(); + boolean v8() default false; + // void v9(); + String v10(); + Class<?> v11(); + JavaSimpleEnumeration_1 v12(); +}
\ No newline at end of file diff --git a/test/files/run/reflection-java-annotations/JavaSimpleEnumeration_1.java b/test/files/run/reflection-java-annotations/JavaSimpleEnumeration_1.java new file mode 100644 index 0000000000..39246141cc --- /dev/null +++ b/test/files/run/reflection-java-annotations/JavaSimpleEnumeration_1.java @@ -0,0 +1,4 @@ +enum JavaSimpleEnumeration_1 { + FOO, + BAR +}
\ No newline at end of file diff --git a/test/files/run/reflection-java-annotations.scala b/test/files/run/reflection-java-annotations/Test_2.scala index 2e3fed48ce..d2c3157071 100644 --- a/test/files/run/reflection-java-annotations.scala +++ b/test/files/run/reflection-java-annotations/Test_2.scala @@ -1,6 +1,6 @@ object Test extends App { import scala.reflect.runtime.universe._ - val sym = typeOf[JavaAnnottee].typeSymbol + val sym = typeOf[JavaAnnottee_1].typeSymbol sym.typeSignature sym.annotations foreach (_.javaArgs) println(sym.annotations) diff --git a/test/files/run/reflection-java-crtp/JavaSimpleEnumeration_1.java b/test/files/run/reflection-java-crtp/JavaSimpleEnumeration_1.java new file mode 100644 index 0000000000..39246141cc --- /dev/null +++ b/test/files/run/reflection-java-crtp/JavaSimpleEnumeration_1.java @@ -0,0 +1,4 @@ +enum JavaSimpleEnumeration_1 { + FOO, + BAR +}
\ No newline at end of file diff --git a/test/files/run/reflection-java-crtp.scala b/test/files/run/reflection-java-crtp/Main_2.scala index 260d3540dc..fb5668f323 100644 --- a/test/files/run/reflection-java-crtp.scala +++ b/test/files/run/reflection-java-crtp/Main_2.scala @@ -1,6 +1,6 @@ object Test extends App { import scala.reflect.runtime.universe._ - val enum = typeOf[JavaSimpleEnumeration].baseClasses(1).asClass + val enum = typeOf[JavaSimpleEnumeration_1].baseClasses(1).asClass // make sure that the E's in Enum<E extends Enum<E>> are represented by the same symbol val e1 = enum.typeParams(0).asType val TypeBounds(_, TypeRef(_, _, List(TypeRef(_, e2: TypeSymbol, _)))) = e1.typeSignature diff --git a/test/files/run/reflection-magicsymbols-repl.check b/test/files/run/reflection-magicsymbols-repl.check index 85a1f63f01..bb8bdc9dd9 100644 --- a/test/files/run/reflection-magicsymbols-repl.check +++ b/test/files/run/reflection-magicsymbols-repl.check @@ -23,7 +23,7 @@ scala> def test(n: Int): Unit = { val x = sig.asInstanceOf[MethodType].params.head println(x.typeSignature) } -warning: there were 1 feature warnings; re-run with -feature for details +warning: there were 1 feature warning(s); re-run with -feature for details test: (n: Int)Unit scala> for (i <- 1 to 8) test(i) diff --git a/test/files/run/reify_ann1a.check b/test/files/run/reify_ann1a.check index 244be27aa7..99a966f38b 100644 --- a/test/files/run/reify_ann1a.check +++ b/test/files/run/reify_ann1a.check @@ -1,28 +1,28 @@ { - @new ann(immutable.this.List.apply("1a")) @new ann(immutable.this.List.apply("1b")) class C[@new ann(immutable.this.List.apply("2a")) @new ann(immutable.this.List.apply("2b")) T >: Nothing <: Any] extends AnyRef { - @new ann(immutable.this.List.apply("3a")) @new ann(immutable.this.List.apply("3b")) <paramaccessor> private[this] val x: T @ann(immutable.this.List.apply("4a")) @ann(immutable.this.List.apply("4b")) = _; - def <init>(@new ann(immutable.this.List.apply("3a")) @new ann(immutable.this.List.apply("3b")) x: T @ann(immutable.this.List.apply("4a")) @ann(immutable.this.List.apply("4b"))) = { + @new ann(List.apply("1a")) @new ann(List.apply("1b")) class C[@new ann(List.apply("2a")) @new ann(List.apply("2b")) T >: Nothing <: Any] extends AnyRef { + @new ann(List.apply("3a")) @new ann(List.apply("3b")) <paramaccessor> private[this] val x: T @ann(List.apply("4a")) @ann(List.apply("4b")) = _; + def <init>(@new ann(List.apply("3a")) @new ann(List.apply("3b")) x: T @ann(List.apply("4a")) @ann(List.apply("4b"))) = { super.<init>(); () }; - @new ann(immutable.this.List.apply("5a")) @new ann(immutable.this.List.apply("5b")) def f(x: Int @ann(immutable.this.List.apply("6a")) @ann(immutable.this.List.apply("6b"))) = { - @new ann(immutable.this.List.apply("7a")) @new ann(immutable.this.List.apply("7b")) val r = x.$plus(3): @ann(immutable.this.List.apply("8a")): @ann(immutable.this.List.apply("8b")); - val s = (4: Int @ann(immutable.this.List.apply("9a")) @ann(immutable.this.List.apply("9b"))); + @new ann(List.apply("5a")) @new ann(List.apply("5b")) def f(x: Int @ann(List.apply("6a")) @ann(List.apply("6b"))) = { + @new ann(List.apply("7a")) @new ann(List.apply("7b")) val r = x.$plus(3): @ann(List.apply("8a")): @ann(List.apply("8b")); + val s = (4: Int @ann(List.apply("9a")) @ann(List.apply("9b"))); r.$plus(s) } }; () } { - @ann(immutable.this.List.apply[String]("1a")) @ann(immutable.this.List.apply[String]("1b")) class C[@ann(immutable.this.List.apply[String]("2a")) @ann(immutable.this.List.apply[String]("2b")) T] extends AnyRef { - @ann(immutable.this.List.apply[String]("3a")) @ann(immutable.this.List.apply[String]("3b")) <paramaccessor> private[this] val x: T @ann(immutable.this.List.apply[String]("4b")) @ann(immutable.this.List.apply[String]("4a")) = _; - def <init>(@ann(immutable.this.List.apply[String]("3a")) @ann(immutable.this.List.apply[String]("3b")) x: T @ann(immutable.this.List.apply[String]("4b")) @ann(immutable.this.List.apply[String]("4a"))): C[T] = { + @ann(List.apply[String]("1a")) @ann(List.apply[String]("1b")) class C[@ann(List.apply[String]("2a")) @ann(List.apply[String]("2b")) T] extends AnyRef { + @ann(List.apply[String]("3a")) @ann(List.apply[String]("3b")) <paramaccessor> private[this] val x: T @ann(List.apply[String]("4b")) @ann(List.apply[String]("4a")) = _; + def <init>(@ann(List.apply[String]("3a")) @ann(List.apply[String]("3b")) x: T @ann(List.apply[String]("4b")) @ann(List.apply[String]("4a"))): C[T] = { C.super.<init>(); () }; - @ann(immutable.this.List.apply[String]("5a")) @ann(immutable.this.List.apply[String]("5b")) def f(x: Int @ann(immutable.this.List.apply[String]("6b")) @ann(immutable.this.List.apply[String]("6a"))): Int = { - @ann(immutable.this.List.apply[String]("7a")) @ann(immutable.this.List.apply[String]("7b")) val r: Int @ann(immutable.this.List.apply[String]("8b")) @ann(immutable.this.List.apply[String]("8a")) = ((x.+(3): Int @ann(immutable.this.List.apply[String]("8a"))): Int @ann(immutable.this.List.apply[String]("8b")) @ann(immutable.this.List.apply[String]("8a"))); - val s: Int @ann(immutable.this.List.apply[String]("9b")) @ann(immutable.this.List.apply[String]("9a")) = (4: Int @ann(immutable.this.List.apply[String]("9b")) @ann(immutable.this.List.apply[String]("9a"))); + @ann(List.apply[String]("5a")) @ann(List.apply[String]("5b")) def f(x: Int @ann(List.apply[String]("6b")) @ann(List.apply[String]("6a"))): Int = { + @ann(List.apply[String]("7a")) @ann(List.apply[String]("7b")) val r: Int @ann(List.apply[String]("8b")) @ann(List.apply[String]("8a")) = ((x.+(3): Int @ann(List.apply[String]("8a"))): Int @ann(List.apply[String]("8b")) @ann(List.apply[String]("8a"))); + val s: Int @ann(List.apply[String]("9b")) @ann(List.apply[String]("9a")) = (4: Int @ann(List.apply[String]("9b")) @ann(List.apply[String]("9a"))); r.+(s) } }; diff --git a/test/files/run/reify_ann2a.check b/test/files/run/reify_ann2a.check index 934af54802..ccbcb4c31e 100644 --- a/test/files/run/reify_ann2a.check +++ b/test/files/run/reify_ann2a.check @@ -1,20 +1,20 @@ { class ann extends StaticAnnotation { - <paramaccessor> private[this] val bar: List[String] = _; - def <init>(bar: List[String]) = { + <paramaccessor> private[this] val bar: `package`.List[Predef.String] = _; + def <init>(bar: `package`.List[Predef.String]) = { super.<init>(); () } }; - @new ann(immutable.this.List.apply("1a")) @new ann(immutable.this.List.apply("1b")) class C[@new ann(immutable.this.List.apply("2a")) @new ann(immutable.this.List.apply("2b")) T >: Nothing <: Any] extends AnyRef { - @new ann(immutable.this.List.apply("3a")) @new ann(immutable.this.List.apply("3b")) <paramaccessor> private[this] val x: T @ann(immutable.this.List.apply("4a")) @ann(immutable.this.List.apply("4b")) = _; - def <init>(@new ann(immutable.this.List.apply("3a")) @new ann(immutable.this.List.apply("3b")) x: T @ann(immutable.this.List.apply("4a")) @ann(immutable.this.List.apply("4b"))) = { + @new ann(List.apply("1a")) @new ann(List.apply("1b")) class C[@new ann(List.apply("2a")) @new ann(List.apply("2b")) T >: Nothing <: Any] extends AnyRef { + @new ann(List.apply("3a")) @new ann(List.apply("3b")) <paramaccessor> private[this] val x: T @ann(List.apply("4a")) @ann(List.apply("4b")) = _; + def <init>(@new ann(List.apply("3a")) @new ann(List.apply("3b")) x: T @ann(List.apply("4a")) @ann(List.apply("4b"))) = { super.<init>(); () }; - @new ann(immutable.this.List.apply("5a")) @new ann(immutable.this.List.apply("5b")) def f(x: Int @ann(immutable.this.List.apply("6a")) @ann(immutable.this.List.apply("6b"))) = { - @new ann(immutable.this.List.apply("7a")) @new ann(immutable.this.List.apply("7b")) val r = x.$plus(3): @ann(immutable.this.List.apply("8a")): @ann(immutable.this.List.apply("8b")); - val s = (4: Int @ann(immutable.this.List.apply("9a")) @ann(immutable.this.List.apply("9b"))); + @new ann(List.apply("5a")) @new ann(List.apply("5b")) def f(x: Int @ann(List.apply("6a")) @ann(List.apply("6b"))) = { + @new ann(List.apply("7a")) @new ann(List.apply("7b")) val r = x.$plus(3): @ann(List.apply("8a")): @ann(List.apply("8b")); + val s = (4: Int @ann(List.apply("9a")) @ann(List.apply("9b"))); r.$plus(s) } }; @@ -28,15 +28,15 @@ () } }; - @ann(immutable.this.List.apply[String]("1a")) @ann(immutable.this.List.apply[String]("1b")) class C[@ann(immutable.this.List.apply[String]("2a")) @ann(immutable.this.List.apply[String]("2b")) T] extends AnyRef { - @ann(immutable.this.List.apply[String]("3a")) @ann(immutable.this.List.apply[String]("3b")) <paramaccessor> private[this] val x: T @ann(immutable.this.List.apply[String]("4b")) @ann(immutable.this.List.apply[String]("4a")) = _; - def <init>(@ann(immutable.this.List.apply[String]("3a")) @ann(immutable.this.List.apply[String]("3b")) x: T @ann(immutable.this.List.apply[String]("4b")) @ann(immutable.this.List.apply[String]("4a"))): C[T] = { + @ann(List.apply[String]("1a")) @ann(List.apply[String]("1b")) class C[@ann(List.apply[String]("2a")) @ann(List.apply[String]("2b")) T] extends AnyRef { + @ann(List.apply[String]("3a")) @ann(List.apply[String]("3b")) <paramaccessor> private[this] val x: T @ann(List.apply[String]("4b")) @ann(List.apply[String]("4a")) = _; + def <init>(@ann(List.apply[String]("3a")) @ann(List.apply[String]("3b")) x: T @ann(List.apply[String]("4b")) @ann(List.apply[String]("4a"))): C[T] = { C.super.<init>(); () }; - @ann(immutable.this.List.apply[String]("5a")) @ann(immutable.this.List.apply[String]("5b")) def f(x: Int @ann(immutable.this.List.apply[String]("6b")) @ann(immutable.this.List.apply[String]("6a"))): Int = { - @ann(immutable.this.List.apply[String]("7a")) @ann(immutable.this.List.apply[String]("7b")) val r: Int @ann(immutable.this.List.apply[String]("8b")) @ann(immutable.this.List.apply[String]("8a")) = ((x.+(3): Int @ann(immutable.this.List.apply[String]("8a"))): Int @ann(immutable.this.List.apply[String]("8b")) @ann(immutable.this.List.apply[String]("8a"))); - val s: Int @ann(immutable.this.List.apply[String]("9b")) @ann(immutable.this.List.apply[String]("9a")) = (4: Int @ann(immutable.this.List.apply[String]("9b")) @ann(immutable.this.List.apply[String]("9a"))); + @ann(List.apply[String]("5a")) @ann(List.apply[String]("5b")) def f(x: Int @ann(List.apply[String]("6b")) @ann(List.apply[String]("6a"))): Int = { + @ann(List.apply[String]("7a")) @ann(List.apply[String]("7b")) val r: Int @ann(List.apply[String]("8b")) @ann(List.apply[String]("8a")) = ((x.+(3): Int @ann(List.apply[String]("8a"))): Int @ann(List.apply[String]("8b")) @ann(List.apply[String]("8a"))); + val s: Int @ann(List.apply[String]("9b")) @ann(List.apply[String]("9a")) = (4: Int @ann(List.apply[String]("9b")) @ann(List.apply[String]("9a"))); r.+(s) } }; diff --git a/test/files/run/reify_copypaste2.check b/test/files/run/reify_copypaste2.check index 9c34f5179b..f5c1076962 100644 --- a/test/files/run/reify_copypaste2.check +++ b/test/files/run/reify_copypaste2.check @@ -1 +1 @@ -scala.reflect.runtime.`package`.universe.reify(Test.this.x) +`package`.universe.reify(Test.this.x) diff --git a/test/files/run/reify_newimpl_30.check b/test/files/run/reify_newimpl_30.check index c23af69b08..7557c750a6 100644 --- a/test/files/run/reify_newimpl_30.check +++ b/test/files/run/reify_newimpl_30.check @@ -1 +1,4 @@ -List(2) +reflective toolbox failed due to unresolved free type variables: + C defined by <local Test> in reify_newimpl_30.scala:7:11 +have you forgotten to use TypeTag annotations for type parameters external to a reifee? +if you have troubles tracking free type variables, consider using -Xlog-free-types diff --git a/test/files/run/reify_newimpl_30.scala b/test/files/run/reify_newimpl_30.scala index 573d05a630..bc34f1bb6c 100644 --- a/test/files/run/reify_newimpl_30.scala +++ b/test/files/run/reify_newimpl_30.scala @@ -1,5 +1,5 @@ import scala.reflect.runtime.universe._ -import scala.tools.reflect.ToolBox +import scala.tools.reflect.{ ToolBox, ToolBoxError } import scala.tools.reflect.Eval object Test extends App { @@ -9,9 +9,10 @@ object Test extends App { val code = reify { List[C#T](2) } - println(code.eval) + try { println(code.eval) } + catch { case e: ToolBoxError => println(e.getMessage) } } new C } -}
\ No newline at end of file +} diff --git a/test/files/run/reify_newimpl_35.check b/test/files/run/reify_newimpl_35.check index 5545e6e005..52aaa171e0 100644 --- a/test/files/run/reify_newimpl_35.check +++ b/test/files/run/reify_newimpl_35.check @@ -10,7 +10,7 @@ scala> def foo[T: TypeTag] = reify{List[T]()} foo: [T](implicit evidence$1: reflect.runtime.universe.TypeTag[T])reflect.runtime.universe.Expr[List[T]] scala> println(foo) -Expr[List[Nothing]](immutable.this.Nil) +Expr[List[Nothing]](Nil) scala> diff --git a/test/files/run/showraw_tree.check b/test/files/run/showraw_tree.check index 0416b12568..eb74bd8b2b 100644 --- a/test/files/run/showraw_tree.check +++ b/test/files/run/showraw_tree.check @@ -1,2 +1,2 @@ -Apply(Select(New(AppliedTypeTree(Ident(scala.collection.immutable.HashMap), List(Ident(TypeName("String")), Ident(TypeName("String"))))), nme.CONSTRUCTOR), List()) -Apply(Select(New(AppliedTypeTree(Ident(scala.collection.mutable.HashMap), List(Ident(TypeName("String")), Ident(TypeName("String"))))), nme.CONSTRUCTOR), List()) +Apply(Select(New(AppliedTypeTree(Ident(scala.collection.immutable.HashMap), List(Select(Ident(scala.Predef), TypeName("String")), Select(Ident(scala.Predef), TypeName("String"))))), nme.CONSTRUCTOR), List()) +Apply(Select(New(AppliedTypeTree(Ident(scala.collection.mutable.HashMap), List(Select(Ident(scala.Predef), TypeName("String")), Select(Ident(scala.Predef), TypeName("String"))))), nme.CONSTRUCTOR), List()) diff --git a/test/files/run/showraw_tree_ids.check b/test/files/run/showraw_tree_ids.check index 6e17bf2fb4..7e0149a3c1 100644 --- a/test/files/run/showraw_tree_ids.check +++ b/test/files/run/showraw_tree_ids.check @@ -1,2 +1,2 @@ -Apply(Select(New(AppliedTypeTree(Ident(scala.collection.immutable.HashMap#<id>), List(Ident(TypeName("String")#<id>), Ident(TypeName("String")#<id>)))), nme.CONSTRUCTOR), List()) -Apply(Select(New(AppliedTypeTree(Ident(scala.collection.mutable.HashMap#<id>), List(Ident(TypeName("String")#<id>), Ident(TypeName("String")#<id>)))), nme.CONSTRUCTOR), List()) +Apply(Select(New(AppliedTypeTree(Ident(scala.collection.immutable.HashMap#<id>), List(Select(Ident(scala.Predef#<id>), TypeName("String")), Select(Ident(scala.Predef#<id>), TypeName("String"))))), nme.CONSTRUCTOR), List()) +Apply(Select(New(AppliedTypeTree(Ident(scala.collection.mutable.HashMap#<id>), List(Select(Ident(scala.Predef#<id>), TypeName("String")), Select(Ident(scala.Predef#<id>), TypeName("String"))))), nme.CONSTRUCTOR), List()) diff --git a/test/files/run/showraw_tree_kinds.check b/test/files/run/showraw_tree_kinds.check index 16147a64f4..577f447ae4 100644 --- a/test/files/run/showraw_tree_kinds.check +++ b/test/files/run/showraw_tree_kinds.check @@ -1,2 +1,2 @@ -Apply(Select(New(AppliedTypeTree(Ident(scala.collection.immutable.HashMap#CLS), List(Ident(TypeName("String")#TPE), Ident(TypeName("String")#TPE)))), nme.CONSTRUCTOR), List()) -Apply(Select(New(AppliedTypeTree(Ident(scala.collection.mutable.HashMap#CLS), List(Ident(TypeName("String")#TPE), Ident(TypeName("String")#TPE)))), nme.CONSTRUCTOR), List()) +Apply(Select(New(AppliedTypeTree(Ident(scala.collection.immutable.HashMap#CLS), List(Select(Ident(scala.Predef#MOD), TypeName("String")), Select(Ident(scala.Predef#MOD), TypeName("String"))))), nme.CONSTRUCTOR), List()) +Apply(Select(New(AppliedTypeTree(Ident(scala.collection.mutable.HashMap#CLS), List(Select(Ident(scala.Predef#MOD), TypeName("String")), Select(Ident(scala.Predef#MOD), TypeName("String"))))), nme.CONSTRUCTOR), List()) diff --git a/test/files/run/showraw_tree_types_ids.check b/test/files/run/showraw_tree_types_ids.check index c98b16e956..6a73d77436 100644 --- a/test/files/run/showraw_tree_types_ids.check +++ b/test/files/run/showraw_tree_types_ids.check @@ -1,10 +1,12 @@ -Apply[1](Select[2](New[1](TypeTree[1]().setOriginal(AppliedTypeTree(Ident[3](scala.collection.immutable.HashMap#<id>), List(TypeTree[4]().setOriginal(Ident[4](TypeName("String")#<id>)), TypeTree[4]().setOriginal(Ident[4](TypeName("String")#<id>)))))), nme.CONSTRUCTOR#<id>), List()) -[1] TypeRef(ThisType(scala.collection.immutable#<id>), scala.collection.immutable.HashMap#<id>, List(TypeRef(ThisType(scala.Predef#<id>), TypeName("String")#<id>, List()), TypeRef(ThisType(scala.Predef#<id>), TypeName("String")#<id>, List()))) -[2] MethodType(List(), TypeRef(ThisType(scala.collection.immutable#<id>), scala.collection.immutable.HashMap#<id>, List(TypeRef(ThisType(scala.Predef#<id>), TypeName("String")#<id>, List()), TypeRef(ThisType(scala.Predef#<id>), TypeName("String")#<id>, List())))) +Apply[1](Select[2](New[1](TypeTree[1]().setOriginal(AppliedTypeTree(Ident[3](scala.collection.immutable.HashMap#<id>), List(TypeTree[4]().setOriginal(Select[4](Ident[5](scala.Predef#<id>), TypeName("String")#<id>)), TypeTree[4]().setOriginal(Select[4](Ident[5](scala.Predef#<id>), TypeName("String")#<id>)))))), nme.CONSTRUCTOR#<id>), List()) +[1] TypeRef(ThisType(scala.collection.immutable#<id>), scala.collection.immutable.HashMap#<id>, List(TypeRef(SingleType(ThisType(scala#<id>), scala.Predef#<id>), TypeName("String")#<id>, List()), TypeRef(SingleType(ThisType(scala#<id>), scala.Predef#<id>), TypeName("String")#<id>, List()))) +[2] MethodType(List(), TypeRef(ThisType(scala.collection.immutable#<id>), scala.collection.immutable.HashMap#<id>, List(TypeRef(SingleType(ThisType(scala#<id>), scala.Predef#<id>), TypeName("String")#<id>, List()), TypeRef(SingleType(ThisType(scala#<id>), scala.Predef#<id>), TypeName("String")#<id>, List())))) [3] TypeRef(ThisType(scala.collection.immutable#<id>), scala.collection.immutable.HashMap#<id>, List()) -[4] TypeRef(ThisType(scala.Predef#<id>), TypeName("String")#<id>, List()) -Apply[5](Select[6](New[5](TypeTree[5]().setOriginal(AppliedTypeTree(Ident[7](scala.collection.mutable.HashMap#<id>), List(TypeTree[4]().setOriginal(Ident[4](TypeName("String")#<id>)), TypeTree[4]().setOriginal(Ident[4](TypeName("String")#<id>)))))), nme.CONSTRUCTOR#<id>), List()) -[4] TypeRef(ThisType(scala.Predef#<id>), TypeName("String")#<id>, List()) -[5] TypeRef(ThisType(scala.collection.mutable#<id>), scala.collection.mutable.HashMap#<id>, List(TypeRef(ThisType(scala.Predef#<id>), TypeName("String")#<id>, List()), TypeRef(ThisType(scala.Predef#<id>), TypeName("String")#<id>, List()))) -[6] MethodType(List(), TypeRef(ThisType(scala.collection.mutable#<id>), scala.collection.mutable.HashMap#<id>, List(TypeRef(ThisType(scala.Predef#<id>), TypeName("String")#<id>, List()), TypeRef(ThisType(scala.Predef#<id>), TypeName("String")#<id>, List())))) -[7] TypeRef(ThisType(scala.collection.mutable#<id>), scala.collection.mutable.HashMap#<id>, List()) +[4] TypeRef(SingleType(ThisType(scala#<id>), scala.Predef#<id>), TypeName("String")#<id>, List()) +[5] SingleType(ThisType(scala#<id>), scala.Predef#<id>) +Apply[6](Select[7](New[6](TypeTree[6]().setOriginal(AppliedTypeTree(Ident[8](scala.collection.mutable.HashMap#<id>), List(TypeTree[4]().setOriginal(Select[4](Ident[5](scala.Predef#<id>), TypeName("String")#<id>)), TypeTree[4]().setOriginal(Select[4](Ident[5](scala.Predef#<id>), TypeName("String")#<id>)))))), nme.CONSTRUCTOR#<id>), List()) +[4] TypeRef(SingleType(ThisType(scala#<id>), scala.Predef#<id>), TypeName("String")#<id>, List()) +[5] SingleType(ThisType(scala#<id>), scala.Predef#<id>) +[6] TypeRef(ThisType(scala.collection.mutable#<id>), scala.collection.mutable.HashMap#<id>, List(TypeRef(SingleType(ThisType(scala#<id>), scala.Predef#<id>), TypeName("String")#<id>, List()), TypeRef(SingleType(ThisType(scala#<id>), scala.Predef#<id>), TypeName("String")#<id>, List()))) +[7] MethodType(List(), TypeRef(ThisType(scala.collection.mutable#<id>), scala.collection.mutable.HashMap#<id>, List(TypeRef(SingleType(ThisType(scala#<id>), scala.Predef#<id>), TypeName("String")#<id>, List()), TypeRef(SingleType(ThisType(scala#<id>), scala.Predef#<id>), TypeName("String")#<id>, List())))) +[8] TypeRef(ThisType(scala.collection.mutable#<id>), scala.collection.mutable.HashMap#<id>, List()) diff --git a/test/files/run/showraw_tree_types_typed.check b/test/files/run/showraw_tree_types_typed.check index 30dda7d18b..cf63ecb586 100644 --- a/test/files/run/showraw_tree_types_typed.check +++ b/test/files/run/showraw_tree_types_typed.check @@ -1,10 +1,12 @@ -Apply[1](Select[2](New[1](TypeTree[1]().setOriginal(AppliedTypeTree(Ident[3](scala.collection.immutable.HashMap), List(TypeTree[4]().setOriginal(Ident[4](TypeName("String"))), TypeTree[4]().setOriginal(Ident[4](TypeName("String"))))))), nme.CONSTRUCTOR), List()) -[1] TypeRef(ThisType(scala.collection.immutable), scala.collection.immutable.HashMap, List(TypeRef(ThisType(scala.Predef), TypeName("String"), List()), TypeRef(ThisType(scala.Predef), TypeName("String"), List()))) -[2] MethodType(List(), TypeRef(ThisType(scala.collection.immutable), scala.collection.immutable.HashMap, List(TypeRef(ThisType(scala.Predef), TypeName("String"), List()), TypeRef(ThisType(scala.Predef), TypeName("String"), List())))) +Apply[1](Select[2](New[1](TypeTree[1]().setOriginal(AppliedTypeTree(Ident[3](scala.collection.immutable.HashMap), List(TypeTree[4]().setOriginal(Select[4](Ident[5](scala.Predef), TypeName("String"))), TypeTree[4]().setOriginal(Select[4](Ident[5](scala.Predef), TypeName("String"))))))), nme.CONSTRUCTOR), List()) +[1] TypeRef(ThisType(scala.collection.immutable), scala.collection.immutable.HashMap, List(TypeRef(SingleType(ThisType(scala), scala.Predef), TypeName("String"), List()), TypeRef(SingleType(ThisType(scala), scala.Predef), TypeName("String"), List()))) +[2] MethodType(List(), TypeRef(ThisType(scala.collection.immutable), scala.collection.immutable.HashMap, List(TypeRef(SingleType(ThisType(scala), scala.Predef), TypeName("String"), List()), TypeRef(SingleType(ThisType(scala), scala.Predef), TypeName("String"), List())))) [3] TypeRef(ThisType(scala.collection.immutable), scala.collection.immutable.HashMap, List()) -[4] TypeRef(ThisType(scala.Predef), TypeName("String"), List()) -Apply[5](Select[6](New[5](TypeTree[5]().setOriginal(AppliedTypeTree(Ident[7](scala.collection.mutable.HashMap), List(TypeTree[4]().setOriginal(Ident[4](TypeName("String"))), TypeTree[4]().setOriginal(Ident[4](TypeName("String"))))))), nme.CONSTRUCTOR), List()) -[4] TypeRef(ThisType(scala.Predef), TypeName("String"), List()) -[5] TypeRef(ThisType(scala.collection.mutable), scala.collection.mutable.HashMap, List(TypeRef(ThisType(scala.Predef), TypeName("String"), List()), TypeRef(ThisType(scala.Predef), TypeName("String"), List()))) -[6] MethodType(List(), TypeRef(ThisType(scala.collection.mutable), scala.collection.mutable.HashMap, List(TypeRef(ThisType(scala.Predef), TypeName("String"), List()), TypeRef(ThisType(scala.Predef), TypeName("String"), List())))) -[7] TypeRef(ThisType(scala.collection.mutable), scala.collection.mutable.HashMap, List()) +[4] TypeRef(SingleType(ThisType(scala), scala.Predef), TypeName("String"), List()) +[5] SingleType(ThisType(scala), scala.Predef) +Apply[6](Select[7](New[6](TypeTree[6]().setOriginal(AppliedTypeTree(Ident[8](scala.collection.mutable.HashMap), List(TypeTree[4]().setOriginal(Select[4](Ident[5](scala.Predef), TypeName("String"))), TypeTree[4]().setOriginal(Select[4](Ident[5](scala.Predef), TypeName("String"))))))), nme.CONSTRUCTOR), List()) +[4] TypeRef(SingleType(ThisType(scala), scala.Predef), TypeName("String"), List()) +[5] SingleType(ThisType(scala), scala.Predef) +[6] TypeRef(ThisType(scala.collection.mutable), scala.collection.mutable.HashMap, List(TypeRef(SingleType(ThisType(scala), scala.Predef), TypeName("String"), List()), TypeRef(SingleType(ThisType(scala), scala.Predef), TypeName("String"), List()))) +[7] MethodType(List(), TypeRef(ThisType(scala.collection.mutable), scala.collection.mutable.HashMap, List(TypeRef(SingleType(ThisType(scala), scala.Predef), TypeName("String"), List()), TypeRef(SingleType(ThisType(scala), scala.Predef), TypeName("String"), List())))) +[8] TypeRef(ThisType(scala.collection.mutable), scala.collection.mutable.HashMap, List()) diff --git a/test/files/run/showraw_tree_types_untyped.check b/test/files/run/showraw_tree_types_untyped.check index 0416b12568..eb74bd8b2b 100644 --- a/test/files/run/showraw_tree_types_untyped.check +++ b/test/files/run/showraw_tree_types_untyped.check @@ -1,2 +1,2 @@ -Apply(Select(New(AppliedTypeTree(Ident(scala.collection.immutable.HashMap), List(Ident(TypeName("String")), Ident(TypeName("String"))))), nme.CONSTRUCTOR), List()) -Apply(Select(New(AppliedTypeTree(Ident(scala.collection.mutable.HashMap), List(Ident(TypeName("String")), Ident(TypeName("String"))))), nme.CONSTRUCTOR), List()) +Apply(Select(New(AppliedTypeTree(Ident(scala.collection.immutable.HashMap), List(Select(Ident(scala.Predef), TypeName("String")), Select(Ident(scala.Predef), TypeName("String"))))), nme.CONSTRUCTOR), List()) +Apply(Select(New(AppliedTypeTree(Ident(scala.collection.mutable.HashMap), List(Select(Ident(scala.Predef), TypeName("String")), Select(Ident(scala.Predef), TypeName("String"))))), nme.CONSTRUCTOR), List()) diff --git a/test/files/run/showraw_tree_ultimate.check b/test/files/run/showraw_tree_ultimate.check index 991ecc5410..63f72de50b 100644 --- a/test/files/run/showraw_tree_ultimate.check +++ b/test/files/run/showraw_tree_ultimate.check @@ -1,10 +1,12 @@ -Apply[1](Select[2](New[1](TypeTree[1]().setOriginal(AppliedTypeTree(Ident[3](scala.collection.immutable.HashMap#<id>#CLS), List(TypeTree[4]().setOriginal(Ident[4](TypeName("String")#<id>#TPE)), TypeTree[4]().setOriginal(Ident[4](TypeName("String")#<id>#TPE)))))), nme.CONSTRUCTOR#<id>#PCTOR), List()) -[1] TypeRef(ThisType(scala.collection.immutable#<id>#PK), scala.collection.immutable.HashMap#<id>#CLS, List(TypeRef(ThisType(scala.Predef#<id>#MODC), TypeName("String")#<id>#TPE, List()), TypeRef(ThisType(scala.Predef#<id>#MODC), TypeName("String")#<id>#TPE, List()))) -[2] MethodType(List(), TypeRef(ThisType(scala.collection.immutable#<id>#PK), scala.collection.immutable.HashMap#<id>#CLS, List(TypeRef(ThisType(scala.Predef#<id>#MODC), TypeName("String")#<id>#TPE, List()), TypeRef(ThisType(scala.Predef#<id>#MODC), TypeName("String")#<id>#TPE, List())))) +Apply[1](Select[2](New[1](TypeTree[1]().setOriginal(AppliedTypeTree(Ident[3](scala.collection.immutable.HashMap#<id>#CLS), List(TypeTree[4]().setOriginal(Select[4](Ident[5](scala.Predef#<id>#MOD), TypeName("String")#<id>#TPE)), TypeTree[4]().setOriginal(Select[4](Ident[5](scala.Predef#<id>#MOD), TypeName("String")#<id>#TPE)))))), nme.CONSTRUCTOR#<id>#PCTOR), List()) +[1] TypeRef(ThisType(scala.collection.immutable#<id>#PK), scala.collection.immutable.HashMap#<id>#CLS, List(TypeRef(SingleType(ThisType(scala#<id>#PK), scala.Predef#<id>#MOD), TypeName("String")#<id>#TPE, List()), TypeRef(SingleType(ThisType(scala#<id>#PK), scala.Predef#<id>#MOD), TypeName("String")#<id>#TPE, List()))) +[2] MethodType(List(), TypeRef(ThisType(scala.collection.immutable#<id>#PK), scala.collection.immutable.HashMap#<id>#CLS, List(TypeRef(SingleType(ThisType(scala#<id>#PK), scala.Predef#<id>#MOD), TypeName("String")#<id>#TPE, List()), TypeRef(SingleType(ThisType(scala#<id>#PK), scala.Predef#<id>#MOD), TypeName("String")#<id>#TPE, List())))) [3] TypeRef(ThisType(scala.collection.immutable#<id>#PK), scala.collection.immutable.HashMap#<id>#CLS, List()) -[4] TypeRef(ThisType(scala.Predef#<id>#MODC), TypeName("String")#<id>#TPE, List()) -Apply[5](Select[6](New[5](TypeTree[5]().setOriginal(AppliedTypeTree(Ident[7](scala.collection.mutable.HashMap#<id>#CLS), List(TypeTree[4]().setOriginal(Ident[4](TypeName("String")#<id>#TPE)), TypeTree[4]().setOriginal(Ident[4](TypeName("String")#<id>#TPE)))))), nme.CONSTRUCTOR#<id>#CTOR), List()) -[4] TypeRef(ThisType(scala.Predef#<id>#MODC), TypeName("String")#<id>#TPE, List()) -[5] TypeRef(ThisType(scala.collection.mutable#<id>#PK), scala.collection.mutable.HashMap#<id>#CLS, List(TypeRef(ThisType(scala.Predef#<id>#MODC), TypeName("String")#<id>#TPE, List()), TypeRef(ThisType(scala.Predef#<id>#MODC), TypeName("String")#<id>#TPE, List()))) -[6] MethodType(List(), TypeRef(ThisType(scala.collection.mutable#<id>#PK), scala.collection.mutable.HashMap#<id>#CLS, List(TypeRef(ThisType(scala.Predef#<id>#MODC), TypeName("String")#<id>#TPE, List()), TypeRef(ThisType(scala.Predef#<id>#MODC), TypeName("String")#<id>#TPE, List())))) -[7] TypeRef(ThisType(scala.collection.mutable#<id>#PK), scala.collection.mutable.HashMap#<id>#CLS, List()) +[4] TypeRef(SingleType(ThisType(scala#<id>#PK), scala.Predef#<id>#MOD), TypeName("String")#<id>#TPE, List()) +[5] SingleType(ThisType(scala#<id>#PK), scala.Predef#<id>#MOD) +Apply[6](Select[7](New[6](TypeTree[6]().setOriginal(AppliedTypeTree(Ident[8](scala.collection.mutable.HashMap#<id>#CLS), List(TypeTree[4]().setOriginal(Select[4](Ident[5](scala.Predef#<id>#MOD), TypeName("String")#<id>#TPE)), TypeTree[4]().setOriginal(Select[4](Ident[5](scala.Predef#<id>#MOD), TypeName("String")#<id>#TPE)))))), nme.CONSTRUCTOR#<id>#CTOR), List()) +[4] TypeRef(SingleType(ThisType(scala#<id>#PK), scala.Predef#<id>#MOD), TypeName("String")#<id>#TPE, List()) +[5] SingleType(ThisType(scala#<id>#PK), scala.Predef#<id>#MOD) +[6] TypeRef(ThisType(scala.collection.mutable#<id>#PK), scala.collection.mutable.HashMap#<id>#CLS, List(TypeRef(SingleType(ThisType(scala#<id>#PK), scala.Predef#<id>#MOD), TypeName("String")#<id>#TPE, List()), TypeRef(SingleType(ThisType(scala#<id>#PK), scala.Predef#<id>#MOD), TypeName("String")#<id>#TPE, List()))) +[7] MethodType(List(), TypeRef(ThisType(scala.collection.mutable#<id>#PK), scala.collection.mutable.HashMap#<id>#CLS, List(TypeRef(SingleType(ThisType(scala#<id>#PK), scala.Predef#<id>#MOD), TypeName("String")#<id>#TPE, List()), TypeRef(SingleType(ThisType(scala#<id>#PK), scala.Predef#<id>#MOD), TypeName("String")#<id>#TPE, List())))) +[8] TypeRef(ThisType(scala.collection.mutable#<id>#PK), scala.collection.mutable.HashMap#<id>#CLS, List()) diff --git a/test/files/run/t2886.check b/test/files/run/t2886.check index cb0db8a6dc..61e36948bd 100644 --- a/test/files/run/t2886.check +++ b/test/files/run/t2886.check @@ -1,4 +1,4 @@ -((x: String) => { +((x: Predef.String) => { <artifact> val x$1 = x; <artifact> val x$2 = x; Test.this.test(x$2, x$1) diff --git a/test/files/run/t4172.check b/test/files/run/t4172.check index 94cdff4870..b48c9ca056 100644 --- a/test/files/run/t4172.check +++ b/test/files/run/t4172.check @@ -4,7 +4,7 @@ Type :help for more information. scala> scala> val c = { class C { override def toString = "C" }; ((new C, new C { def f = 2 })) } -warning: there were 1 feature warnings; re-run with -feature for details +warning: there were 1 feature warning(s); re-run with -feature for details c: (C, C{def f: Int}) forSome { type C <: AnyRef } = (C,C) scala> diff --git a/test/files/run/t4710.check b/test/files/run/t4710.check index 7c2b10b098..f2335d1bdd 100644 --- a/test/files/run/t4710.check +++ b/test/files/run/t4710.check @@ -2,7 +2,7 @@ Type in expressions to have them evaluated. Type :help for more information. scala> def method : String = { implicit def f(s: Symbol) = "" ; 'symbol } -warning: there were 1 feature warnings; re-run with -feature for details +warning: there were 1 feature warning(s); re-run with -feature for details method: String scala> diff --git a/test/files/run/t5271_2.check b/test/files/run/t5271_2.check index 585331be65..1df88872a7 100644 --- a/test/files/run/t5271_2.check +++ b/test/files/run/t5271_2.check @@ -8,7 +8,7 @@ } }; val c = C.apply(2, 2); - scala.this.Predef.println(c.foo.$times(c.bar)) + Predef.println(c.foo.$times(c.bar)) } 4 () diff --git a/test/files/run/t5271_3.check b/test/files/run/t5271_3.check index b02acd21f9..99aacc2cee 100644 --- a/test/files/run/t5271_3.check +++ b/test/files/run/t5271_3.check @@ -15,7 +15,7 @@ } }; val c = C.apply(2, 2); - scala.this.Predef.println(c.foo.$times(c.bar).$eq$eq(C.qwe)) + Predef.println(c.foo.$times(c.bar).$eq$eq(C.qwe)) } true () diff --git a/test/files/run/t5313.check b/test/files/run/t5313.check new file mode 100644 index 0000000000..7a48b2b711 --- /dev/null +++ b/test/files/run/t5313.check @@ -0,0 +1,12 @@ +STORE_LOCAL(variable kept1) +STORE_LOCAL(value result) +STORE_LOCAL(variable kept1) +STORE_LOCAL(variable kept2) +STORE_LOCAL(value kept3) +STORE_LOCAL(variable kept2) +STORE_LOCAL(variable kept4) +STORE_LOCAL(variable kept4) +STORE_LOCAL(variable kept5) +STORE_LOCAL(variable kept5) +STORE_LOCAL(variable kept6) +STORE_LOCAL(variable kept6) diff --git a/test/files/run/t5313.scala b/test/files/run/t5313.scala new file mode 100644 index 0000000000..7da8726a1f --- /dev/null +++ b/test/files/run/t5313.scala @@ -0,0 +1,54 @@ +import scala.tools.partest.IcodeTest + +object Test extends IcodeTest { + override def printIcodeAfterPhase = "dce" + + override def extraSettings: String = super.extraSettings + " -optimize" + + override def code = + """class Foo { + def randomBoolean = util.Random.nextInt % 2 == 0 + def bar = { + var kept1 = new Object + val result = new java.lang.ref.WeakReference(kept1) + kept1 = null // we can't eliminate this assigment because result can observe + // when the object has no more references. See SI-5313 + kept1 = new Object // but we can eliminate this one because kept1 has already been clobbered + var erased2 = null // we can eliminate this store because it's never used + val erased3 = erased2 // and this + var erased4 = erased2 // and this + val erased5 = erased4 // and this + var kept2: Object = new Object // ultimately can't be eliminated + while(randomBoolean) { + val kept3 = kept2 + kept2 = null // this can't, because it clobbers kept2, which is used + erased4 = null // safe to eliminate + println(kept3) + } + var kept4 = new Object // have to keep, it's used + try + println(kept4) + catch { + case _ : Throwable => kept4 = null // have to keep, it clobbers kept4 which is used + } + var kept5 = new Object + print(kept5) + kept5 = null // can't eliminate it's a clobber and it's used + print(kept5) + kept5 = null // can eliminate because we don't care about clobbers of nulls + while(randomBoolean) { + var kept6: AnyRef = null // not used, but have to keep because it clobbers the next used store + // on the back edge of the loop + kept6 = new Object // used + println(kept6) + } + result + } + }""".stripMargin + + override def show() { + val storeLocal = "STORE_LOCAL" + val lines1 = collectIcode("") filter (_ contains storeLocal) map (x => x.drop(x.indexOf(storeLocal))) + println(lines1 mkString "\n") + } +} diff --git a/test/files/run/t5374.check b/test/files/run/t5374.check deleted file mode 100644 index c1cd843080..0000000000 --- a/test/files/run/t5374.check +++ /dev/null @@ -1,5 +0,0 @@ -ListBuffer(1, 2, 3, 1) -ListBuffer(1, 2, 3, 1) -ListBuffer() -List(1, 2, 3, 4, 5) -ok diff --git a/test/files/run/t5374.scala b/test/files/run/t5374.scala deleted file mode 100644 index f6a913e35c..0000000000 --- a/test/files/run/t5374.scala +++ /dev/null @@ -1,76 +0,0 @@ - - - -import collection.mutable.ListBuffer -import java.io._ - - - -object Test { - - def main(args: Array[String]) { - ticketExample() - emptyListBuffer() - list() - // legacyList() - objectWithMultipleLists() - } - - def inAndOut[T <: AnyRef](obj: T): T = { - val baos = new ByteArrayOutputStream - val oos = new ObjectOutputStream(baos) - oos.writeObject( obj ) - val bais = new ByteArrayInputStream( baos.toByteArray ) - val ois = new ObjectInputStream(bais) - ois.readObject.asInstanceOf[T] - } - - def ticketExample() { - val lb = inAndOut(ListBuffer(1, 2, 3)) - val lb2 = ListBuffer[Int]() ++= lb - - lb2 ++= List(1) - lb ++= List(1) - println(lb) - println(lb2) - } - - def emptyListBuffer() { - val lb = inAndOut(ListBuffer[Int]()) - - println(lb) - } - - def list() { - val l = inAndOut(List(1, 2, 3, 4, 5)) - - println(l) - } - - // this byte array corresponds to what List(1, 2, 3) used to be serialized to prior to this fix - val listBytes = Array[Byte](-84, -19, 0, 5, 115, 114, 0, 39, 115, 99, 97, 108, 97, 46, 99, 111, 108, 108, 101, 99, 116, 105, 111, 110, 46, 105, 109, 109, 117, 116, 97, 98, 108, 101, 46, 36, 99, 111, 108, 111, 110, 36, 99, 111, 108, 111, 110, -118, 92, 99, 91, -10, -40, -7, 109, 3, 0, 2, 76, 0, 43, 115, 99, 97, 108, 97, 36, 99, 111, 108, 108, 101, 99, 116, 105, 111, 110, 36, 105, 109, 109, 117, 116, 97, 98, 108, 101, 36, 36, 99, 111, 108, 111, 110, 36, 99, 111, 108, 111, 110, 36, 36, 104, 100, 116, 0, 18, 76, 106, 97, 118, 97, 47, 108, 97, 110, 103, 47, 79, 98, 106, 101, 99, 116, 59, 76, 0, 2, 116, 108, 116, 0, 33, 76, 115, 99, 97, 108, 97, 47, 99, 111, 108, 108, 101, 99, 116, 105, 111, 110, 47, 105, 109, 109, 117, 116, 97, 98, 108, 101, 47, 76, 105, 115, 116, 59, 120, 112, 115, 114, 0, 17, 106, 97, 118, 97, 46, 108, 97, 110, 103, 46, 73, 110, 116, 101, 103, 101, 114, 18, -30, -96, -92, -9, -127, -121, 56, 2, 0, 1, 73, 0, 5, 118, 97, 108, 117, 101, 120, 114, 0, 16, 106, 97, 118, 97, 46, 108, 97, 110, 103, 46, 78, 117, 109, 98, 101, 114, -122, -84, -107, 29, 11, -108, -32, -117, 2, 0, 0, 120, 112, 0, 0, 0, 1, 115, 113, 0, 126, 0, 4, 0, 0, 0, 2, 115, 113, 0, 126, 0, 4, 0, 0, 0, 3, 115, 114, 0, 44, 115, 99, 97, 108, 97, 46, 99, 111, 108, 108, 101, 99, 116, 105, 111, 110, 46, 105, 109, 109, 117, 116, 97, 98, 108, 101, 46, 76, 105, 115, 116, 83, 101, 114, 105, 97, 108, 105, 122, 101, 69, 110, 100, 36, -118, 92, 99, 91, -9, 83, 11, 109, 2, 0, 0, 120, 112, 120) - - // def legacyList() { - // val bais = new ByteArrayInputStream(listBytes) - // val ois = new ObjectInputStream(bais) - // val l = ois.readObject() - - // println(l) - // } - - class Foo extends Serializable { - val head = List(1, 2, 3) - val last = head.tail.tail - def structuralSharing: Boolean = head.tail.tail eq last - - assert(structuralSharing) - } - - def objectWithMultipleLists() { - val foo = inAndOut(new Foo) - - if (foo.structuralSharing) println("ok") - else println("no structural sharing") - } - -} diff --git a/test/files/run/t5824.check b/test/files/run/t5824.check new file mode 100644 index 0000000000..3774da60e5 --- /dev/null +++ b/test/files/run/t5824.check @@ -0,0 +1 @@ +a b c diff --git a/test/files/run/t5824.scala b/test/files/run/t5824.scala new file mode 100644 index 0000000000..2ad169e2d1 --- /dev/null +++ b/test/files/run/t5824.scala @@ -0,0 +1,8 @@ +import scala.reflect.runtime.universe._ +import scala.tools.reflect.Eval + +object Test extends App { + reify { + println("%s %s %s".format(List("a", "b", "c"): _*)) + }.eval +} diff --git a/test/files/run/t6028.check b/test/files/run/t6028.check index 942f3d5f0c..67c30e35c6 100644 --- a/test/files/run/t6028.check +++ b/test/files/run/t6028.check @@ -81,4 +81,4 @@ package <empty> { } } -warning: there were 1 feature warnings; re-run with -feature for details +warning: there were 1 feature warning(s); re-run with -feature for details diff --git a/test/files/run/t6113.check b/test/files/run/t6113.check new file mode 100644 index 0000000000..65fb3cd090 --- /dev/null +++ b/test/files/run/t6113.check @@ -0,0 +1 @@ +Foo[[X](Int, X)] diff --git a/test/files/run/t6113.scala b/test/files/run/t6113.scala new file mode 100644 index 0000000000..321cae86a3 --- /dev/null +++ b/test/files/run/t6113.scala @@ -0,0 +1,6 @@ +trait Foo[C[_]] + +object Test extends App { + import scala.reflect.runtime.universe._ + println(typeOf[Foo[({type l[X] = (Int, X)})#l]]) +}
\ No newline at end of file diff --git a/test/files/run/t6146b.check b/test/files/run/t6146b.check new file mode 100644 index 0000000000..b664d1152a --- /dev/null +++ b/test/files/run/t6146b.check @@ -0,0 +1,52 @@ +Type in expressions to have them evaluated. +Type :help for more information. + +scala> :power +** Power User mode enabled - BEEP WHIR GYVE ** +** :phase has been set to 'typer'. ** +** scala.tools.nsc._ has been imported ** +** global._, definitions._ also imported ** +** Try :help, :vals, power.<tab> ** + +scala> val u = rootMirror.universe; import u._, language._ +u: $r.intp.global.type = <global> +import u._ +import language._ + +scala> val S1 = typeOf[c.X.S1.type forSome { val c: C[_] }].typeSymbol.tpeHK +S1: u.Type = C.X.S1.type + +scala> val S2 = typeOf[O.S2].typeSymbol.tpeHK +S2: u.Type = C.this.S2 + +scala> val S3 = typeOf[O.S3].typeSymbol.tpeHK +S3: u.Type = O.S3 + +scala> val S4 = typeOf[S4].typeSymbol.tpeHK +S4: u.Type = S4 + +scala> val F = typeOf[c.F[_] forSome { val c: C[_] }].typeSymbol.tpeHK +F: u.Type = C.this.F + +scala> val fTpe = typeOf[O.type].decl(newTermName("foo")).paramss.head.head.tpe +fTpe: u.Type = O.F[Int] + +scala> def memType(sub: Type, scrut: Type): Type = + nestedMemberType(sub.typeSymbol, scrut.prefix, scrut.typeSymbol.owner) +memType: (sub: u.Type, scrut: u.Type)u.Type + +scala> + +scala> memType(S1, fTpe) +res0: u.Type = O.X.S1.type + +scala> memType(S2, fTpe) +res1: u.Type = O.S2 + +scala> memType(S3, fTpe) +res2: u.Type = O.S3 + +scala> memType(S4, fTpe) +res3: u.Type = S4 + +scala> diff --git a/test/files/run/t6146b.scala b/test/files/run/t6146b.scala new file mode 100644 index 0000000000..adcd40d2ee --- /dev/null +++ b/test/files/run/t6146b.scala @@ -0,0 +1,39 @@ +import scala.tools.partest.ReplTest + +class A { + sealed trait F[A] +} + +class C[T] extends A { + sealed trait F[A] + object X { + object S1 extends F[T] + } + class S2 extends F[T] +} +object O extends C[Int] { + def foo(f: F[Int]) = f match { case X.S1 => } + + class S3 extends F[Int] +} +class S4 extends O.F[String] + +object Test extends ReplTest { + override def code = """ +:power +val u = rootMirror.universe; import u._, language._ +val S1 = typeOf[c.X.S1.type forSome { val c: C[_] }].typeSymbol.tpeHK +val S2 = typeOf[O.S2].typeSymbol.tpeHK +val S3 = typeOf[O.S3].typeSymbol.tpeHK +val S4 = typeOf[S4].typeSymbol.tpeHK +val F = typeOf[c.F[_] forSome { val c: C[_] }].typeSymbol.tpeHK +val fTpe = typeOf[O.type].decl(newTermName("foo")).paramss.head.head.tpe +def memType(sub: Type, scrut: Type): Type = + nestedMemberType(sub.typeSymbol, scrut.prefix, scrut.typeSymbol.owner) + +memType(S1, fTpe) +memType(S2, fTpe) +memType(S3, fTpe) +memType(S4, fTpe) + """.stripMargin.trim +}
\ No newline at end of file diff --git a/test/files/run/t6187.check b/test/files/run/t6187.check new file mode 100644 index 0000000000..621306b2ef --- /dev/null +++ b/test/files/run/t6187.check @@ -0,0 +1,32 @@ +Type in expressions to have them evaluated. +Type :help for more information. + +scala> import language.experimental.macros, reflect.macros.Context +import language.experimental.macros +import reflect.macros.Context + +scala> def macroImpl[T: c.WeakTypeTag](c: Context)(t: c.Expr[T]): c.Expr[List[T]] = { + val r = c.universe.reify { List(t.splice) } + c.Expr[List[T]]( c.resetLocalAttrs(r.tree) ) +} +macroImpl: [T](c: scala.reflect.macros.Context)(t: c.Expr[T])(implicit evidence$1: c.WeakTypeTag[T])c.Expr[List[T]] + +scala> def demo[T](t: T): List[T] = macro macroImpl[T] +defined term macro demo: [T](t: T)List[T] + +scala> def m[T](t: T): List[List[T]] = + demo( List((t,true)) collect { case (x,true) => x } ) +m: [T](t: T)List[List[T]] + +scala> m(List(1)) +res0: List[List[List[Int]]] = List(List(List(1))) + +scala> // Showing we haven't added unreachable warnings + +scala> List(1) collect { case x => x } +res1: List[Int] = List(1) + +scala> List("") collect { case x => x } +res2: List[String] = List("") + +scala> diff --git a/test/files/run/t6187.scala b/test/files/run/t6187.scala new file mode 100644 index 0000000000..ae642917e7 --- /dev/null +++ b/test/files/run/t6187.scala @@ -0,0 +1,18 @@ +import scala.tools.partest.ReplTest + +object Test extends ReplTest { + override def code = """ +import language.experimental.macros, reflect.macros.Context +def macroImpl[T: c.WeakTypeTag](c: Context)(t: c.Expr[T]): c.Expr[List[T]] = { + val r = c.universe.reify { List(t.splice) } + c.Expr[List[T]]( c.resetLocalAttrs(r.tree) ) +} +def demo[T](t: T): List[T] = macro macroImpl[T] +def m[T](t: T): List[List[T]] = + demo( List((t,true)) collect { case (x,true) => x } ) +m(List(1)) +// Showing we haven't added unreachable warnings +List(1) collect { case x => x } +List("") collect { case x => x } + """.trim +} diff --git a/test/files/run/t6187b.scala b/test/files/run/t6187b.scala new file mode 100644 index 0000000000..d2d3e9797d --- /dev/null +++ b/test/files/run/t6187b.scala @@ -0,0 +1,5 @@ +object Test extends App { + val x: PartialFunction[Int, Int] = { case 1 => 1 } + val o: Any = "" + assert(x.applyOrElse(0, (_: Int) => o) == "") +} diff --git a/test/files/pos/t6259.scala b/test/files/run/t6259.scala index 43361c417e..294c95e96b 100644 --- a/test/files/pos/t6259.scala +++ b/test/files/run/t6259.scala @@ -1,5 +1,3 @@ -package t6259 - import scala.reflect.runtime.universe._ class A[X](implicit val tt: TypeTag[X]) {} @@ -17,16 +15,15 @@ class G { object H extends A[String] } -object Test { +object HasX { val x = { object InVal extends A[String] + InVal 5 } } -// Note: Both of these fail right now. - trait NeedsEarly { val x: AnyRef } @@ -45,3 +42,15 @@ object DoubleOk extends DoubleTrouble[String]({ InnerTrouble }) +object Test extends App { + B + C.D + val e = new E {}; e.F + val g = new G; g.H + + locally(HasX.x) + // locally(Early.x) TODO sort out VerifyError in Early$.<init> + // DoubleOk TODO sort out VerifyError in DoubleOk$.<init> +} + + diff --git a/test/files/run/t6288.check b/test/files/run/t6288.check index 0a8ff0b92d..4465b6302c 100644 --- a/test/files/run/t6288.check +++ b/test/files/run/t6288.check @@ -11,10 +11,7 @@ [64]case5()[84]{ [84]<synthetic> val o7: [84]Option[Int] = [84][84]Case3.unapply([84]x1); [84]if ([84]o7.isEmpty.unary_!) - [84]{ - [90]val nr: [90]Int = [90]o7.get; - [97][97]matchEnd4([97]()) - } + [97][97]matchEnd4([97]()) else [84][84]case6() }; @@ -38,10 +35,7 @@ [195]<synthetic> val o7: [195]Option[List[Int]] = [195][195]Case4.unapplySeq([195]x1); [195]if ([195]o7.isEmpty.unary_!) [195]if ([195][195][195][195]o7.get.!=([195]null).&&([195][195][195][195]o7.get.lengthCompare([195]1).==([195]0))) - [195]{ - [201]val nr: [201]Int = [201][201]o7.get.apply([201]0); - [208][208]matchEnd4([208]()) - } + [208][208]matchEnd4([208]()) else [195][195]case6() else diff --git a/test/files/run/t6288b-jump-position.check b/test/files/run/t6288b-jump-position.check index 45ec31c308..ece88b18f0 100644 --- a/test/files/run/t6288b-jump-position.check +++ b/test/files/run/t6288b-jump-position.check @@ -19,7 +19,7 @@ object Case3 extends Object { Exception handlers: def main(args: Array[String] (ARRAY[REF(class String)])): Unit { - locals: value args, value x1, value x2, value x + locals: value args, value x1, value x startBlock: 1 blocks: [1,2,3,6,7] @@ -35,10 +35,6 @@ object Case3 extends Object { 5 CZJUMP (BOOL)NE ? 3 : 6 3: - 5 LOAD_LOCAL(value x1) - 5 CHECK_CAST REF(class String) - 5 STORE_LOCAL(value x2) - 5 SCOPE_ENTER value x2 6 LOAD_MODULE object Predef 6 CONSTANT("case 0") 6 CALL_METHOD scala.Predef.println (dynamic) diff --git a/test/files/run/t6329_repl.check b/test/files/run/t6329_repl.check index 55d689f2fb..3480bbdd0b 100644 --- a/test/files/run/t6329_repl.check +++ b/test/files/run/t6329_repl.check @@ -7,28 +7,28 @@ scala> import scala.reflect.classTag import scala.reflect.classTag scala> classManifest[scala.List[_]] -warning: there were 1 deprecation warnings; re-run with -deprecation for details +warning: there were 1 deprecation warning(s); re-run with -deprecation for details res0: scala.reflect.ClassTag[List[_]] = scala.collection.immutable.List[<?>] scala> classTag[scala.List[_]] res1: scala.reflect.ClassTag[List[_]] = scala.collection.immutable.List scala> classManifest[scala.collection.immutable.List[_]] -warning: there were 1 deprecation warnings; re-run with -deprecation for details +warning: there were 1 deprecation warning(s); re-run with -deprecation for details res2: scala.reflect.ClassTag[List[_]] = scala.collection.immutable.List[<?>] scala> classTag[scala.collection.immutable.List[_]] res3: scala.reflect.ClassTag[List[_]] = scala.collection.immutable.List scala> classManifest[Predef.Set[_]] -warning: there were 1 deprecation warnings; re-run with -deprecation for details +warning: there were 1 deprecation warning(s); re-run with -deprecation for details res4: scala.reflect.ClassTag[scala.collection.immutable.Set[_]] = scala.collection.immutable.Set[<?>] scala> classTag[Predef.Set[_]] res5: scala.reflect.ClassTag[scala.collection.immutable.Set[_]] = scala.collection.immutable.Set scala> classManifest[scala.collection.immutable.Set[_]] -warning: there were 1 deprecation warnings; re-run with -deprecation for details +warning: there were 1 deprecation warning(s); re-run with -deprecation for details res6: scala.reflect.ClassTag[scala.collection.immutable.Set[_]] = scala.collection.immutable.Set[<?>] scala> classTag[scala.collection.immutable.Set[_]] diff --git a/test/files/run/t6506.scala b/test/files/run/t6506.scala new file mode 100644 index 0000000000..04d77c3c16 --- /dev/null +++ b/test/files/run/t6506.scala @@ -0,0 +1,8 @@ +object Test { + def main(args: Array[String]) { + new WL(new {} #:: S) with T + } + object S { def #::(a: Any): Any = () } + trait T + class WL(a: Any) +} diff --git a/test/files/run/t6548.check b/test/files/run/t6548.check index e82cae110a..5dfcb12e02 100644 --- a/test/files/run/t6548.check +++ b/test/files/run/t6548.check @@ -1,2 +1,2 @@ false -List(JavaAnnotationWithNestedEnum(value = VALUE)) +List(JavaAnnotationWithNestedEnum_1(value = VALUE)) diff --git a/test/files/run/t6548/JavaAnnotationWithNestedEnum_1.java b/test/files/run/t6548/JavaAnnotationWithNestedEnum_1.java new file mode 100644 index 0000000000..32004de537 --- /dev/null +++ b/test/files/run/t6548/JavaAnnotationWithNestedEnum_1.java @@ -0,0 +1,17 @@ +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target({ElementType.ANNOTATION_TYPE, ElementType.METHOD, ElementType.FIELD, + ElementType.TYPE, ElementType.PARAMETER}) +@Retention(RetentionPolicy.RUNTIME) +public @interface JavaAnnotationWithNestedEnum_1 +{ + public Value value() default Value.VALUE; + + public enum Value + { + VALUE; + } +}
\ No newline at end of file diff --git a/test/files/run/t6548.scala b/test/files/run/t6548/Test_2.scala index b4d09fd8f6..7200259d36 100644 --- a/test/files/run/t6548.scala +++ b/test/files/run/t6548/Test_2.scala @@ -2,7 +2,7 @@ import scala.reflect.runtime.universe._ import scala.reflect.runtime.{currentMirror => cm} class Bean { - @JavaAnnotationWithNestedEnum(JavaAnnotationWithNestedEnum.Value.VALUE) + @JavaAnnotationWithNestedEnum_1(JavaAnnotationWithNestedEnum_1.Value.VALUE) def value = 1 } diff --git a/test/files/run/t6591_1.check b/test/files/run/t6591_1.check new file mode 100644 index 0000000000..d1d448f283 --- /dev/null +++ b/test/files/run/t6591_1.check @@ -0,0 +1 @@ +Block(List(ValDef(Modifiers(), TermName("v"), Select(Ident(A), TypeName("I")), Select(Ident(A), TermName("impl")))), Ident(TermName("v"))) diff --git a/test/files/run/t6591_1.scala b/test/files/run/t6591_1.scala new file mode 100644 index 0000000000..6dd9a1d9fb --- /dev/null +++ b/test/files/run/t6591_1.scala @@ -0,0 +1,19 @@ +import scala.reflect.runtime.universe._ +import scala.tools.reflect.ToolBox +import scala.tools.reflect.Eval + +trait O { trait I } + +object A extends O { + val impl = new I {} +} + +object Test extends App { + val code = reify { + val v: A.I = A.impl + v + } + println(showRaw(code.tree)) + + val v: A.I = code.eval +} diff --git a/test/files/run/t6591_2.check b/test/files/run/t6591_2.check new file mode 100644 index 0000000000..8c972ef920 --- /dev/null +++ b/test/files/run/t6591_2.check @@ -0,0 +1 @@ +Block(List(ValDef(Modifiers(), TermName("v"), SelectFromTypeTree(Ident(A), TypeName("I")), Select(Apply(Select(New(Ident(A)), nme.CONSTRUCTOR), List()), TermName("impl")))), Ident(TermName("v"))) diff --git a/test/files/run/t6591_2.scala b/test/files/run/t6591_2.scala new file mode 100644 index 0000000000..6214308dab --- /dev/null +++ b/test/files/run/t6591_2.scala @@ -0,0 +1,19 @@ +import scala.reflect.runtime.universe._ +import scala.tools.reflect.ToolBox +import scala.tools.reflect.Eval + +trait O { trait I } + +class A extends O { + val impl = new I {} +} + +object Test extends App { + val code = reify { + val v: A#I = (new A).impl + v + } + println(showRaw(code.tree)) + + val v: A#I = code.eval +} diff --git a/test/files/run/t6591_3.check b/test/files/run/t6591_3.check new file mode 100644 index 0000000000..f4592adce9 --- /dev/null +++ b/test/files/run/t6591_3.check @@ -0,0 +1 @@ +Block(List(ValDef(Modifiers(), TermName("v"), Select(This(TypeName("A")), TypeName("I")), Apply(Select(New(Select(This(TypeName("A")), TypeName("I"))), nme.CONSTRUCTOR), List()))), Ident(TermName("v"))) diff --git a/test/files/run/t6591_3.scala b/test/files/run/t6591_3.scala new file mode 100644 index 0000000000..b73a7baf48 --- /dev/null +++ b/test/files/run/t6591_3.scala @@ -0,0 +1,17 @@ +import scala.reflect.runtime.universe._ +import scala.tools.reflect.ToolBox +import scala.tools.reflect.Eval + +class O { class I } + +object A extends O { + val code = reify { + val v: I = new I + v + } + println(showRaw(code.tree)) +} + +object Test extends App { + val v: A.I = A.code.eval +} diff --git a/test/files/run/t6591_5.check b/test/files/run/t6591_5.check new file mode 100644 index 0000000000..4ebc2236af --- /dev/null +++ b/test/files/run/t6591_5.check @@ -0,0 +1 @@ +Expr(Block(List(ValDef(Modifiers(), TermName("v"), Select(Select(This(TypeName("A")), TermName("x")), TypeName("I")), Select(Ident(scala.Predef), TermName("$qmark$qmark$qmark")))), Ident(TermName("v")))) diff --git a/test/files/run/t6591_5.scala b/test/files/run/t6591_5.scala new file mode 100644 index 0000000000..18d6f90a9b --- /dev/null +++ b/test/files/run/t6591_5.scala @@ -0,0 +1,23 @@ +import scala.reflect.runtime.universe._ +import scala.tools.reflect.ToolBox +import scala.tools.reflect.Eval +import java.lang.reflect.InvocationTargetException + +class O { class I } + +object A extends O { + val x = new O + val code = reify { + val v: x.I = ??? + v + } + println(showRaw(code)) +} + +object Test extends App { + try { + val v: A.x.I = A.code.eval + } catch { + case ex: InvocationTargetException if ex.getCause.isInstanceOf[NotImplementedError] => + } +} diff --git a/test/files/run/t6591_6.check b/test/files/run/t6591_6.check new file mode 100644 index 0000000000..940e2026fe --- /dev/null +++ b/test/files/run/t6591_6.check @@ -0,0 +1 @@ +Expr(Block(List(ValDef(Modifiers(), TermName("v"), Select(Select(Ident(TermName("A")), TermName("x")), TypeName("I")), Select(Ident(scala.Predef), TermName("$qmark$qmark$qmark")))), Ident(TermName("v")))) diff --git a/test/files/run/t6591_6.scala b/test/files/run/t6591_6.scala new file mode 100644 index 0000000000..2eee87928d --- /dev/null +++ b/test/files/run/t6591_6.scala @@ -0,0 +1,24 @@ +import scala.language.existentials +import scala.reflect.runtime.universe._ +import scala.tools.reflect.ToolBox +import scala.tools.reflect.Eval +import java.lang.reflect.InvocationTargetException + +class O { class I } + +class A extends O { + val x = new O + val code = reify { + val v: x.I = ??? + v + } + println(showRaw(code)) +} + +object Test extends App { + try { + val v = (new A).code.eval + } catch { + case ex: InvocationTargetException if ex.getCause.isInstanceOf[NotImplementedError] => + } +} diff --git a/test/files/run/t6591_7.check b/test/files/run/t6591_7.check new file mode 100644 index 0000000000..e21a3669b6 --- /dev/null +++ b/test/files/run/t6591_7.check @@ -0,0 +1,4 @@ +name = x, stable = true +name = y, stable = true +name = z, stable = false +name = C, stable = true diff --git a/test/files/run/t6591_7.scala b/test/files/run/t6591_7.scala new file mode 100644 index 0000000000..b6c8d399a0 --- /dev/null +++ b/test/files/run/t6591_7.scala @@ -0,0 +1,26 @@ +import scala.reflect.runtime.universe._ +import scala.tools.reflect.Eval + +object Test extends App { + locally { + val x = 2 + def y = 3 + var z = 4 + class C { + var w = 5 + locally { + val expr = reify(x + y + z + w) + // blocked by SI-7103, though it's not the focus of this test + // therefore I'm just commenting out the evaluation + // println(expr.eval) + expr.tree.freeTerms foreach (ft => { + // blocked by SI-7104, though it's not the focus of this test + // therefore I'm just commenting out the call to typeSignature + // println(s"name = ${ft.name}, sig = ${ft.typeSignature}, stable = ${ft.isStable}") + println(s"name = ${ft.name}, stable = ${ft.isStable}") + }) + } + } + new C() + } +}
\ No newline at end of file diff --git a/test/files/run/t6666a.scala b/test/files/run/t6666a.scala new file mode 100644 index 0000000000..1d208a32e7 --- /dev/null +++ b/test/files/run/t6666a.scala @@ -0,0 +1,16 @@ +class A(a: Any) + +object Test { + def main(args: Array[String]): Unit = { + } + + val x: Unit = { + object InVal extends A({ + new {} // okay + val o = {new {}} // nesting triggers a VerifyError. + null + }); + InVal; + () + }; +} diff --git a/test/files/run/t6888.check b/test/files/run/t6888.check new file mode 100644 index 0000000000..4e8a2de2db --- /dev/null +++ b/test/files/run/t6888.check @@ -0,0 +1,3 @@ +2 +3 +3 diff --git a/test/files/run/t6888.scala b/test/files/run/t6888.scala new file mode 100644 index 0000000000..0c64cbe5b6 --- /dev/null +++ b/test/files/run/t6888.scala @@ -0,0 +1,19 @@ +class C { + val x = 1 + object $ { + val y = x + x + class abc$ { + def xy = x + y + } + object abc$ { + def xy = x + y + } + } +} + +object Test extends App { + val c = new C() + println(c.$.y) + println(c.$.abc$.xy) + println(new c.$.abc$().xy) +} diff --git a/test/files/run/t6957.scala b/test/files/run/t6957.scala new file mode 100644 index 0000000000..d0bf8e7b5e --- /dev/null +++ b/test/files/run/t6957.scala @@ -0,0 +1,8 @@ +object Test { + def main(args: Array[String]) { + class Foo + class Parent(f:Foo) + class Child extends Parent({val x=new Foo{}; x}) + new Child + } +} diff --git a/test/files/run/t6989.check b/test/files/run/t6989.check new file mode 100644 index 0000000000..8943792115 --- /dev/null +++ b/test/files/run/t6989.check @@ -0,0 +1,216 @@ +============ +sym = class PackagePrivateJavaClass, signature = ClassInfoType(...), owner = package foo +isPrivate = false +isProtected = false +isPublic = false +privateWithin = package foo +============ +sym = constructor PackagePrivateJavaClass, signature = (x$1: Int, x$2: Int)foo.PackagePrivateJavaClass, owner = class PackagePrivateJavaClass +isPrivate = false +isProtected = false +isPublic = true +privateWithin = <none> +============ +sym = variable privateField, signature = Int, owner = class PackagePrivateJavaClass +isPrivate = true +isProtected = false +isPublic = false +privateWithin = <none> +============ +sym = method privateMethod, signature = ()Unit, owner = class PackagePrivateJavaClass +isPrivate = true +isProtected = false +isPublic = false +privateWithin = <none> +============ +sym = variable protectedField, signature = Int, owner = class PackagePrivateJavaClass +isPrivate = false +isProtected = true +isPublic = false +privateWithin = package foo +============ +sym = method protectedMethod, signature = ()Unit, owner = class PackagePrivateJavaClass +isPrivate = false +isProtected = true +isPublic = false +privateWithin = package foo +============ +sym = variable publicField, signature = Int, owner = class PackagePrivateJavaClass +isPrivate = false +isProtected = false +isPublic = true +privateWithin = <none> +============ +sym = method publicMethod, signature = ()Unit, owner = class PackagePrivateJavaClass +isPrivate = false +isProtected = false +isPublic = true +privateWithin = <none> +============ +sym = object PackagePrivateJavaClass, signature = foo.PackagePrivateJavaClass.type, owner = package foo +isPrivate = false +isProtected = false +isPublic = false +privateWithin = package foo +============ +sym = variable privateStaticField, signature = Int, owner = object PackagePrivateJavaClass +isPrivate = true +isProtected = false +isPublic = false +privateWithin = <none> +============ +sym = method privateStaticMethod, signature = ()Unit, owner = object PackagePrivateJavaClass +isPrivate = true +isProtected = false +isPublic = false +privateWithin = <none> +============ +sym = variable protectedStaticField, signature = Int, owner = object PackagePrivateJavaClass +isPrivate = false +isProtected = true +isPublic = false +privateWithin = package foo +============ +sym = method protectedStaticMethod, signature = ()Unit, owner = object PackagePrivateJavaClass +isPrivate = false +isProtected = true +isPublic = false +privateWithin = package foo +============ +sym = variable publicStaticField, signature = Int, owner = object PackagePrivateJavaClass +isPrivate = false +isProtected = false +isPublic = true +privateWithin = <none> +============ +sym = method publicStaticMethod, signature = ()Unit, owner = object PackagePrivateJavaClass +isPrivate = false +isProtected = false +isPublic = true +privateWithin = <none> +============ +sym = class JavaClass_1, signature = ClassInfoType(...), owner = package foo +isPrivate = false +isProtected = false +isPublic = true +privateWithin = <none> +============ +sym = class $PrivateJavaClass, signature = ClassInfoType(...), owner = class JavaClass_1 +isPrivate = true +isProtected = false +isPublic = false +privateWithin = <none> +============ +sym = value this$0, signature = foo.JavaClass_1, owner = class $PrivateJavaClass +isPrivate = false +isProtected = false +isPublic = false +privateWithin = package foo +============ +sym = object $PrivateJavaClass, signature = JavaClass_1.this.$PrivateJavaClass.type, owner = class JavaClass_1 +isPrivate = true +isProtected = false +isPublic = false +privateWithin = <none> +============ +sym = class $ProtectedJavaClass, signature = ClassInfoType(...), owner = class JavaClass_1 +isPrivate = false +isProtected = true +isPublic = false +privateWithin = package foo +============ +sym = value this$0, signature = foo.JavaClass_1, owner = class $ProtectedJavaClass +isPrivate = false +isProtected = false +isPublic = false +privateWithin = package foo +============ +sym = object $ProtectedJavaClass, signature = JavaClass_1.this.$ProtectedJavaClass.type, owner = class JavaClass_1 +isPrivate = false +isProtected = false +isPublic = false +privateWithin = package foo +============ +sym = class $PublicJavaClass, signature = ClassInfoType(...), owner = class JavaClass_1 +isPrivate = false +isProtected = false +isPublic = true +privateWithin = <none> +============ +sym = constructor $PublicJavaClass, signature = (x$1: foo.JavaClass_1)JavaClass_1.this.$PublicJavaClass, owner = class $PublicJavaClass +isPrivate = false +isProtected = false +isPublic = true +privateWithin = <none> +============ +sym = value this$0, signature = foo.JavaClass_1, owner = class $PublicJavaClass +isPrivate = false +isProtected = false +isPublic = false +privateWithin = package foo +============ +sym = object $PublicJavaClass, signature = JavaClass_1.this.$PublicJavaClass.type, owner = class JavaClass_1 +isPrivate = false +isProtected = false +isPublic = true +privateWithin = <none> +============ +sym = constructor JavaClass_1, signature = ()foo.JavaClass_1, owner = class JavaClass_1 +isPrivate = false +isProtected = false +isPublic = true +privateWithin = <none> +============ +sym = object JavaClass_1, signature = foo.JavaClass_1.type, owner = package foo +isPrivate = false +isProtected = false +isPublic = true +privateWithin = <none> +============ +sym = class PrivateStaticJavaClass, signature = ClassInfoType(...), owner = object JavaClass_1 +isPrivate = true +isProtected = false +isPublic = false +privateWithin = <none> +============ +sym = object PrivateStaticJavaClass, signature = foo.JavaClass_1.PrivateStaticJavaClass.type, owner = object JavaClass_1 +isPrivate = true +isProtected = false +isPublic = false +privateWithin = <none> +============ +sym = class ProtectedStaticJavaClass, signature = ClassInfoType(...), owner = object JavaClass_1 +isPrivate = true +isProtected = false +isPublic = false +privateWithin = <none> +============ +sym = object ProtectedStaticJavaClass, signature = foo.JavaClass_1.ProtectedStaticJavaClass.type, owner = object JavaClass_1 +isPrivate = true +isProtected = false +isPublic = false +privateWithin = <none> +============ +sym = class PublicStaticJavaClass, signature = ClassInfoType(...), owner = object JavaClass_1 +isPrivate = false +isProtected = false +isPublic = true +privateWithin = <none> +============ +sym = constructor PublicStaticJavaClass, signature = ()foo.JavaClass_1.PublicStaticJavaClass, owner = class PublicStaticJavaClass +isPrivate = false +isProtected = false +isPublic = true +privateWithin = <none> +============ +sym = object PublicStaticJavaClass, signature = foo.JavaClass_1.PublicStaticJavaClass.type, owner = object JavaClass_1 +isPrivate = false +isProtected = false +isPublic = true +privateWithin = <none> +============ +sym = variable staticField, signature = Int, owner = object JavaClass_1 +isPrivate = true +isProtected = false +isPublic = false +privateWithin = <none> diff --git a/test/files/run/t6989/JavaClass_1.java b/test/files/run/t6989/JavaClass_1.java new file mode 100644 index 0000000000..eb26a08700 --- /dev/null +++ b/test/files/run/t6989/JavaClass_1.java @@ -0,0 +1,41 @@ +package foo; + +// Originally composed to accommodate pull request feedback, this test has +// uncovered a handful of bugs in FromJavaClassCompleter, namely: +// * SI-7071 non-public ctors get lost +// * SI-7072 inner classes are read incorrectly + +// I'm leaving the incorrect results of FromJavaClassCompleters in the check +// file, so that we get notified when something changes there. + +class PackagePrivateJavaClass { + private int privateField = 0; + protected int protectedField = 1; + public int publicField = 2; + + private static int privateStaticField = 3; + protected static int protectedStaticField = 4; + public static int publicStaticField = 5; + + private void privateMethod() {} + protected void protectedMethod() {} + public void publicMethod() {} + + private static void privateStaticMethod() {} + protected static void protectedStaticMethod() {} + public static void publicStaticMethod() {} + + private PackagePrivateJavaClass() {} + protected PackagePrivateJavaClass(int x) {} + public PackagePrivateJavaClass(int x, int y) {} +} + +public class JavaClass_1 { + private class PrivateJavaClass {} + private static class PrivateStaticJavaClass {} + protected class ProtectedJavaClass {} + private static class ProtectedStaticJavaClass {} + public class PublicJavaClass {} + public static class PublicStaticJavaClass {} + private static int staticField = 0; +}
\ No newline at end of file diff --git a/test/files/run/t6989/Test_2.scala b/test/files/run/t6989/Test_2.scala new file mode 100644 index 0000000000..e48e82422d --- /dev/null +++ b/test/files/run/t6989/Test_2.scala @@ -0,0 +1,42 @@ +import scala.reflect.runtime.universe._ + +// Originally composed to accommodate pull request feedback, this test has +// uncovered a handful of bugs in FromJavaClassCompleter, namely: +// * SI-7071 non-public ctors get lost +// * SI-7072 inner classes are read incorrectly + +// I'm leaving the incorrect results of FromJavaClassCompleters in the check +// file, so that we get notified when something changes there. + +package object foo { + def testAll(): Unit = { + test(typeOf[foo.PackagePrivateJavaClass].typeSymbol) + test(typeOf[foo.PackagePrivateJavaClass].typeSymbol.companionSymbol) + test(typeOf[foo.JavaClass_1].typeSymbol) + test(typeOf[foo.JavaClass_1].typeSymbol.companionSymbol) + } + + def test(sym: Symbol): Unit = { + printSymbolDetails(sym) + if (sym.isClass || sym.isModule) { + sym.typeSignature.declarations.toList.sortBy(_.name.toString) foreach test + } + } + + def printSymbolDetails(sym: Symbol): Unit = { + def stableSignature(sym: Symbol) = sym.typeSignature match { + case ClassInfoType(_, _, _) => "ClassInfoType(...)" + case tpe => tpe.toString + } + println("============") + println(s"sym = $sym, signature = ${stableSignature(sym)}, owner = ${sym.owner}") + println(s"isPrivate = ${sym.isPrivate}") + println(s"isProtected = ${sym.isProtected}") + println(s"isPublic = ${sym.isPublic}") + println(s"privateWithin = ${sym.privateWithin}") + } +} + +object Test extends App { + foo.testAll() +}
\ No newline at end of file diff --git a/test/files/run/t7008-scala-defined.check b/test/files/run/t7008-scala-defined.check new file mode 100644 index 0000000000..84ed62619e --- /dev/null +++ b/test/files/run/t7008-scala-defined.check @@ -0,0 +1,7 @@ +<init>: List(throws[NullPointerException]("")) +bar: List(throws[E1]("")) +baz: List(throws[IllegalStateException]("")) +============= +<init>: List(throws[NullPointerException]("")) +bar: List(throws[E1]("")) +baz: List(throws[IllegalStateException]("")) diff --git a/test/files/run/t7008-scala-defined/Impls_Macros_2.scala b/test/files/run/t7008-scala-defined/Impls_Macros_2.scala new file mode 100644 index 0000000000..94fd99018e --- /dev/null +++ b/test/files/run/t7008-scala-defined/Impls_Macros_2.scala @@ -0,0 +1,12 @@ +import language.experimental.macros +import scala.reflect.macros.Context + +object Macros { + def impl(c: Context) = { + val decls = c.typeOf[ScalaClassWithCheckedExceptions_1[_]].declarations.toList + val s = decls.sortBy(_.name.toString).map(decl => (s"${decl.name}: ${decl.annotations}")).mkString(scala.compat.Platform.EOL) + c.universe.reify(println(c.literal(s).splice)) + } + + def foo = macro impl +}
\ No newline at end of file diff --git a/test/files/run/t7008-scala-defined/ScalaClassWithCheckedExceptions_1.scala b/test/files/run/t7008-scala-defined/ScalaClassWithCheckedExceptions_1.scala new file mode 100644 index 0000000000..7783c873ec --- /dev/null +++ b/test/files/run/t7008-scala-defined/ScalaClassWithCheckedExceptions_1.scala @@ -0,0 +1,6 @@ +class ScalaClassWithCheckedExceptions_1[E1 <: Exception] @throws[NullPointerException]("") () { + @throws[E1]("") def bar() {} + @throws[IllegalStateException]("") def baz(x: Int) {} + // FIXME: SI-7066 + // @throws[E2]("") def foo[E2 <: Exception] {} +}
\ No newline at end of file diff --git a/test/files/run/t7008-scala-defined/Test_3.scala b/test/files/run/t7008-scala-defined/Test_3.scala new file mode 100644 index 0000000000..03bb79d311 --- /dev/null +++ b/test/files/run/t7008-scala-defined/Test_3.scala @@ -0,0 +1,9 @@ +import scala.reflect.runtime.universe._ + +object Test extends App { + Macros.foo + println("=============") + + val decls = typeOf[ScalaClassWithCheckedExceptions_1[_]].declarations.toList + decls sortBy (_.name.toString) foreach (decl => println(s"${decl.name}: ${decl.annotations}")) +}
\ No newline at end of file diff --git a/test/files/run/t7008.check b/test/files/run/t7008.check new file mode 100644 index 0000000000..ee077f90ff --- /dev/null +++ b/test/files/run/t7008.check @@ -0,0 +1,9 @@ +<init>: List(throws[NullPointerException](classOf[java.lang.NullPointerException])) +bar: List(throws[Exception](classOf[java.lang.Exception])) +baz: List(throws[IllegalStateException](classOf[java.lang.IllegalStateException])) +foo: List(throws[Exception](classOf[java.lang.Exception])) +============= +<init>: List(throws[java.lang.NullPointerException](classOf[java.lang.NullPointerException])) +bar: List(throws[java.lang.Exception](classOf[java.lang.Exception])) +baz: List(throws[java.lang.IllegalStateException](classOf[java.lang.IllegalStateException])) +foo: List(throws[java.lang.Exception](classOf[java.lang.Exception])) diff --git a/test/files/run/t7008/Impls_Macros_2.scala b/test/files/run/t7008/Impls_Macros_2.scala new file mode 100644 index 0000000000..7a17314085 --- /dev/null +++ b/test/files/run/t7008/Impls_Macros_2.scala @@ -0,0 +1,12 @@ +import language.experimental.macros +import scala.reflect.macros.Context + +object Macros { + def impl(c: Context) = { + val decls = c.typeOf[JavaClassWithCheckedExceptions_1[_]].declarations.toList + val s = decls.sortBy(_.name.toString).map(decl => (s"${decl.name}: ${decl.annotations}")).mkString(scala.compat.Platform.EOL) + c.universe.reify(println(c.literal(s).splice)) + } + + def foo = macro impl +}
\ No newline at end of file diff --git a/test/files/run/t7008/JavaClassWithCheckedExceptions_1.java b/test/files/run/t7008/JavaClassWithCheckedExceptions_1.java new file mode 100644 index 0000000000..dda2128302 --- /dev/null +++ b/test/files/run/t7008/JavaClassWithCheckedExceptions_1.java @@ -0,0 +1,7 @@ +class JavaClassWithCheckedExceptions_1<E1 extends Exception> { + public JavaClassWithCheckedExceptions_1() throws NullPointerException {} + + public void bar() throws E1 {} + public void baz(int x) throws IllegalStateException {} + public <E2 extends Exception> void foo() throws E2 {} +}
\ No newline at end of file diff --git a/test/files/run/t7008/Test_3.scala b/test/files/run/t7008/Test_3.scala new file mode 100644 index 0000000000..b2961a829e --- /dev/null +++ b/test/files/run/t7008/Test_3.scala @@ -0,0 +1,9 @@ +import scala.reflect.runtime.universe._ + +object Test extends App { + Macros.foo + println("=============") + + val decls = typeOf[JavaClassWithCheckedExceptions_1[_]].declarations.toList + decls sortBy (_.name.toString) foreach (decl => println(s"${decl.name}: ${decl.annotations}")) +}
\ No newline at end of file diff --git a/test/files/run/t7039.check b/test/files/run/t7039.check new file mode 100644 index 0000000000..954906040f --- /dev/null +++ b/test/files/run/t7039.check @@ -0,0 +1 @@ +Matched! diff --git a/test/files/run/t7039.scala b/test/files/run/t7039.scala new file mode 100644 index 0000000000..475c4ae267 --- /dev/null +++ b/test/files/run/t7039.scala @@ -0,0 +1,11 @@ +object UnapplySeqTest { + def unapplySeq(any: Any): Option[(Int, Seq[Int])] = Some((5, List(1))) +} + +object Test extends App { + null match { + case UnapplySeqTest(5) => println("uh-oh") + case UnapplySeqTest(5, 1) => println("Matched!") // compiles + case UnapplySeqTest(5, xs @ _*) => println("toooo long: "+ (xs: Seq[Int])) + } +}
\ No newline at end of file diff --git a/test/files/run/t7046.check b/test/files/run/t7046.check new file mode 100644 index 0000000000..427f1ce610 --- /dev/null +++ b/test/files/run/t7046.check @@ -0,0 +1,2 @@ +Set(class D, class E) +Set(class D, class E) diff --git a/test/files/run/t7046.scala b/test/files/run/t7046.scala new file mode 100644 index 0000000000..647a15cd18 --- /dev/null +++ b/test/files/run/t7046.scala @@ -0,0 +1,13 @@ +import scala.reflect.runtime.universe._ +import scala.reflect.runtime.{currentMirror => cm} + +sealed class C +class D extends C +class E extends C + +object Test extends App { + val c = cm.staticClass("C") + println(c.knownDirectSubclasses) + c.typeSignature + println(c.knownDirectSubclasses) +}
\ No newline at end of file diff --git a/test/files/run/t7096.check b/test/files/run/t7096.check new file mode 100644 index 0000000000..6f1cef6c43 --- /dev/null +++ b/test/files/run/t7096.check @@ -0,0 +1,2 @@ +testing symbol List(method foo, class Base, package ano, package <root>), param value x, xRefs List(x) +testing symbol List(method foo, class Sub, package ano, package <root>), param value x, xRefs List(x) diff --git a/test/files/run/t7096.scala b/test/files/run/t7096.scala new file mode 100644 index 0000000000..2a93dcc571 --- /dev/null +++ b/test/files/run/t7096.scala @@ -0,0 +1,36 @@ +import scala.tools.partest._ +import scala.tools.nsc._ + +object Test extends CompilerTest { + import global._ + import definitions._ + + override def code = """ +package ano + +class ann(x: Any) extends annotation.TypeConstraint + +abstract class Base { + def foo(x: String): String @ann(x.trim()) +} + +class Sub extends Base { + def foo(x: String): String @ann(x.trim()) = x +} + """ + + object syms extends SymsInPackage("ano") + import syms._ + + def check(source: String, unit: global.CompilationUnit) { + exitingTyper { + terms.filter(_.name.toString == "foo").foreach(sym => { + val xParam = sym.tpe.paramss.flatten.head + val annot = sym.tpe.finalResultType.annotations.head + val xRefs = annot.args.head.filter(t => t.symbol == xParam) + println(s"testing symbol ${sym.ownerChain}, param $xParam, xRefs $xRefs") + assert(xRefs.length == 1, xRefs) + }) + } + } +} diff --git a/test/files/run/t7106.check b/test/files/run/t7106.check new file mode 100644 index 0000000000..9a4bb430fd --- /dev/null +++ b/test/files/run/t7106.check @@ -0,0 +1,6 @@ +[ok] q1 I private final +[ok] q3 I private final +[ok] <init> (III)V public +[ok] bippy1 ()I public +[ok] bippy2 ()I public +[ok] bippy3 ()I public diff --git a/test/files/run/t7106/Analyzed_1.scala b/test/files/run/t7106/Analyzed_1.scala new file mode 100644 index 0000000000..a2ddebceed --- /dev/null +++ b/test/files/run/t7106/Analyzed_1.scala @@ -0,0 +1,14 @@ + +abstract class Base0 { def p2: Int } +class Base(p1: Int, override val p2: Int) extends Base0 + +abstract class Sub1(q1: Int, q2: Int, q3: Int) extends Base(q1, q2) { + def bippy1 = q1 + def bippy2 = q2 + def bippy3 = q3 +} +abstract class Sub2(q1: Int, q2: Int, q3: Int) extends Base(q1, q2) { + def bippy1 = q1 + def bippy2 = p2 + def bippy3 = q3 +} diff --git a/test/files/run/t7106/test.scala b/test/files/run/t7106/test.scala new file mode 100644 index 0000000000..3584a272db --- /dev/null +++ b/test/files/run/t7106/test.scala @@ -0,0 +1,10 @@ +import scala.tools.partest.BytecodeTest + +object Test extends BytecodeTest { + def show { + val node1 = loadClassNode("Sub1") + val node2 = loadClassNode("Sub2") + + sameMethodAndFieldSignatures(node1, node2) + } +} diff --git a/test/files/run/toolbox_typecheck_macrosdisabled2.check b/test/files/run/toolbox_typecheck_macrosdisabled2.check index 74dfb03666..bdcdb421fd 100644 --- a/test/files/run/toolbox_typecheck_macrosdisabled2.check +++ b/test/files/run/toolbox_typecheck_macrosdisabled2.check @@ -19,7 +19,7 @@ def apply[U <: scala.reflect.api.Universe with Singleton]($m$untyped: scala.reflect.api.Mirror[U]): U#Tree = { val $u: U = $m$untyped.universe; val $m: $u.Mirror = $m$untyped.asInstanceOf[$u.Mirror]; - $u.Apply.apply($u.Select.apply($u.Select.apply($u.build.Ident($m.staticPackage("scala")), $u.TermName.apply("Array")), $u.TermName.apply("apply")), scala.collection.immutable.List.apply[$u.Literal]($u.Literal.apply($u.Constant.apply(2)))) + $u.Apply.apply($u.Select.apply($u.build.Ident($m.staticModule("scala.Array")), $u.TermName.apply("apply")), scala.collection.immutable.List.apply[$u.Literal]($u.Literal.apply($u.Constant.apply(2)))) } }; new $treecreator1() diff --git a/test/pending/run/idempotency-partial-functions.scala b/test/pending/run/idempotency-partial-functions.scala new file mode 100644 index 0000000000..bc0ca706dd --- /dev/null +++ b/test/pending/run/idempotency-partial-functions.scala @@ -0,0 +1,28 @@ +import scala.reflect.runtime.universe._ +import scala.reflect.runtime.{currentMirror => cm} +import scala.tools.reflect.{ToolBox, ToolBoxError} +import scala.tools.reflect.Eval + +// Related to SI-6187 +// +// Moved to pending as we are currently blocked by the inability +// to reify the parent types of the anoymous function class, +// which are not part of the tree, but rather only part of the +// ClassInfoType. +object Test extends App { + val partials = reify { + List((false,true)) collect { case (x,true) => x } + } + println(Seq(show(partials), showRaw(partials)).mkString("\n\n")) + try { + println(partials.eval) + } catch { + case e: ToolBoxError => println(e) + } + val tb = cm.mkToolBox() + val tpartials = tb.typeCheck(partials.tree) + println(tpartials) + val rtpartials = tb.resetAllAttrs(tpartials) + println(tb.eval(rtpartials)) +} +Test.main(null)
\ No newline at end of file diff --git a/test/pending/run/t6591_4.check b/test/pending/run/t6591_4.check new file mode 100644 index 0000000000..0f1c0489e9 --- /dev/null +++ b/test/pending/run/t6591_4.check @@ -0,0 +1 @@ +Expr(Block(List(ValDef(Modifiers(), newTermName("v"), Select(Ident(newTermName("A")), newTypeName("I")), Apply(Select(New(Select(Ident(newTermName("A")), newTypeName("I"))), nme.CONSTRUCTOR), List()))), Ident(newTermName("v")))) diff --git a/test/pending/run/t6591_4.scala b/test/pending/run/t6591_4.scala new file mode 100644 index 0000000000..f20c8e6127 --- /dev/null +++ b/test/pending/run/t6591_4.scala @@ -0,0 +1,17 @@ +import scala.reflect.runtime.universe._ +import scala.tools.reflect.ToolBox +import scala.tools.reflect.Eval + +class O { class I } + +class A extends O { + val code = reify { + val v: I = new I + v + } + println(showRaw(code)) +} + +object Test extends App { + val v: A#I = (new A).code.eval +} diff --git a/test/scaladoc/run/SI-6017.scala b/test/scaladoc/run/SI-6017.scala index a4950e48d8..9951534c6d 100644 --- a/test/scaladoc/run/SI-6017.scala +++ b/test/scaladoc/run/SI-6017.scala @@ -16,6 +16,11 @@ object Test extends ScaladocModelTest { val index = IndexModelFactory.makeIndex(universe) // Because "STAR" and "Star" are different assert(index.firstLetterIndex('s').keys.toSeq.length == 2) + + val indexPage = new Index(universe, index) + val letters = indexPage.letters + assert(letters.length > 1) + assert(letters(0).toString == "<span>#</span>") } case _ => assert(false) } diff --git a/test/scaladoc/run/package-object.check b/test/scaladoc/run/package-object.check index 01dbcc682f..7da897a4f2 100644 --- a/test/scaladoc/run/package-object.check +++ b/test/scaladoc/run/package-object.check @@ -1,3 +1,4 @@ List(test.B, test.A, scala.AnyRef, scala.Any) List(B, A, AnyRef, Any) +Some((newSource,10)) Done. diff --git a/test/scaladoc/run/package-object.scala b/test/scaladoc/run/package-object.scala index 5fb5a4ddf1..f5c79b1332 100644 --- a/test/scaladoc/run/package-object.scala +++ b/test/scaladoc/run/package-object.scala @@ -11,6 +11,7 @@ object Test extends ScaladocModelTest { val p = root._package("test") println(p.linearizationTemplates) println(p.linearizationTypes) + println(p.inSource) } } |