summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/files/jvm/future-spec/FutureTests.scala19
-rw-r--r--test/files/jvm/future-spec/PromiseTests.scala14
-rw-r--r--test/files/jvm/future-spec/TryTests.scala118
-rw-r--r--test/files/jvm/future-spec/main.scala4
-rw-r--r--test/files/jvm/scala-concurrent-tck.scala152
-rw-r--r--test/files/jvm/try-type-tests.scala144
-rw-r--r--test/files/neg/catch-all.check6
-rw-r--r--test/files/neg/macro-invalidsig-context-bounds.check8
-rw-r--r--test/files/neg/macro-invalidsig-implicit-params.check8
-rw-r--r--test/files/neg/newpat_unreachable.check29
-rw-r--r--test/files/neg/newpat_unreachable.flags1
-rw-r--r--test/files/neg/newpat_unreachable.scala29
-rw-r--r--test/files/neg/nonlocal-warning.check2
-rw-r--r--test/files/neg/pat_unreachable.check8
-rw-r--r--test/files/neg/pat_unreachable.scala8
-rw-r--r--test/files/neg/t4425.check5
-rw-r--r--test/files/neg/t4425.flags1
-rw-r--r--test/files/neg/t5148.check5
-rw-r--r--test/files/neg/t5687.check8
-rw-r--r--test/files/neg/t5687.scala55
-rw-r--r--test/files/neg/t6040.check7
-rw-r--r--test/files/neg/t6040.scala1
-rw-r--r--test/files/neg/t6048.check7
-rw-r--r--test/files/neg/t6214.check4
-rw-r--r--test/files/neg/t6214.scala7
-rw-r--r--test/files/pos/inline-access-levels.flags1
-rw-r--r--test/files/pos/inline-access-levels/A_1.scala10
-rw-r--r--test/files/pos/inline-access-levels/Test_2.scala11
-rw-r--r--test/files/pos/t5756.scala6
-rw-r--r--test/files/pos/t6022b.scala20
-rw-r--r--test/files/pos/t6040.scala3
-rw-r--r--test/files/pos/t6145.scala11
-rw-r--r--test/files/pos/t6184.scala7
-rw-r--r--test/files/pos/t6201.scala13
-rw-r--r--test/files/pos/t6204-a.scala9
-rw-r--r--test/files/pos/t6204-b.scala10
-rw-r--r--test/files/pos/t6205.scala18
-rw-r--r--test/files/run/applydynamic_sip.flags1
-rw-r--r--test/files/run/inline-ex-handlers.check170
-rw-r--r--test/files/run/reflection-enclosed-basic.check18
-rw-r--r--test/files/run/reflection-enclosed-basic.scala46
-rw-r--r--test/files/run/reflection-enclosed-inner-basic.check20
-rw-r--r--test/files/run/reflection-enclosed-inner-basic.scala52
-rw-r--r--test/files/run/reflection-enclosed-inner-inner-basic.check20
-rw-r--r--test/files/run/reflection-enclosed-inner-inner-basic.scala58
-rw-r--r--test/files/run/reflection-enclosed-inner-nested-basic.check20
-rw-r--r--test/files/run/reflection-enclosed-inner-nested-basic.scala55
-rw-r--r--test/files/run/reflection-enclosed-nested-basic.check20
-rw-r--r--test/files/run/reflection-enclosed-nested-basic.scala52
-rw-r--r--test/files/run/reflection-enclosed-nested-inner-basic.check20
-rw-r--r--test/files/run/reflection-enclosed-nested-inner-basic.scala54
-rw-r--r--test/files/run/reflection-enclosed-nested-nested-basic.check20
-rw-r--r--test/files/run/reflection-enclosed-nested-nested-basic.scala54
-rw-r--r--test/files/run/reflection-modulemirror-inner-good.check3
-rw-r--r--test/files/run/reflection-modulemirror-nested-good.check3
-rw-r--r--test/files/run/reflection-repl-classes.check35
-rw-r--r--test/files/run/reflection-repl-classes.scala22
-rw-r--r--test/files/run/reflection-repl-elementary.check (renamed from test/files/run/reflection-repl.check)0
-rw-r--r--test/files/run/reflection-repl-elementary.scala (renamed from test/files/run/reflection-repl.scala)0
-rw-r--r--test/files/run/reflection-sanitychecks.check4
-rw-r--r--test/files/run/t4536.flags1
-rw-r--r--test/files/run/t5040.flags1
-rw-r--r--test/files/run/t6197.check0
-rw-r--r--test/files/run/t6197.scala21
-rw-r--r--test/files/run/t6198.check0
-rw-r--r--test/files/run/t6198.scala24
-rw-r--r--test/files/run/t6223.check4
-rw-r--r--test/files/run/t6223.scala11
-rw-r--r--test/scaladoc/run/SI-5933.check1
-rw-r--r--test/scaladoc/run/SI-5933.scala43
70 files changed, 1328 insertions, 294 deletions
diff --git a/test/files/jvm/future-spec/FutureTests.scala b/test/files/jvm/future-spec/FutureTests.scala
index 30e1a722bf..31bb8c4e44 100644
--- a/test/files/jvm/future-spec/FutureTests.scala
+++ b/test/files/jvm/future-spec/FutureTests.scala
@@ -6,6 +6,7 @@ import scala.concurrent.util.duration._
import scala.concurrent.util.Duration.Inf
import scala.collection._
import scala.runtime.NonLocalReturnControl
+import scala.util.{Try,Success,Failure}
@@ -197,7 +198,7 @@ object FutureTests extends MinimalScalaTest {
} andThen {
case _ => q.add(2)
} andThen {
- case Right(0) => q.add(Int.MaxValue)
+ case Success(0) => q.add(Int.MaxValue)
} andThen {
case _ => q.add(3);
}
@@ -260,13 +261,13 @@ object FutureTests extends MinimalScalaTest {
}
val futures = (0 to 9) map {
- idx => async(idx, idx * 200)
+ idx => async(idx, idx * 20)
}
val folded = Future.fold(futures)(0)(_ + _)
Await.result(folded, timeout) mustBe (45)
val futuresit = (0 to 9) map {
- idx => async(idx, idx * 200)
+ idx => async(idx, idx * 20)
}
val foldedit = Future.fold(futures)(0)(_ + _)
Await.result(foldedit, timeout) mustBe (45)
@@ -279,7 +280,7 @@ object FutureTests extends MinimalScalaTest {
add
}
def futures = (0 to 9) map {
- idx => async(idx, idx * 200)
+ idx => async(idx, idx * 20)
}
val folded = futures.foldLeft(Future(0)) {
case (fr, fa) => for (r <- fr; a <- fa) yield (r + a)
@@ -295,7 +296,7 @@ object FutureTests extends MinimalScalaTest {
add
}
def futures = (0 to 9) map {
- idx => async(idx, idx * 100)
+ idx => async(idx, idx * 10)
}
val folded = Future.fold(futures)(0)(_ + _)
intercept[IllegalArgumentException] {
@@ -326,7 +327,7 @@ object FutureTests extends MinimalScalaTest {
"shouldReduceResults" in {
def async(idx: Int) = future {
- Thread.sleep(idx * 200)
+ Thread.sleep(idx * 20)
idx
}
val timeout = 10000 millis
@@ -348,7 +349,7 @@ object FutureTests extends MinimalScalaTest {
}
val timeout = 10000 millis
def futures = (1 to 10) map {
- idx => async(idx, idx * 100)
+ idx => async(idx, idx * 10)
}
val failed = Future.reduce(futures)(_ + _)
intercept[IllegalArgumentException] {
@@ -472,7 +473,7 @@ object FutureTests extends MinimalScalaTest {
p1.future.isCompleted mustBe (false)
f4.isCompleted mustBe (false)
- p1 complete Right("Hello")
+ p1 complete Success("Hello")
Await.ready(latch(7), TestLatch.DefaultTimeout)
@@ -509,7 +510,7 @@ object FutureTests extends MinimalScalaTest {
}
"should not throw when Await.ready" in {
- val expected = try Right(5 / 0) catch { case a: ArithmeticException => Left(a) }
+ val expected = try Success(5 / 0) catch { case a: ArithmeticException => Failure(a) }
val f = future(5).map(_ / 0)
Await.ready(f, defaultTimeout).value.get.toString mustBe expected.toString
}
diff --git a/test/files/jvm/future-spec/PromiseTests.scala b/test/files/jvm/future-spec/PromiseTests.scala
index d15bb31f36..d9aaa1d5ed 100644
--- a/test/files/jvm/future-spec/PromiseTests.scala
+++ b/test/files/jvm/future-spec/PromiseTests.scala
@@ -6,7 +6,7 @@ import scala.concurrent.util.duration._
import scala.concurrent.util.Duration.Inf
import scala.collection._
import scala.runtime.NonLocalReturnControl
-
+import scala.util.{Try,Success,Failure}
object PromiseTests extends MinimalScalaTest {
@@ -48,27 +48,27 @@ object PromiseTests extends MinimalScalaTest {
"A successful Promise" should {
val result = "test value"
- val promise = Promise[String]().complete(Right(result))
+ val promise = Promise[String]().complete(Success(result))
promise.isCompleted mustBe (true)
futureWithResult(_(promise.future, result))
}
"A failed Promise" should {
val message = "Expected Exception"
- val promise = Promise[String]().complete(Left(new RuntimeException(message)))
+ val promise = Promise[String]().complete(Failure(new RuntimeException(message)))
promise.isCompleted mustBe (true)
futureWithException[RuntimeException](_(promise.future, message))
}
"An interrupted Promise" should {
val message = "Boxed InterruptedException"
- val future = Promise[String]().complete(Left(new InterruptedException(message))).future
+ val future = Promise[String]().complete(Failure(new InterruptedException(message))).future
futureWithException[ExecutionException](_(future, message))
}
"A NonLocalReturnControl failed Promise" should {
val result = "test value"
- val future = Promise[String]().complete(Left(new NonLocalReturnControl[String]("test", result))).future
+ val future = Promise[String]().complete(Failure(new NonLocalReturnControl[String]("test", result))).future
futureWithResult(_(future, result))
}
@@ -76,7 +76,7 @@ object PromiseTests extends MinimalScalaTest {
"be completed" in { f((future, _) => future.isCompleted mustBe (true)) }
- "contain a value" in { f((future, result) => future.value mustBe (Some(Right(result)))) }
+ "contain a value" in { f((future, result) => future.value mustBe (Some(Success(result)))) }
"return when ready with 'Await.ready'" in { f((future, result) => Await.ready(future, defaultTimeout).isCompleted mustBe (true)) }
@@ -159,7 +159,7 @@ object PromiseTests extends MinimalScalaTest {
"contain a value" in {
f((future, message) => {
- future.value.get.left.get.getMessage mustBe (message)
+ future.value.get.failed.get.getMessage mustBe (message)
})
}
diff --git a/test/files/jvm/future-spec/TryTests.scala b/test/files/jvm/future-spec/TryTests.scala
new file mode 100644
index 0000000000..82ca12276f
--- /dev/null
+++ b/test/files/jvm/future-spec/TryTests.scala
@@ -0,0 +1,118 @@
+// This is a port of the com.twitter.util Try spec.
+// --
+// It lives in the future-spec directory simply because it requires a specs-like
+// DSL which has already been minimally implemented for the future spec tests.
+
+import scala.util.{Try,Success,Failure}
+
+object TryTests extends MinimalScalaTest {
+ class MyException extends Exception
+ val e = new Exception("this is an exception")
+
+ "Try()" should {
+ "catch exceptions and lift into the Try type" in {
+ Try[Int](1) mustEqual Success(1)
+ Try[Int] { throw e } mustEqual Failure(e)
+ }
+ }
+
+ "Try" should {
+ "recoverWith" in {
+ val myException = new MyException
+ Success(1) recoverWith { case _ => Success(2) } mustEqual Success(1)
+ Failure(e) recoverWith { case _ => Success(2) } mustEqual Success(2)
+ Failure(e) recoverWith { case _ => Failure(e) } mustEqual Failure(e)
+ }
+
+ "getOrElse" in {
+ Success(1) getOrElse 2 mustEqual 1
+ Failure(e) getOrElse 2 mustEqual 2
+ }
+
+ "orElse" in {
+ Success(1) orElse Success(2) mustEqual Success(1)
+ Failure(e) orElse Success(2) mustEqual Success(2)
+ }
+
+ "map" in {
+ "when there is no exception" in {
+ Success(1) map(1+) mustEqual Success(2)
+ Failure[Int](e) map(1+) mustEqual Failure(e)
+ }
+
+ "when there is an exception" in {
+ Success(1) map(_ => throw e) mustEqual Failure(e)
+
+ val e2 = new Exception
+ Failure[Int](e) map(_ => throw e2) mustEqual Failure(e)
+ }
+ }
+
+ "flatMap" in {
+ "when there is no exception" in {
+ Success(1) flatMap(x => Success(1 + x)) mustEqual Success(2)
+ Failure[Int](e) flatMap(x => Success(1 + x)) mustEqual Failure(e)
+ }
+
+ "when there is an exception" in {
+ Success(1).flatMap[Int](_ => throw e) mustEqual Failure(e)
+
+ val e2 = new Exception
+ Failure[Int](e).flatMap[Int](_ => throw e2) mustEqual Failure(e)
+ }
+ }
+
+ "flatten" in {
+ "is a Success(Success)" in {
+ Success(Success(1)).flatten mustEqual Success(1)
+ }
+
+ "is a Success(Failure)" in {
+ val e = new Exception
+ Success(Failure(e)).flatten mustEqual Failure(e)
+ }
+
+ "is a Throw" in {
+ val e = new Exception
+ Failure[Try[Int]](e).flatten mustEqual Failure(e)
+ }
+ }
+
+ "for" in {
+ "with no Failure values" in {
+ val result = for {
+ i <- Success(1)
+ j <- Success(1)
+ } yield (i + j)
+ result mustEqual Success(2)
+ }
+
+ "with Failure values" in {
+ "throws before" in {
+ val result = for {
+ i <- Failure[Int](e)
+ j <- Success(1)
+ } yield (i + j)
+ result mustEqual Failure(e)
+ }
+
+ "throws after" in {
+ val result = for {
+ i <- Success(1)
+ j <- Failure[Int](e)
+ } yield (i + j)
+ result mustEqual Failure(e)
+ }
+
+ "returns the FIRST Failure" in {
+ val e2 = new Exception
+ val result = for {
+ i <- Failure[Int](e)
+ j <- Failure[Int](e2)
+ } yield (i + j)
+ result mustEqual Failure(e)
+ }
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/test/files/jvm/future-spec/main.scala b/test/files/jvm/future-spec/main.scala
index 45b59d5d20..57183d8cea 100644
--- a/test/files/jvm/future-spec/main.scala
+++ b/test/files/jvm/future-spec/main.scala
@@ -12,6 +12,7 @@ object Test {
def main(args: Array[String]) {
FutureTests.check()
PromiseTests.check()
+ TryTests.check()
}
}
@@ -47,7 +48,7 @@ trait MinimalScalaTest extends Output {
snippet
bufferPrintln("[OK] Test passed.")
} catch {
- case e =>
+ case e: Throwable =>
bufferPrintln("[FAILED] " + e)
bufferPrintln(e.getStackTrace().mkString("\n"))
throwables += e
@@ -59,6 +60,7 @@ trait MinimalScalaTest extends Output {
implicit def objectops(obj: Any) = new {
def mustBe(other: Any) = assert(obj == other, obj + " is not " + other)
+ def mustEqual(other: Any) = mustBe(other)
}
diff --git a/test/files/jvm/scala-concurrent-tck.scala b/test/files/jvm/scala-concurrent-tck.scala
index 43d4c9dc71..ffb5608fd2 100644
--- a/test/files/jvm/scala-concurrent-tck.scala
+++ b/test/files/jvm/scala-concurrent-tck.scala
@@ -601,10 +601,10 @@ trait FutureProjections extends TestBase {
throw cause
}
f.failed onComplete {
- case Right(t) =>
+ case Success(t) =>
assert(t == cause)
done()
- case Left(t) =>
+ case Failure(t) =>
assert(false)
}
}
@@ -626,9 +626,9 @@ trait FutureProjections extends TestBase {
done =>
val f = future { 0 }
f.failed onComplete {
- case Right(t) =>
+ case Success(t) =>
assert(false)
- case Left(t) =>
+ case Failure(t) =>
assert(t.isInstanceOf[NoSuchElementException])
done()
}
@@ -803,81 +803,6 @@ trait Exceptions extends TestBase {
}
-// trait TryEitherExtractor extends TestBase {
-
-// import scala.util.{Try, Success, Failure}
-
-// def testSuccessMatch(): Unit = once {
-// done =>
-// val thisIsASuccess = Success(42)
-// thisIsASuccess match {
-// case Success(v) =>
-// done()
-// assert(v == 42)
-// case Failure(e) =>
-// done()
-// assert(false)
-// case other =>
-// done()
-// assert(false)
-// }
-// }
-
-// def testRightMatch(): Unit = once {
-// done =>
-// val thisIsNotASuccess: Right[Throwable, Int] = Right(43)
-// thisIsNotASuccess match {
-// case Success(v) =>
-// done()
-// assert(v == 43)
-// case Failure(e) =>
-// done()
-// assert(false)
-// case other =>
-// done()
-// assert(false)
-// }
-// }
-
-// def testFailureMatch(): Unit = once {
-// done =>
-// val thisIsAFailure = Failure(new Exception("I'm an exception"))
-// thisIsAFailure match {
-// case Success(v) =>
-// done()
-// assert(false)
-// case Failure(e) =>
-// done()
-// assert(e.getMessage == "I'm an exception")
-// case other =>
-// done()
-// assert(false)
-// }
-// }
-
-// def testLeftMatch(): Unit = once {
-// done =>
-// val thisIsNotAFailure: Left[Throwable, Int] = Left(new Exception("I'm an exception"))
-// thisIsNotAFailure match {
-// case Success(v) =>
-// done()
-// assert(false)
-// case Failure(e) =>
-// done()
-// assert(e.getMessage == "I'm an exception")
-// case other =>
-// done()
-// assert(false)
-// }
-
-// }
-
-// testSuccessMatch()
-// testRightMatch()
-// testFailureMatch()
-// testLeftMatch()
-// }
-
trait CustomExecutionContext extends TestBase {
import scala.concurrent.{ ExecutionContext, Awaitable }
@@ -975,13 +900,13 @@ trait CustomExecutionContext extends TestBase {
} flatMap { x =>
Promise.successful(x + 1).future.map(addOne).map(addOne)
} onComplete {
- case Left(t) =>
+ case Failure(t) =>
try {
throw new AssertionError("error in test: " + t.getMessage, t)
} finally {
done()
}
- case Right(x) =>
+ case Success(x) =>
assertEC()
assert(x == 14)
done()
@@ -1001,6 +926,66 @@ trait CustomExecutionContext extends TestBase {
testCallbackChainCustomEC()
}
+trait ExecutionContextPrepare extends TestBase {
+ val theLocal = new ThreadLocal[String] {
+ override protected def initialValue(): String = ""
+ }
+
+ class PreparingExecutionContext extends ExecutionContext {
+ def delegate = ExecutionContext.global
+
+ override def execute(runnable: Runnable): Unit =
+ delegate.execute(runnable)
+
+ override def prepare(): ExecutionContext = {
+ // save object stored in ThreadLocal storage
+ val localData = theLocal.get
+ new PreparingExecutionContext {
+ override def execute(runnable: Runnable): Unit = {
+ val wrapper = new Runnable {
+ override def run(): Unit = {
+ // now we're on the new thread
+ // put localData into theLocal
+ theLocal.set(localData)
+ runnable.run()
+ }
+ }
+ delegate.execute(wrapper)
+ }
+ }
+ }
+
+ override def reportFailure(t: Throwable): Unit =
+ delegate.reportFailure(t)
+ }
+
+ implicit val ec = new PreparingExecutionContext
+
+ def testOnComplete(): Unit = once {
+ done =>
+ theLocal.set("secret")
+ val fut = future { 42 }
+ fut onComplete {
+ case _ =>
+ assert(theLocal.get == "secret")
+ done()
+ }
+ }
+
+ def testMap(): Unit = once {
+ done =>
+ theLocal.set("secret2")
+ val fut = future { 42 }
+ fut map { x =>
+ assert(theLocal.get == "secret2")
+ done()
+ }
+ }
+
+ testOnComplete()
+ testMap()
+}
+
object Test
extends App
with FutureCallbacks
@@ -1009,12 +994,9 @@ with FutureProjections
with Promises
with BlockContexts
with Exceptions
-// with TryEitherExtractor
with CustomExecutionContext
+with ExecutionContextPrepare
{
System.exit(0)
}
-
-
-
diff --git a/test/files/jvm/try-type-tests.scala b/test/files/jvm/try-type-tests.scala
index eecbb0ae57..17811f64c5 100644
--- a/test/files/jvm/try-type-tests.scala
+++ b/test/files/jvm/try-type-tests.scala
@@ -59,12 +59,12 @@ trait TryStandard {
def testRescueSuccess(): Unit = {
val t = Success(1)
- t.rescue{ case x => assert(false); Try() }
+ t.recoverWith{ case x => assert(false); Try() }
}
def testRescueFailure(): Unit = {
val t = Failure(new Exception("foo"))
- val n = t.rescue{ case x => Try(1) }
+ val n = t.recoverWith{ case x => Try(1) }
assert(n.get == 1)
}
@@ -103,6 +103,20 @@ trait TryStandard {
}
}
+ def testSuccessTransform(): Unit = {
+ val s = Success(1)
+ val succ = (x: Int) => Success(x * 10)
+ val fail = (x: Throwable) => Success(0)
+ assert(s.transform(succ, fail).get == 10)
+ }
+
+ def testFailureTransform(): Unit = {
+ val f = Failure(new Exception("foo"))
+ val succ = (x: Int) => Success(x * 10)
+ val fail = (x: Throwable) => Success(0)
+ assert(f.transform(succ, fail).get == 0)
+ }
+
testForeachSuccess()
testForeachFailure()
testFlatMapSuccess()
@@ -119,132 +133,12 @@ trait TryStandard {
testFlattenSuccess()
testFailedSuccess()
testFailedFailure()
-}
-
-// tests that implicit conversions from Try to Either behave as expected
-trait TryImplicitConversionTry2Either {
-
- def testTry2RightMap(): Unit = {
- val t = Success(1)
- val n = t.right.map(x => x * 100)
- assert(n == Right(100))
- }
-
- def testTry2LeftMap(): Unit = {
- val e = new Exception("foo")
- val t = Failure(e)
- val n = t.left.map(x => x)
- assert(n == Left(e))
- }
-
- def testTry2FoldSuccess(): Unit = {
- val t = Success(1)
- val n = t.fold(x => assert(false), y => y * 200)
- assert(n == 200)
- }
-
- def testTry2FoldFailure(): Unit = {
- val e = new Exception("foo")
- val t = Failure(e)
- val n = t.fold(x => x, y => assert(false))
- assert(n == e)
- }
-
- def testTry2SwapSuccess(): Unit = {
- val t = Success(1)
- val n = t.swap
- assert(n == Left(1))
- }
-
- def testTry2SwapFailure(): Unit = {
- val e = new Exception("foo")
- val t = Failure(e)
- val n = t.swap
- assert(n == Right(e))
- }
-
- // def testTry2MergeSucccess(): Unit = {
- // val t: Try[Int] = Success(1)
- // val n = (t: Either[Any, Any]).t.merge // connecting two implicit conversions
- // assert(n == 1)
- // }
-
- // def testTry2MergeFailure(): Unit = {
- // val e = new Exception("foo")
- // val t = Failure(e)
- // val n = (t: Either[Any, Any]).merge // connecting two implicit conversions
- // assert(n == e)
- // }
-
- testTry2RightMap()
- testTry2LeftMap()
- testTry2FoldSuccess()
- testTry2FoldFailure()
- testTry2SwapSuccess()
- testTry2SwapFailure()
- // testTry2MergeSucccess()
- // testTry2MergeFailure()
-}
-
-// tests that implicit conversions from Either to Try behave as expected
-trait TryImplicitConversionEither2Try {
-
- def testRight2FilterSuccessTrue(): Unit = {
- def expectsTry[U <% Try[Int]](rght: U): Try[Int] = {
- val n = rght.filter(x => x > 0) // this should be converted to a Try
- n
- }
- val r = Right(1)
- val n = expectsTry(r)
- assert(n == Success(1))
- }
-
- def testRight2FilterSuccessFalse(): Unit = {
- def expectsTry[U <% Try[Int]](rght: U): Try[Int] = {
- val n = rght.filter(x => x < 0) // this should be converted to a Try
- n
- }
- val r = Right(1)
- val n = expectsTry(r)
- n match {
- case Failure(e: NoSuchElementException) => assert(true)
- case _ => assert(false)
- }
- }
-
- def testLeft2FilterFailure(): Unit = {
- def expectsTry[U <% Try[Int]](rght: U): Try[Int] = {
- val n = rght.filter(x => x > 0) // this should be converted to a Try
- n
- }
- val r = Left(new Exception("foo"))
- val n = expectsTry(r)
- n match {
- case Failure(e: Exception) => assert(true)
- case _ => assert(false)
- }
- }
-
- def testRight2GetSuccess(): Unit = {
- def expectsTry[U <% Try[Int]](rght: U): Int = {
- val n = rght.get // this should be converted to a Try
- n
- }
- val r = Right(1)
- val n = expectsTry(r)
- assert(n == 1)
- }
-
- testRight2FilterSuccessTrue()
- testRight2FilterSuccessFalse()
- testLeft2FilterFailure()
- testRight2GetSuccess()
+ testSuccessTransform()
+ testFailureTransform()
}
object Test
extends App
-with TryStandard
-with TryImplicitConversionTry2Either
-with TryImplicitConversionEither2Try {
+with TryStandard {
System.exit(0)
} \ No newline at end of file
diff --git a/test/files/neg/catch-all.check b/test/files/neg/catch-all.check
index d59e826f03..aaf51480c3 100644
--- a/test/files/neg/catch-all.check
+++ b/test/files/neg/catch-all.check
@@ -1,10 +1,10 @@
-catch-all.scala:2: warning: This catches all Throwables. If this is really intended, use `case _: Throwable` to clear this warning.
+catch-all.scala:2: warning: This catches all Throwables. If this is really intended, use `case _ : Throwable` to clear this warning.
try { "warn" } catch { case _ => }
^
-catch-all.scala:4: warning: This catches all Throwables. If this is really intended, use `case x: Throwable` to clear this warning.
+catch-all.scala:4: warning: This catches all Throwables. If this is really intended, use `case x : Throwable` to clear this warning.
try { "warn" } catch { case x => }
^
-catch-all.scala:6: warning: This catches all Throwables. If this is really intended, use `case x: Throwable` to clear this warning.
+catch-all.scala:6: warning: This catches all Throwables. If this is really intended, use `case x : Throwable` to clear this warning.
try { "warn" } catch { case _: RuntimeException => ; case x => }
^
error: No warnings can be incurred under -Xfatal-warnings.
diff --git a/test/files/neg/macro-invalidsig-context-bounds.check b/test/files/neg/macro-invalidsig-context-bounds.check
index 894eabc442..6c9482e537 100644
--- a/test/files/neg/macro-invalidsig-context-bounds.check
+++ b/test/files/neg/macro-invalidsig-context-bounds.check
@@ -1,4 +1,4 @@
-Impls_1.scala:5: error: macro implementations cannot have implicit parameters other than AbsTypeTag evidences
- def foo[U: c.AbsTypeTag: Numeric](c: Ctx) = {
- ^
-one error found
+Impls_1.scala:5: error: macro implementations cannot have implicit parameters other than AbsTypeTag evidences
+ def foo[U: c.AbsTypeTag: Numeric](c: Ctx) = {
+ ^
+one error found
diff --git a/test/files/neg/macro-invalidsig-implicit-params.check b/test/files/neg/macro-invalidsig-implicit-params.check
index 029b8a4634..98b3167b7a 100644
--- a/test/files/neg/macro-invalidsig-implicit-params.check
+++ b/test/files/neg/macro-invalidsig-implicit-params.check
@@ -1,4 +1,4 @@
-Impls_Macros_1.scala:5: error: macro implementations cannot have implicit parameters other than AbsTypeTag evidences
- def foo_targs[T, U: c.AbsTypeTag](c: Ctx)(implicit x: c.Expr[Int]) = {
- ^
-one error found
+Impls_Macros_1.scala:5: error: macro implementations cannot have implicit parameters other than AbsTypeTag evidences
+ def foo_targs[T, U: c.AbsTypeTag](c: Ctx)(implicit x: c.Expr[Int]) = {
+ ^
+one error found
diff --git a/test/files/neg/newpat_unreachable.check b/test/files/neg/newpat_unreachable.check
new file mode 100644
index 0000000000..a928e3853a
--- /dev/null
+++ b/test/files/neg/newpat_unreachable.check
@@ -0,0 +1,29 @@
+newpat_unreachable.scala:6: warning: patterns after a variable pattern cannot match (SLS 8.1.1)
+If you intended to match against parameter b of method contrivedExample, you must use backticks, like: case `b` =>
+ case b => println("matched b")
+ ^
+newpat_unreachable.scala:7: warning: unreachable code due to variable pattern 'b' on line 6
+If you intended to match against parameter c of method contrivedExample, you must use backticks, like: case `c` =>
+ case c => println("matched c")
+ ^
+newpat_unreachable.scala:8: warning: unreachable code due to variable pattern 'b' on line 6
+If you intended to match against value d in class A, you must use backticks, like: case `d` =>
+ case d => println("matched d")
+ ^
+newpat_unreachable.scala:9: warning: unreachable code due to variable pattern 'b' on line 6
+ case _ => println("matched neither")
+ ^
+newpat_unreachable.scala:22: warning: patterns after a variable pattern cannot match (SLS 8.1.1)
+If you intended to match against parameter b of method g, you must use backticks, like: case `b` =>
+ case b => 1
+ ^
+newpat_unreachable.scala:23: warning: unreachable code due to variable pattern 'b' on line 22
+If you intended to match against parameter c of method h, you must use backticks, like: case `c` =>
+ case c => 2
+ ^
+newpat_unreachable.scala:24: warning: unreachable code due to variable pattern 'b' on line 22
+ case _ => 3
+ ^
+error: No warnings can be incurred under -Xfatal-warnings.
+7 warnings found
+one error found
diff --git a/test/files/neg/newpat_unreachable.flags b/test/files/neg/newpat_unreachable.flags
new file mode 100644
index 0000000000..85d8eb2ba2
--- /dev/null
+++ b/test/files/neg/newpat_unreachable.flags
@@ -0,0 +1 @@
+-Xfatal-warnings
diff --git a/test/files/neg/newpat_unreachable.scala b/test/files/neg/newpat_unreachable.scala
new file mode 100644
index 0000000000..c9cc85cec6
--- /dev/null
+++ b/test/files/neg/newpat_unreachable.scala
@@ -0,0 +1,29 @@
+object Test {
+ class A {
+ val d = 55
+
+ def contrivedExample[A, B, C](a: A, b: B, c: C): Unit = a match {
+ case b => println("matched b")
+ case c => println("matched c")
+ case d => println("matched d")
+ case _ => println("matched neither")
+ }
+
+ def correctExample[A, B, C](a: A, b: B, c: C): Unit = a match {
+ case `b` => println("matched b")
+ case `c` => println("matched c")
+ case `d` => println("matched d")
+ case _ => println("matched neither")
+ }
+
+ def f[A](a: A) = {
+ def g[B](b: B) = {
+ def h[C](c: C) = a match {
+ case b => 1
+ case c => 2
+ case _ => 3
+ }
+ }
+ }
+ }
+}
diff --git a/test/files/neg/nonlocal-warning.check b/test/files/neg/nonlocal-warning.check
index efb3efaaa2..5202df655a 100644
--- a/test/files/neg/nonlocal-warning.check
+++ b/test/files/neg/nonlocal-warning.check
@@ -1,4 +1,4 @@
-nonlocal-warning.scala:4: warning: This catches all Throwables. If this is really intended, use `case x: Throwable` to clear this warning.
+nonlocal-warning.scala:4: warning: This catches all Throwables. If this is really intended, use `case x : Throwable` to clear this warning.
catch { case x => 11 }
^
nonlocal-warning.scala:2: warning: catch block may intercept non-local return from method foo
diff --git a/test/files/neg/pat_unreachable.check b/test/files/neg/pat_unreachable.check
index 4e1463d591..c5706b7fad 100644
--- a/test/files/neg/pat_unreachable.check
+++ b/test/files/neg/pat_unreachable.check
@@ -4,4 +4,10 @@ pat_unreachable.scala:5: error: unreachable code
pat_unreachable.scala:9: error: unreachable code
case Seq(x, y) => List(x, y)
^
-two errors found
+pat_unreachable.scala:23: error: unreachable code
+ case c => println("matched c")
+ ^
+pat_unreachable.scala:24: error: unreachable code
+ case _ => println("matched neither")
+ ^
+four errors found
diff --git a/test/files/neg/pat_unreachable.scala b/test/files/neg/pat_unreachable.scala
index fc0fd41920..1f402e5212 100644
--- a/test/files/neg/pat_unreachable.scala
+++ b/test/files/neg/pat_unreachable.scala
@@ -8,7 +8,7 @@ object Test extends App {
case Seq(x, y, _*) => x::y::Nil
case Seq(x, y) => List(x, y)
}
-
+
def not_unreachable(xs:Seq[Char]) = xs match {
case Seq(x, y, _*) => x::y::Nil
case Seq(x) => List(x)
@@ -17,4 +17,10 @@ object Test extends App {
case Seq(x, y) => x::y::Nil
case Seq(x, y, z, _*) => List(x,y)
}
+
+ def contrivedExample[A, B, C](a: A, b: B, c: C): Unit = a match {
+ case b => println("matched b")
+ case c => println("matched c")
+ case _ => println("matched neither")
+ }
}
diff --git a/test/files/neg/t4425.check b/test/files/neg/t4425.check
index a6a1a1fad4..0f2fe6f2d1 100644
--- a/test/files/neg/t4425.check
+++ b/test/files/neg/t4425.check
@@ -1,5 +1,4 @@
-t4425.scala:3: error: error during expansion of this match (this is a scalac bug).
-The underlying error was: value _1 is not a member of object Foo.X
+t4425.scala:3: error: isInstanceOf cannot test if value types are references.
42 match { case _ X _ => () }
- ^
+ ^
one error found
diff --git a/test/files/neg/t4425.flags b/test/files/neg/t4425.flags
new file mode 100644
index 0000000000..1182725e86
--- /dev/null
+++ b/test/files/neg/t4425.flags
@@ -0,0 +1 @@
+-optimize \ No newline at end of file
diff --git a/test/files/neg/t5148.check b/test/files/neg/t5148.check
index 96eb1fd364..6edfdf2b1e 100644
--- a/test/files/neg/t5148.check
+++ b/test/files/neg/t5148.check
@@ -1,2 +1,3 @@
-error: bad reference while unpickling Imports.class: term memberHandlers not found in scala.tools.nsc.interpreter.IMain
-one error found
+error: bad symbolic reference to value global in class IMain - referenced from t5148.scala (a classfile may be missing)
+error: bad symbolic reference to value memberHandlers in class IMain - referenced from t5148.scala (a classfile may be missing)
+two errors found
diff --git a/test/files/neg/t5687.check b/test/files/neg/t5687.check
new file mode 100644
index 0000000000..5096077ee5
--- /dev/null
+++ b/test/files/neg/t5687.check
@@ -0,0 +1,8 @@
+t5687.scala:4: error: type arguments [T] do not conform to class Template's type parameter bounds [T <: AnyRef]
+ type Repr[T]<:Template[T]
+ ^
+t5687.scala:20: error: overriding type Repr in class Template with bounds[T] <: Template[T];
+ type Repr has incompatible type
+ type Repr = CurveTemplate[T]
+ ^
+two errors found
diff --git a/test/files/neg/t5687.scala b/test/files/neg/t5687.scala
new file mode 100644
index 0000000000..90a9ae265c
--- /dev/null
+++ b/test/files/neg/t5687.scala
@@ -0,0 +1,55 @@
+abstract class Template[T <: AnyRef](private val t: T) {
+
+// type Repr[A<:AnyRef]<:Template[T]
+ type Repr[T]<:Template[T]
+
+ def access1(timeout: Int): Repr[T] = this.asInstanceOf[Repr[T]]
+ def access2: Repr[T] = this.asInstanceOf[Repr[T]]
+ val access3: Repr[T] = this.asInstanceOf[Repr[T]]
+ def access4(v: Repr[T]): Repr[T] = this.asInstanceOf[Repr[T]]
+ def access5(x: X): Repr[T] = this.asInstanceOf[Repr[T]]
+ def access5(x: Y): Repr[T] = this.asInstanceOf[Repr[T]]
+
+ def withReadModifiers(readModifiers:Int): Repr[T] = this.asInstanceOf[Repr[T]]
+}
+
+class Curve
+
+class CurveTemplate [T <: Curve](t: T) extends Template(t) {
+// type Repr[A<: AnyRef] = CurveTemplate[T]
+ type Repr = CurveTemplate[T]
+}
+
+class Base
+class X extends Base
+class Y extends Base
+
+
+object Example {
+ def test1() {
+ new CurveTemplate(new Curve).access1(10)
+
+ new CurveTemplate(new Curve).access2
+
+ new CurveTemplate(new Curve).access3
+
+ new CurveTemplate(new Curve).access4(null)
+
+ new CurveTemplate(new Curve).access5(new X)
+
+ ()
+
+ }
+
+ def test2() {
+ new CurveTemplate(new Curve).access1(10).withReadModifiers(1)
+
+ new CurveTemplate(new Curve).access2.withReadModifiers(1)
+
+ new CurveTemplate(new Curve).access3.withReadModifiers(1)
+
+ new CurveTemplate(new Curve).access4(null).withReadModifiers(1)
+
+ new CurveTemplate(new Curve).access5(new X).withReadModifiers(1)
+ }
+}
diff --git a/test/files/neg/t6040.check b/test/files/neg/t6040.check
new file mode 100644
index 0000000000..f44a81c471
--- /dev/null
+++ b/test/files/neg/t6040.check
@@ -0,0 +1,7 @@
+error: extension of type scala.Dynamic needs to be enabled
+by making the implicit value language.dynamics visible.
+This can be achieved by adding the import clause 'import language.dynamics'
+or by setting the compiler option -language:dynamics.
+See the Scala docs for value scala.language.dynamics for a discussion
+why the feature needs to be explicitly enabled.
+one error found
diff --git a/test/files/neg/t6040.scala b/test/files/neg/t6040.scala
new file mode 100644
index 0000000000..b8f7dab7a4
--- /dev/null
+++ b/test/files/neg/t6040.scala
@@ -0,0 +1 @@
+class X extends Dynamic \ No newline at end of file
diff --git a/test/files/neg/t6048.check b/test/files/neg/t6048.check
index 319e3fa620..5e11d24fde 100644
--- a/test/files/neg/t6048.check
+++ b/test/files/neg/t6048.check
@@ -4,9 +4,12 @@ t6048.scala:3: warning: unreachable code
t6048.scala:8: warning: unreachable code
case _ if false => x // unreachable
^
-t6048.scala:14: warning: unreachable code
+t6048.scala:13: warning: patterns after a variable pattern cannot match (SLS 8.1.1)
+ case _ => x
+ ^
+t6048.scala:14: warning: unreachable code due to variable pattern on line 13
case 5 if true => x // unreachable
^
error: No warnings can be incurred under -Xfatal-warnings.
-three warnings found
+four warnings found
one error found
diff --git a/test/files/neg/t6214.check b/test/files/neg/t6214.check
new file mode 100644
index 0000000000..6349a3e71c
--- /dev/null
+++ b/test/files/neg/t6214.check
@@ -0,0 +1,4 @@
+t6214.scala:5: error: missing parameter type
+ m { s => case class Foo() }
+ ^
+one error found
diff --git a/test/files/neg/t6214.scala b/test/files/neg/t6214.scala
new file mode 100644
index 0000000000..734acda35e
--- /dev/null
+++ b/test/files/neg/t6214.scala
@@ -0,0 +1,7 @@
+object Test {
+ def m(f: String => Unit) = 0
+ def m(f: Int => Unit) = 0
+ def foo {
+ m { s => case class Foo() }
+ }
+}
diff --git a/test/files/pos/inline-access-levels.flags b/test/files/pos/inline-access-levels.flags
new file mode 100644
index 0000000000..882f40f050
--- /dev/null
+++ b/test/files/pos/inline-access-levels.flags
@@ -0,0 +1 @@
+-optimise -Xfatal-warnings -Yinline-warnings
diff --git a/test/files/pos/inline-access-levels/A_1.scala b/test/files/pos/inline-access-levels/A_1.scala
new file mode 100644
index 0000000000..479fe0fc71
--- /dev/null
+++ b/test/files/pos/inline-access-levels/A_1.scala
@@ -0,0 +1,10 @@
+package test
+
+object A {
+
+ private var x: Int = 0
+
+ @inline def actOnX(f: Int => Int) = {
+ x = f(x)
+ }
+}
diff --git a/test/files/pos/inline-access-levels/Test_2.scala b/test/files/pos/inline-access-levels/Test_2.scala
new file mode 100644
index 0000000000..12c9eb540f
--- /dev/null
+++ b/test/files/pos/inline-access-levels/Test_2.scala
@@ -0,0 +1,11 @@
+package test
+
+object Test {
+
+ def main(args: Array[String]) {
+
+ A.actOnX(_ + 1)
+
+ }
+
+}
diff --git a/test/files/pos/t5756.scala b/test/files/pos/t5756.scala
new file mode 100644
index 0000000000..45960fa8bd
--- /dev/null
+++ b/test/files/pos/t5756.scala
@@ -0,0 +1,6 @@
+import scala.reflect.runtime.universe._
+
+object Test extends App {
+ def tagme[T: TypeTag](x: T) = typeTag[T]
+ val foo = tagme{object Bar; Bar}
+} \ No newline at end of file
diff --git a/test/files/pos/t6022b.scala b/test/files/pos/t6022b.scala
new file mode 100644
index 0000000000..6ceb928162
--- /dev/null
+++ b/test/files/pos/t6022b.scala
@@ -0,0 +1,20 @@
+trait A
+trait B
+trait C
+trait AB extends B with A
+
+// two types are mutually exclusive if there is no equality symbol whose constant implies both
+object Test extends App {
+ def foo(x: Any) = x match {
+ case _ : C => println("C")
+ case _ : AB => println("AB")
+ case _ : (A with B) => println("AB'")
+ case _ : B => println("B")
+ case _ : A => println("A")
+ }
+
+ foo(new A {})
+ foo(new B {})
+ foo(new AB{})
+ foo(new C {})
+}
diff --git a/test/files/pos/t6040.scala b/test/files/pos/t6040.scala
new file mode 100644
index 0000000000..9c00ecd8e1
--- /dev/null
+++ b/test/files/pos/t6040.scala
@@ -0,0 +1,3 @@
+import language.dynamics
+
+class X extends Dynamic \ No newline at end of file
diff --git a/test/files/pos/t6145.scala b/test/files/pos/t6145.scala
new file mode 100644
index 0000000000..28334d4420
--- /dev/null
+++ b/test/files/pos/t6145.scala
@@ -0,0 +1,11 @@
+object Test {
+ // the existential causes a cast and the cast makes searchClass not be in tail position
+ // can we get rid of the useless cast?
+ @annotation.tailrec
+ final def searchClass: Class[_] = {
+ "packageName" match {
+ case _ =>
+ searchClass
+ }
+ }
+} \ No newline at end of file
diff --git a/test/files/pos/t6184.scala b/test/files/pos/t6184.scala
new file mode 100644
index 0000000000..83a1306aca
--- /dev/null
+++ b/test/files/pos/t6184.scala
@@ -0,0 +1,7 @@
+trait Foo[TroubleSome] {
+ type T <: Foo[TroubleSome]
+
+ this match {
+ case e: Foo[_]#T => ???
+ }
+} \ No newline at end of file
diff --git a/test/files/pos/t6201.scala b/test/files/pos/t6201.scala
new file mode 100644
index 0000000000..366c1f26eb
--- /dev/null
+++ b/test/files/pos/t6201.scala
@@ -0,0 +1,13 @@
+class Test {
+ class Foo1 {
+ def must(x: scala.xml.Elem) = ()
+ }
+
+ class Foo2 {
+ def must(x: Int) = ()
+ }
+ implicit def toFoo1(s: scala.xml.Elem) = new Foo1()
+ implicit def toFoo2(s: scala.xml.Elem) = new Foo2()
+
+ def is: Unit = { (<a>{"a"}</a>).must(<a>{"b"}</a>) }
+} \ No newline at end of file
diff --git a/test/files/pos/t6204-a.scala b/test/files/pos/t6204-a.scala
new file mode 100644
index 0000000000..bd8d5c437e
--- /dev/null
+++ b/test/files/pos/t6204-a.scala
@@ -0,0 +1,9 @@
+import scala.reflect.runtime.universe._
+
+object Bish {
+ def m {
+ object Bash {
+ typeOf[Option[_]]
+ }
+ }
+} \ No newline at end of file
diff --git a/test/files/pos/t6204-b.scala b/test/files/pos/t6204-b.scala
new file mode 100644
index 0000000000..86094d1a19
--- /dev/null
+++ b/test/files/pos/t6204-b.scala
@@ -0,0 +1,10 @@
+import scala.reflect.runtime.universe._
+
+object Bosh {
+ def Besh {
+ new {
+ val t = typeOf[Option[_]]
+ val x = t
+ }
+ }
+} \ No newline at end of file
diff --git a/test/files/pos/t6205.scala b/test/files/pos/t6205.scala
new file mode 100644
index 0000000000..02d924fe85
--- /dev/null
+++ b/test/files/pos/t6205.scala
@@ -0,0 +1,18 @@
+// original code by reporter
+class A[T]
+class Test1 {
+ def x(backing: Map[A[_], Any]) =
+ for( (k: A[kt], v) <- backing)
+ yield (k: A[kt])
+}
+
+// this tests same thing as above, but independent of library classes,
+// earlier expansions eliminated as well as variance (everything's invariant)
+case class Holder[A](a: A)
+class Mapped[A] { def map[T](f: Holder[A] => T): Iterable[T] = ??? }
+class Test2 {
+ def works(backing: Mapped[A[_]]): Iterable[A[_]]
+ = backing.map(x =>
+ x match {case Holder(k: A[kt]) => (k: A[kt])}
+ )
+} \ No newline at end of file
diff --git a/test/files/run/applydynamic_sip.flags b/test/files/run/applydynamic_sip.flags
new file mode 100644
index 0000000000..1141f97507
--- /dev/null
+++ b/test/files/run/applydynamic_sip.flags
@@ -0,0 +1 @@
+-language:dynamics
diff --git a/test/files/run/inline-ex-handlers.check b/test/files/run/inline-ex-handlers.check
index 25e1b2a4dd..a4c9f215e8 100644
--- a/test/files/run/inline-ex-handlers.check
+++ b/test/files/run/inline-ex-handlers.check
@@ -13,6 +13,10 @@
< 92 JUMP 2
<
< 2:
+383c382
+< 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
385c384
< blocks: [1,2,3,4,5,8,11,13,14,16]
---
@@ -34,11 +38,21 @@
< 101 JUMP 4
<
< 4:
-515c520
+438,441d442
+< 106 LOAD_LOCAL(value x5)
+< 106 CALL_METHOD MyException.message (dynamic)
+< 106 STORE_LOCAL(value message)
+< 106 SCOPE_ENTER value message
+443c444,445
+< 106 LOAD_LOCAL(value message)
+---
+> ? LOAD_LOCAL(value x5)
+> ? CALL_METHOD MyException.message (dynamic)
+515c517
< blocks: [1,2,3,4,6,7,8,9,10]
---
> blocks: [1,2,3,4,6,7,8,9,10,11,12,13]
-544c549,554
+544c546,551
< 306 THROW(MyException)
---
> ? JUMP 11
@@ -47,7 +61,7 @@
> ? LOAD_LOCAL(variable monitor4)
> 305 MONITOR_EXIT
> ? JUMP 12
-550c560,566
+550c557,563
< ? THROW(Throwable)
---
> ? JUMP 12
@@ -57,7 +71,7 @@
> 304 MONITOR_EXIT
> ? STORE_LOCAL(value t)
> ? JUMP 13
-556c572,585
+556c569,582
< ? THROW(Throwable)
---
> ? STORE_LOCAL(value t)
@@ -74,19 +88,19 @@
> 310 CALL_PRIMITIVE(EndConcat)
> 310 CALL_METHOD scala.Predef.println (dynamic)
> 310 JUMP 2
-580c609
+580c606
< catch (Throwable) in ArrayBuffer(7, 8, 9, 10) starting at: 6
---
> catch (Throwable) in ArrayBuffer(7, 8, 9, 10, 11) starting at: 6
-583c612
+583c609
< 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
-615c644
+615c641
< blocks: [1,2,3,4,5,6,7,9,10]
---
> blocks: [1,2,3,4,5,6,7,9,10,11,12]
-639c668,674
+639c665,671
< 78 THROW(IllegalArgumentException)
---
> ? STORE_LOCAL(value e)
@@ -96,7 +110,7 @@
> 81 LOAD_LOCAL(value e)
> ? STORE_LOCAL(variable exc1)
> ? JUMP 12
-668c703,717
+668c700,714
< 81 THROW(Exception)
---
> ? STORE_LOCAL(variable exc1)
@@ -114,15 +128,19 @@
> 84 STORE_LOCAL(variable result)
> 84 LOAD_LOCAL(variable exc1)
> 84 THROW(Throwable)
-690c739
+690c736
< catch (<none>) in ArrayBuffer(4, 6, 7, 9) starting at: 3
---
> catch (<none>) in ArrayBuffer(4, 6, 7, 9, 11) starting at: 3
-716c765
+714c760
+< 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
+716c762
< blocks: [1,2,3,4,5,6,9,12,14,17,18,19,22,25,27,28,30,31]
---
> blocks: [1,2,3,4,5,6,9,12,14,17,18,19,22,25,27,28,30,31,32,33,34]
-740c789,796
+740c786,793
< 172 THROW(MyException)
---
> ? STORE_LOCAL(value ex6)
@@ -133,12 +151,27 @@
> 170 STORE_LOCAL(value x4)
> 170 SCOPE_ENTER value x4
> 170 JUMP 18
-798c854,855
+787,790d839
+< 175 LOAD_LOCAL(value x5)
+< 175 CALL_METHOD MyException.message (dynamic)
+< 175 STORE_LOCAL(value message)
+< 175 SCOPE_ENTER value message
+792c841,842
+< 176 LOAD_LOCAL(value message)
+---
+> ? LOAD_LOCAL(value x5)
+> ? CALL_METHOD MyException.message (dynamic)
+796c846,847
+< 177 LOAD_LOCAL(value message)
+---
+> ? LOAD_LOCAL(value x5)
+> ? CALL_METHOD MyException.message (dynamic)
+798c849,850
< 177 THROW(MyException)
---
> ? STORE_LOCAL(value ex6)
> ? JUMP 33
-802c859,866
+802c854,861
< 170 THROW(Throwable)
---
> ? STORE_LOCAL(value ex6)
@@ -149,17 +182,32 @@
> 169 STORE_LOCAL(value x4)
> 169 SCOPE_ENTER value x4
> 169 JUMP 5
-837c901,902
+826,829d884
+< 180 LOAD_LOCAL(value x5)
+< 180 CALL_METHOD MyException.message (dynamic)
+< 180 STORE_LOCAL(value message)
+< 180 SCOPE_ENTER value message
+831c886,887
+< 181 LOAD_LOCAL(value message)
+---
+> ? LOAD_LOCAL(value x5)
+> ? CALL_METHOD MyException.message (dynamic)
+835c891,892
+< 182 LOAD_LOCAL(value message)
+---
+> ? LOAD_LOCAL(value x5)
+> ? CALL_METHOD MyException.message (dynamic)
+837c894,895
< 182 THROW(MyException)
---
> ? STORE_LOCAL(variable exc2)
> ? JUMP 34
-841c906,907
+841c899,900
< 169 THROW(Throwable)
---
> ? STORE_LOCAL(variable exc2)
> ? JUMP 34
-842a909,921
+842a902,914
> 34:
> 184 LOAD_MODULE object Predef
> 184 CONSTANT("finally")
@@ -173,19 +221,23 @@
> 185 LOAD_LOCAL(variable exc2)
> 185 THROW(Throwable)
>
-863c942
+863c935
< catch (Throwable) in ArrayBuffer(17, 18, 19, 22, 25, 27, 28, 30) starting at: 4
---
> catch (Throwable) in ArrayBuffer(17, 18, 19, 22, 25, 27, 28, 30, 32) starting at: 4
-866c945
+866c938
< catch (<none>) in ArrayBuffer(4, 5, 6, 9, 12, 17, 18, 19, 22, 25, 27, 28, 30) 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
-892c971
+890c962
+< 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
+892c964
< blocks: [1,2,3,6,7,8,11,14,16,17,19]
---
> blocks: [1,2,3,6,7,8,11,14,16,17,19,20]
-916c995,1002
+916c988,995
< 124 THROW(MyException)
---
> ? STORE_LOCAL(value ex6)
@@ -196,15 +248,29 @@
> 122 STORE_LOCAL(value x4)
> 122 SCOPE_ENTER value x4
> 122 JUMP 7
-979c1065
+945,948d1023
+< 127 LOAD_LOCAL(value x5)
+< 127 CALL_METHOD MyException.message (dynamic)
+< 127 STORE_LOCAL(value message)
+< 127 SCOPE_ENTER value message
+950c1025,1026
+< 127 LOAD_LOCAL(value message)
+---
+> ? LOAD_LOCAL(value x5)
+> ? CALL_METHOD MyException.message (dynamic)
+979c1055
< catch (IllegalArgumentException) in ArrayBuffer(6, 7, 8, 11, 14, 16, 17, 19) starting at: 3
---
> catch (IllegalArgumentException) in ArrayBuffer(6, 7, 8, 11, 14, 16, 17, 19, 20) starting at: 3
-1005c1091
+1003c1079
+< 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
+1005c1081
< blocks: [1,2,3,4,5,8,11,15,16,17,19]
---
> blocks: [1,2,3,5,8,11,15,16,17,19,20]
-1029c1115,1124
+1029c1105,1114
< 148 THROW(MyException)
---
> ? STORE_LOCAL(value ex6)
@@ -217,15 +283,25 @@
> 154 LOAD_LOCAL(value x4)
> 154 IS_INSTANCE REF(class MyException)
> 154 CZJUMP (BOOL)NE ? 5 : 11
-1050,1052d1144
+1050,1052d1134
< 145 JUMP 4
<
< 4:
-1288c1380
+1066,1069d1147
+< 154 LOAD_LOCAL(value x5)
+< 154 CALL_METHOD MyException.message (dynamic)
+< 154 STORE_LOCAL(value message)
+< 154 SCOPE_ENTER value message
+1071c1149,1150
+< 154 LOAD_LOCAL(value message)
+---
+> ? LOAD_LOCAL(value x5)
+> ? CALL_METHOD MyException.message (dynamic)
+1288c1367
< blocks: [1,2,3,4,5,7]
---
> blocks: [1,2,3,4,5,7,8]
-1312c1404,1411
+1312c1391,1398
< 38 THROW(IllegalArgumentException)
---
> ? STORE_LOCAL(value e)
@@ -236,16 +312,20 @@
> 42 CONSTANT("IllegalArgumentException")
> 42 CALL_METHOD scala.Predef.println (dynamic)
> 42 JUMP 2
-1361c1460
+1359c1445
+< 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
+1361c1447
< blocks: [1,2,3,4,5,8,11,13,14,16,17,19]
---
> blocks: [1,2,3,5,8,11,13,14,16,17,19,20]
-1385c1484,1485
+1385c1471,1472
< 203 THROW(MyException)
---
> ? STORE_LOCAL(value ex6)
> ? JUMP 20
-1405c1505,1514
+1405c1492,1501
< 209 THROW(MyException)
---
> ? STORE_LOCAL(value ex6)
@@ -258,15 +338,25 @@
> 212 LOAD_LOCAL(value x4)
> 212 IS_INSTANCE REF(class MyException)
> 212 CZJUMP (BOOL)NE ? 5 : 11
-1418,1420d1526
+1418,1420d1513
< 200 JUMP 4
<
< 4:
-1483c1589
+1434,1437d1526
+< 212 LOAD_LOCAL(value x5)
+< 212 CALL_METHOD MyException.message (dynamic)
+< 212 STORE_LOCAL(value message)
+< 212 SCOPE_ENTER value message
+1439c1528,1529
+< 213 LOAD_LOCAL(value message)
+---
+> ? LOAD_LOCAL(value x5)
+> ? CALL_METHOD MyException.message (dynamic)
+1483c1573
< blocks: [1,2,3,4,5,7]
---
> blocks: [1,2,3,4,5,7,8]
-1507c1613,1620
+1507c1597,1604
< 58 THROW(IllegalArgumentException)
---
> ? STORE_LOCAL(value e)
@@ -277,11 +367,11 @@
> 62 CONSTANT("RuntimeException")
> 62 CALL_METHOD scala.Predef.println (dynamic)
> 62 JUMP 2
-1556c1669
+1556c1653
< blocks: [1,2,3,4]
---
> blocks: [1,2,3,4,5]
-1576c1689,1694
+1576c1673,1678
< 229 THROW(MyException)
---
> ? JUMP 5
@@ -290,19 +380,19 @@
> ? LOAD_LOCAL(variable monitor1)
> 228 MONITOR_EXIT
> 228 THROW(Throwable)
-1582c1700
+1582c1684
< ? THROW(Throwable)
---
> 228 THROW(Throwable)
-1610c1728
+1610c1712
< locals: value args, variable result, variable monitor2, variable monitorResult1
---
> locals: value exception$1, value args, variable result, variable monitor2, variable monitorResult1
-1612c1730
+1612c1714
< blocks: [1,2,3,4]
---
> blocks: [1,2,3,4,5]
-1635c1753,1761
+1635c1737,1745
< 245 THROW(MyException)
---
> ? STORE_LOCAL(value exception$1)
@@ -314,7 +404,7 @@
> ? LOAD_LOCAL(variable monitor2)
> 244 MONITOR_EXIT
> 244 THROW(Throwable)
-1641c1767
+1641c1751
< ? THROW(Throwable)
---
> 244 THROW(Throwable)
diff --git a/test/files/run/reflection-enclosed-basic.check b/test/files/run/reflection-enclosed-basic.check
new file mode 100644
index 0000000000..41f6a72f1c
--- /dev/null
+++ b/test/files/run/reflection-enclosed-basic.check
@@ -0,0 +1,18 @@
+class B1
+B1
+1
+class B2
+B2
+2
+object B3
+B3
+3
+object B4
+B4
+4
+object B5
+B5
+5
+object B6
+B6
+6
diff --git a/test/files/run/reflection-enclosed-basic.scala b/test/files/run/reflection-enclosed-basic.scala
new file mode 100644
index 0000000000..1dcb6c2a27
--- /dev/null
+++ b/test/files/run/reflection-enclosed-basic.scala
@@ -0,0 +1,46 @@
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{currentMirror => cm}
+import scala.reflect.{classTag, ClassTag}
+
+class B1 { override def toString = "B1"; def foo = 1 }
+private class B2 { override def toString = "B2"; def foo = 2 }
+object B3 { override def toString = "B3"; def foo = 3 }
+private object B4 { override def toString = "B4"; def foo = 4 }
+object B5 extends B1 { override def toString = "B5"; override def foo = 5 }
+private object B6 extends B2 { override def toString = "B6"; override def foo = 6 }
+
+object Test extends App {
+ def testMethodInvocation(instance: Any) = {
+ val instanceMirror = cm.reflect(instance)
+ val method = instanceMirror.symbol.typeSignature.declaration(newTermName("foo")).asMethod
+ val methodMirror = instanceMirror.reflectMethod(method)
+ println(methodMirror())
+ }
+
+ def testNestedClass(name: String) = {
+ val sym = cm.staticClass(name)
+ println(sym)
+ val ctor = sym.typeSignature.declaration(newTermName("<init>")).asMethod
+ val ctorMirror = cm.reflectClass(sym).reflectConstructor(ctor)
+ val instance = ctorMirror()
+ println(instance)
+ testMethodInvocation(instance)
+ }
+
+ testNestedClass("B1")
+ testNestedClass("B2")
+
+ def testNestedModule(name: String) = {
+ val sym = cm.staticModule(name)
+ println(sym)
+ val moduleMirror = cm.reflectModule(sym)
+ val instance = moduleMirror.instance
+ println(instance)
+ testMethodInvocation(instance)
+ }
+
+ testNestedModule("B3")
+ testNestedModule("B4")
+ testNestedModule("B5")
+ testNestedModule("B6")
+}
diff --git a/test/files/run/reflection-enclosed-inner-basic.check b/test/files/run/reflection-enclosed-inner-basic.check
new file mode 100644
index 0000000000..984fb1ff12
--- /dev/null
+++ b/test/files/run/reflection-enclosed-inner-basic.check
@@ -0,0 +1,20 @@
+class B
+List(constructor B, class B1, class B2, object B3, object B4, object B5, object B6)
+class B1
+B1
+1
+class B2
+B2
+2
+object B3
+B3
+3
+object B4
+B4
+4
+object B5
+B5
+5
+object B6
+B6
+6
diff --git a/test/files/run/reflection-enclosed-inner-basic.scala b/test/files/run/reflection-enclosed-inner-basic.scala
new file mode 100644
index 0000000000..2b2c701993
--- /dev/null
+++ b/test/files/run/reflection-enclosed-inner-basic.scala
@@ -0,0 +1,52 @@
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{currentMirror => cm}
+import scala.reflect.{classTag, ClassTag}
+
+class B {
+ class B1 { override def toString = "B1"; def foo = 1 }
+ private class B2 { override def toString = "B2"; def foo = 2 }
+ object B3 { override def toString = "B3"; def foo = 3 }
+ private object B4 { override def toString = "B4"; def foo = 4 }
+ object B5 extends B1 { override def toString = "B5"; override def foo = 5 }
+ private object B6 extends B2 { override def toString = "B6"; override def foo = 6 }
+}
+
+object Test extends App {
+ val b = cm.classSymbol(classTag[B].runtimeClass)
+ println(b)
+ println(b.typeSignature.declarations.toList)
+
+ def testMethodInvocation(instance: Any) = {
+ val instanceMirror = cm.reflect(instance)
+ val method = instanceMirror.symbol.typeSignature.declaration(newTermName("foo")).asMethod
+ val methodMirror = instanceMirror.reflectMethod(method)
+ println(methodMirror())
+ }
+
+ def testInnerClass(name: String) = {
+ val sym = b.typeSignature.declaration(newTypeName(name)).asClass
+ println(sym)
+ val ctor = sym.typeSignature.declaration(newTermName("<init>")).asMethod
+ val ctorMirror = cm.reflect(new B).reflectClass(sym).reflectConstructor(ctor)
+ val instance = ctorMirror()
+ println(instance)
+ testMethodInvocation(instance)
+ }
+
+ testInnerClass("B1")
+ testInnerClass("B2")
+
+ def testInnerModule(name: String) = {
+ val sym = b.typeSignature.declaration(newTermName(name)).asModule
+ println(sym)
+ val moduleMirror = cm.reflect(new B).reflectModule(sym)
+ val instance = moduleMirror.instance
+ println(instance)
+ testMethodInvocation(instance)
+ }
+
+ testInnerModule("B3")
+ testInnerModule("B4")
+ testInnerModule("B5")
+ testInnerModule("B6")
+}
diff --git a/test/files/run/reflection-enclosed-inner-inner-basic.check b/test/files/run/reflection-enclosed-inner-inner-basic.check
new file mode 100644
index 0000000000..8987f31b18
--- /dev/null
+++ b/test/files/run/reflection-enclosed-inner-inner-basic.check
@@ -0,0 +1,20 @@
+class BB
+List(constructor BB, class B1, class B2, object B3, object B4, object B5, object B6)
+class B1
+B1
+1
+class B2
+B2
+2
+object B3
+B3
+3
+object B4
+B4
+4
+object B5
+B5
+5
+object B6
+B6
+6
diff --git a/test/files/run/reflection-enclosed-inner-inner-basic.scala b/test/files/run/reflection-enclosed-inner-inner-basic.scala
new file mode 100644
index 0000000000..1b9e19d37d
--- /dev/null
+++ b/test/files/run/reflection-enclosed-inner-inner-basic.scala
@@ -0,0 +1,58 @@
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{currentMirror => cm}
+import scala.reflect.{classTag, ClassTag}
+
+class B {
+ class BB {
+ class B1 { override def toString = "B1"; def foo = 1 }
+ private class B2 { override def toString = "B2"; def foo = 2 }
+ object B3 { override def toString = "B3"; def foo = 3 }
+ private object B4 { override def toString = "B4"; def foo = 4 }
+ object B5 extends B1 { override def toString = "B5"; override def foo = 5 }
+ private object B6 extends B2 { override def toString = "B6"; override def foo = 6 }
+ }
+}
+
+object Test extends App {
+ val b = cm.classSymbol(classTag[B#BB].runtimeClass)
+ println(b)
+ println(b.typeSignature.declarations.toList)
+
+ def testMethodInvocation(instance: Any) = {
+ val instanceMirror = cm.reflect(instance)
+ val method = instanceMirror.symbol.typeSignature.declaration(newTermName("foo")).asMethod
+ val methodMirror = instanceMirror.reflectMethod(method)
+ println(methodMirror())
+ }
+
+ def testInnerClass(name: String) = {
+ val sym = b.typeSignature.declaration(newTypeName(name)).asClass
+ println(sym)
+ val ctor = sym.typeSignature.declaration(newTermName("<init>")).asMethod
+ val outer1 = new B
+ val outer2 = new outer1.BB
+ val ctorMirror = cm.reflect(outer2).reflectClass(sym).reflectConstructor(ctor)
+ val instance = ctorMirror()
+ println(instance)
+ testMethodInvocation(instance)
+ }
+
+ testInnerClass("B1")
+ testInnerClass("B2")
+
+ def testInnerModule(name: String) = {
+ val sym = b.typeSignature.declaration(newTermName(name)).asModule
+ println(sym)
+ val outer1 = new B
+ val outer2 = new outer1.BB
+ val moduleMirror = cm.reflect(outer2).reflectModule(sym)
+ val instance = moduleMirror.instance
+ println(instance)
+ testMethodInvocation(instance)
+ }
+
+ testInnerModule("B3")
+ testInnerModule("B4")
+ testInnerModule("B5")
+ testInnerModule("B6")
+}
diff --git a/test/files/run/reflection-enclosed-inner-nested-basic.check b/test/files/run/reflection-enclosed-inner-nested-basic.check
new file mode 100644
index 0000000000..0f5176a6e7
--- /dev/null
+++ b/test/files/run/reflection-enclosed-inner-nested-basic.check
@@ -0,0 +1,20 @@
+object BB
+List(constructor BB, class B1, class B2, object B3, object B4, object B5, object B6)
+class B1
+B1
+1
+class B2
+B2
+2
+object B3
+B3
+3
+object B4
+B4
+4
+object B5
+B5
+5
+object B6
+B6
+6
diff --git a/test/files/run/reflection-enclosed-inner-nested-basic.scala b/test/files/run/reflection-enclosed-inner-nested-basic.scala
new file mode 100644
index 0000000000..2800ee2548
--- /dev/null
+++ b/test/files/run/reflection-enclosed-inner-nested-basic.scala
@@ -0,0 +1,55 @@
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{currentMirror => cm}
+import scala.reflect.{classTag, ClassTag}
+
+class B {
+ object BB {
+ class B1 { override def toString = "B1"; def foo = 1 }
+ private class B2 { override def toString = "B2"; def foo = 2 }
+ object B3 { override def toString = "B3"; def foo = 3 }
+ private object B4 { override def toString = "B4"; def foo = 4 }
+ object B5 extends B1 { override def toString = "B5"; override def foo = 5 }
+ private object B6 extends B2 { override def toString = "B6"; override def foo = 6 }
+ }
+}
+
+object Test extends App {
+ val outer1 = new B()
+ val b = cm.moduleSymbol(classTag[outer1.BB.type].runtimeClass)
+ println(b)
+ println(b.typeSignature.declarations.toList)
+
+ def testMethodInvocation(instance: Any) = {
+ val instanceMirror = cm.reflect(instance)
+ val method = instanceMirror.symbol.typeSignature.declaration(newTermName("foo")).asMethod
+ val methodMirror = instanceMirror.reflectMethod(method)
+ println(methodMirror())
+ }
+
+ def testNestedClass(name: String) = {
+ val sym = b.typeSignature.declaration(newTypeName(name)).asClass
+ println(sym)
+ val ctor = sym.typeSignature.declaration(newTermName("<init>")).asMethod
+ val ctorMirror = cm.reflect(outer1.BB).reflectClass(sym).reflectConstructor(ctor)
+ val instance = ctorMirror()
+ println(instance)
+ testMethodInvocation(instance)
+ }
+
+ testNestedClass("B1")
+ testNestedClass("B2")
+
+ def testNestedModule(name: String) = {
+ val sym = b.typeSignature.declaration(newTermName(name)).asModule
+ println(sym)
+ val moduleMirror = cm.reflect(outer1.BB).reflectModule(sym)
+ val instance = moduleMirror.instance
+ println(instance)
+ testMethodInvocation(instance)
+ }
+
+ testNestedModule("B3")
+ testNestedModule("B4")
+ testNestedModule("B5")
+ testNestedModule("B6")
+}
diff --git a/test/files/run/reflection-enclosed-nested-basic.check b/test/files/run/reflection-enclosed-nested-basic.check
new file mode 100644
index 0000000000..b0e61149f8
--- /dev/null
+++ b/test/files/run/reflection-enclosed-nested-basic.check
@@ -0,0 +1,20 @@
+object B
+List(constructor B, class B1, class B2, object B3, object B4, object B5, object B6)
+class B1
+B1
+1
+class B2
+B2
+2
+object B3
+B3
+3
+object B4
+B4
+4
+object B5
+B5
+5
+object B6
+B6
+6
diff --git a/test/files/run/reflection-enclosed-nested-basic.scala b/test/files/run/reflection-enclosed-nested-basic.scala
new file mode 100644
index 0000000000..8b740c2da2
--- /dev/null
+++ b/test/files/run/reflection-enclosed-nested-basic.scala
@@ -0,0 +1,52 @@
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{currentMirror => cm}
+import scala.reflect.{classTag, ClassTag}
+
+object B {
+ class B1 { override def toString = "B1"; def foo = 1 }
+ private class B2 { override def toString = "B2"; def foo = 2 }
+ object B3 { override def toString = "B3"; def foo = 3 }
+ private object B4 { override def toString = "B4"; def foo = 4 }
+ object B5 extends B1 { override def toString = "B5"; override def foo = 5 }
+ private object B6 extends B2 { override def toString = "B6"; override def foo = 6 }
+}
+
+object Test extends App {
+ val b = cm.moduleSymbol(classTag[B.type].runtimeClass)
+ println(b)
+ println(b.typeSignature.declarations.toList)
+
+ def testMethodInvocation(instance: Any) = {
+ val instanceMirror = cm.reflect(instance)
+ val method = instanceMirror.symbol.typeSignature.declaration(newTermName("foo")).asMethod
+ val methodMirror = instanceMirror.reflectMethod(method)
+ println(methodMirror())
+ }
+
+ def testNestedClass(name: String) = {
+ val sym = b.typeSignature.declaration(newTypeName(name)).asClass
+ println(sym)
+ val ctor = sym.typeSignature.declaration(newTermName("<init>")).asMethod
+ val ctorMirror = cm.reflectClass(sym).reflectConstructor(ctor)
+ val instance = ctorMirror()
+ println(instance)
+ testMethodInvocation(instance)
+ }
+
+ testNestedClass("B1")
+ testNestedClass("B2")
+
+ def testNestedModule(name: String) = {
+ val sym = b.typeSignature.declaration(newTermName(name)).asModule
+ println(sym)
+ val moduleMirror = cm.reflectModule(sym)
+ val instance = moduleMirror.instance
+ println(instance)
+ testMethodInvocation(instance)
+ }
+
+ testNestedModule("B3")
+ testNestedModule("B4")
+ testNestedModule("B5")
+ testNestedModule("B6")
+}
diff --git a/test/files/run/reflection-enclosed-nested-inner-basic.check b/test/files/run/reflection-enclosed-nested-inner-basic.check
new file mode 100644
index 0000000000..add7a81c0a
--- /dev/null
+++ b/test/files/run/reflection-enclosed-nested-inner-basic.check
@@ -0,0 +1,20 @@
+class BB
+List(constructor BB, class B1, class B2, object B3, object B4, object B5, object B6)
+class B1
+B1
+1
+class B2
+B2
+2
+object B3
+B3
+3
+object B4
+B4
+4
+object B5
+B5
+5
+object B6
+B6
+6
diff --git a/test/files/run/reflection-enclosed-nested-inner-basic.scala b/test/files/run/reflection-enclosed-nested-inner-basic.scala
new file mode 100644
index 0000000000..7466733d37
--- /dev/null
+++ b/test/files/run/reflection-enclosed-nested-inner-basic.scala
@@ -0,0 +1,54 @@
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{currentMirror => cm}
+import scala.reflect.{classTag, ClassTag}
+
+object B {
+ class BB {
+ class B1 { override def toString = "B1"; def foo = 1 }
+ private class B2 { override def toString = "B2"; def foo = 2 }
+ object B3 { override def toString = "B3"; def foo = 3 }
+ private object B4 { override def toString = "B4"; def foo = 4 }
+ object B5 extends B1 { override def toString = "B5"; override def foo = 5 }
+ private object B6 extends B2 { override def toString = "B6"; override def foo = 6 }
+ }
+}
+
+object Test extends App {
+ val b = cm.classSymbol(classTag[B.BB].runtimeClass)
+ println(b)
+ println(b.typeSignature.declarations.toList)
+
+ def testMethodInvocation(instance: Any) = {
+ val instanceMirror = cm.reflect(instance)
+ val method = instanceMirror.symbol.typeSignature.declaration(newTermName("foo")).asMethod
+ val methodMirror = instanceMirror.reflectMethod(method)
+ println(methodMirror())
+ }
+
+ def testInnerClass(name: String) = {
+ val sym = b.typeSignature.declaration(newTypeName(name)).asClass
+ println(sym)
+ val ctor = sym.typeSignature.declaration(newTermName("<init>")).asMethod
+ val ctorMirror = cm.reflect(new B.BB).reflectClass(sym).reflectConstructor(ctor)
+ val instance = ctorMirror()
+ println(instance)
+ testMethodInvocation(instance)
+ }
+
+ testInnerClass("B1")
+ testInnerClass("B2")
+
+ def testInnerModule(name: String) = {
+ val sym = b.typeSignature.declaration(newTermName(name)).asModule
+ println(sym)
+ val moduleMirror = cm.reflect(new B.BB).reflectModule(sym)
+ val instance = moduleMirror.instance
+ println(instance)
+ testMethodInvocation(instance)
+ }
+
+ testInnerModule("B3")
+ testInnerModule("B4")
+ testInnerModule("B5")
+ testInnerModule("B6")
+}
diff --git a/test/files/run/reflection-enclosed-nested-nested-basic.check b/test/files/run/reflection-enclosed-nested-nested-basic.check
new file mode 100644
index 0000000000..0f5176a6e7
--- /dev/null
+++ b/test/files/run/reflection-enclosed-nested-nested-basic.check
@@ -0,0 +1,20 @@
+object BB
+List(constructor BB, class B1, class B2, object B3, object B4, object B5, object B6)
+class B1
+B1
+1
+class B2
+B2
+2
+object B3
+B3
+3
+object B4
+B4
+4
+object B5
+B5
+5
+object B6
+B6
+6
diff --git a/test/files/run/reflection-enclosed-nested-nested-basic.scala b/test/files/run/reflection-enclosed-nested-nested-basic.scala
new file mode 100644
index 0000000000..8335ea482a
--- /dev/null
+++ b/test/files/run/reflection-enclosed-nested-nested-basic.scala
@@ -0,0 +1,54 @@
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{currentMirror => cm}
+import scala.reflect.{classTag, ClassTag}
+
+object B {
+ object BB {
+ class B1 { override def toString = "B1"; def foo = 1 }
+ private class B2 { override def toString = "B2"; def foo = 2 }
+ object B3 { override def toString = "B3"; def foo = 3 }
+ private object B4 { override def toString = "B4"; def foo = 4 }
+ object B5 extends B1 { override def toString = "B5"; override def foo = 5 }
+ private object B6 extends B2 { override def toString = "B6"; override def foo = 6 }
+ }
+}
+
+object Test extends App {
+ val b = cm.moduleSymbol(classTag[B.BB.type].runtimeClass)
+ println(b)
+ println(b.typeSignature.declarations.toList)
+
+ def testMethodInvocation(instance: Any) = {
+ val instanceMirror = cm.reflect(instance)
+ val method = instanceMirror.symbol.typeSignature.declaration(newTermName("foo")).asMethod
+ val methodMirror = instanceMirror.reflectMethod(method)
+ println(methodMirror())
+ }
+
+ def testNestedClass(name: String) = {
+ val sym = b.typeSignature.declaration(newTypeName(name)).asClass
+ println(sym)
+ val ctor = sym.typeSignature.declaration(newTermName("<init>")).asMethod
+ val ctorMirror = cm.reflectClass(sym).reflectConstructor(ctor)
+ val instance = ctorMirror()
+ println(instance)
+ testMethodInvocation(instance)
+ }
+
+ testNestedClass("B1")
+ testNestedClass("B2")
+
+ def testNestedModule(name: String) = {
+ val sym = b.typeSignature.declaration(newTermName(name)).asModule
+ println(sym)
+ val moduleMirror = cm.reflectModule(sym)
+ val instance = moduleMirror.instance
+ println(instance)
+ testMethodInvocation(instance)
+ }
+
+ testNestedModule("B3")
+ testNestedModule("B4")
+ testNestedModule("B5")
+ testNestedModule("B6")
+}
diff --git a/test/files/run/reflection-modulemirror-inner-good.check b/test/files/run/reflection-modulemirror-inner-good.check
index 0bf38a73d1..fe658e7087 100644
--- a/test/files/run/reflection-modulemirror-inner-good.check
+++ b/test/files/run/reflection-modulemirror-inner-good.check
@@ -1,2 +1 @@
-inner and nested modules are not supported yet
-()
+R
diff --git a/test/files/run/reflection-modulemirror-nested-good.check b/test/files/run/reflection-modulemirror-nested-good.check
index 0bf38a73d1..fe658e7087 100644
--- a/test/files/run/reflection-modulemirror-nested-good.check
+++ b/test/files/run/reflection-modulemirror-nested-good.check
@@ -1,2 +1 @@
-inner and nested modules are not supported yet
-()
+R
diff --git a/test/files/run/reflection-repl-classes.check b/test/files/run/reflection-repl-classes.check
new file mode 100644
index 0000000000..1c7f86c90c
--- /dev/null
+++ b/test/files/run/reflection-repl-classes.check
@@ -0,0 +1,35 @@
+Type in expressions to have them evaluated.
+Type :help for more information.
+
+scala>
+
+scala> class A
+defined class A
+
+scala>
+
+scala> class B {
+ def foo(x: A) = 1
+}
+defined class B
+
+scala>
+
+scala> object defs {
+ val cm = reflect.runtime.currentMirror
+ val u = cm.universe
+ val im = cm.reflect(new B)
+ val method = im.symbol.typeSignature.member(u.newTermName("foo")).asMethod
+ val mm = im.reflectMethod(method)
+}
+defined module defs
+
+scala> import defs._
+import defs._
+
+scala>
+
+scala> mm(new A)
+res0: Any = 1
+
+scala>
diff --git a/test/files/run/reflection-repl-classes.scala b/test/files/run/reflection-repl-classes.scala
new file mode 100644
index 0000000000..80e332cde3
--- /dev/null
+++ b/test/files/run/reflection-repl-classes.scala
@@ -0,0 +1,22 @@
+import scala.tools.partest.ReplTest
+
+object Test extends ReplTest {
+ def code = """
+ |class A
+ |
+ |class B {
+ | def foo(x: A) = 1
+ |}
+ |
+ |object defs {
+ | val cm = reflect.runtime.currentMirror
+ | val u = cm.universe
+ | val im = cm.reflect(new B)
+ | val method = im.symbol.typeSignature.member(u.newTermName("foo")).asMethod
+ | val mm = im.reflectMethod(method)
+ |}
+ |import defs._
+ |
+ |mm(new A)
+ |""".stripMargin
+}
diff --git a/test/files/run/reflection-repl.check b/test/files/run/reflection-repl-elementary.check
index 341dd10ab0..341dd10ab0 100644
--- a/test/files/run/reflection-repl.check
+++ b/test/files/run/reflection-repl-elementary.check
diff --git a/test/files/run/reflection-repl.scala b/test/files/run/reflection-repl-elementary.scala
index 72b65a1a70..72b65a1a70 100644
--- a/test/files/run/reflection-repl.scala
+++ b/test/files/run/reflection-repl-elementary.scala
diff --git a/test/files/run/reflection-sanitychecks.check b/test/files/run/reflection-sanitychecks.check
index a1df486b51..821457a999 100644
--- a/test/files/run/reflection-sanitychecks.check
+++ b/test/files/run/reflection-sanitychecks.check
@@ -6,7 +6,7 @@ method #2: 14
constructor #1: scala.ScalaReflectionException: expected a constructor of class D, you provided method bar
constructor #2: scala.ScalaReflectionException: expected a constructor of class D, you provided constructor C
class: CC
-object: java.lang.Error: inner and nested modules are not supported yet
+object: CO
=========members of D in a mirror of D=========
field #1: 21
@@ -16,7 +16,7 @@ method #2: 14
constructor #1: scala.ScalaReflectionException: expected a constructor of class D, you provided method bar
constructor #2: an instance of class D
class: CC
-object: java.lang.Error: inner and nested modules are not supported yet
+object: CO
=========members of E in a mirror of D=========
field #1: scala.ScalaReflectionException: expected a member of class D, you provided value E.foo
diff --git a/test/files/run/t4536.flags b/test/files/run/t4536.flags
new file mode 100644
index 0000000000..1141f97507
--- /dev/null
+++ b/test/files/run/t4536.flags
@@ -0,0 +1 @@
+-language:dynamics
diff --git a/test/files/run/t5040.flags b/test/files/run/t5040.flags
new file mode 100644
index 0000000000..1141f97507
--- /dev/null
+++ b/test/files/run/t5040.flags
@@ -0,0 +1 @@
+-language:dynamics
diff --git a/test/files/run/t6197.check b/test/files/run/t6197.check
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/test/files/run/t6197.check
diff --git a/test/files/run/t6197.scala b/test/files/run/t6197.scala
new file mode 100644
index 0000000000..5ab4b002d7
--- /dev/null
+++ b/test/files/run/t6197.scala
@@ -0,0 +1,21 @@
+import scala.collection.immutable._
+
+object Test extends App {
+
+ // test that a HashTrieSet with one leaf element is not created!
+ val x = HashSet.empty + 1 + 2
+ if(x.getClass.getSimpleName != "HashTrieSet")
+ println("A hash set containing two non-colliding values should be a HashTrieSet")
+
+ val y = x - 1
+ if(y.getClass.getSimpleName != "HashSet1")
+ println("A hash set containing one element should always use HashSet1")
+
+ // it is pretty hard to test that the case where a HashTrieSet has one element which
+ // is itself of type HashTrieS t. That is because the improve hash function makes it very difficult
+ // to find keys that will have hashes that are close together.
+ //
+ // However, it is also not necessary. Removing the ability of a HashTrieSet to have
+ // one child of type HashTrieSet completely breaks the HashSet, so that many other
+ // tests fail
+}
diff --git a/test/files/run/t6198.check b/test/files/run/t6198.check
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/test/files/run/t6198.check
diff --git a/test/files/run/t6198.scala b/test/files/run/t6198.scala
new file mode 100644
index 0000000000..5aa8f1c1cf
--- /dev/null
+++ b/test/files/run/t6198.scala
@@ -0,0 +1,24 @@
+import scala.collection.immutable._
+
+object Test extends App {
+ // test that ListSet.tail does not use a builder
+ // we can't test for O(1) behavior, so the best we can do is to
+ // check that ls.tail always returns the same instance
+ val ls = ListSet.empty[Int] + 1 + 2
+
+ if(ls.tail ne ls.tail)
+ println("ListSet.tail should not use a builder!")
+
+ // class that always causes hash collisions
+ case class Collision(value:Int) { override def hashCode = 0 }
+
+ // create a set that should have a collison
+ val x = HashSet.empty + Collision(0) + Collision(1)
+ if(x.getClass.getSimpleName != "HashSetCollision1")
+ println("HashSet of size >1 with collisions should use HashSetCollision")
+
+ // remove the collision again by removing all but one element
+ val y = x - Collision(0)
+ if(y.getClass.getSimpleName != "HashSet1")
+ println("HashSet of size 1 should use HashSet1" + y.getClass)
+}
diff --git a/test/files/run/t6223.check b/test/files/run/t6223.check
new file mode 100644
index 0000000000..90ec019407
--- /dev/null
+++ b/test/files/run/t6223.check
@@ -0,0 +1,4 @@
+bar
+bar$mcI$sp
+bar$mIc$sp
+bar$mIcI$sp
diff --git a/test/files/run/t6223.scala b/test/files/run/t6223.scala
new file mode 100644
index 0000000000..4ab7c832e6
--- /dev/null
+++ b/test/files/run/t6223.scala
@@ -0,0 +1,11 @@
+class Foo[@specialized(Int) A](a:A) {
+ def bar[@specialized(Int) B](f:A => B) = new Foo(f(a))
+}
+
+object Test {
+ def main(args:Array[String]) {
+ val f = new Foo(333)
+ val ms = f.getClass().getDeclaredMethods()
+ ms.foreach(m => println(m.getName))
+ }
+}
diff --git a/test/scaladoc/run/SI-5933.check b/test/scaladoc/run/SI-5933.check
new file mode 100644
index 0000000000..619c56180b
--- /dev/null
+++ b/test/scaladoc/run/SI-5933.check
@@ -0,0 +1 @@
+Done.
diff --git a/test/scaladoc/run/SI-5933.scala b/test/scaladoc/run/SI-5933.scala
new file mode 100644
index 0000000000..087116fa71
--- /dev/null
+++ b/test/scaladoc/run/SI-5933.scala
@@ -0,0 +1,43 @@
+import scala.tools.nsc.doc.model._
+import scala.tools.partest.ScaladocModelTest
+
+object Test extends ScaladocModelTest {
+
+ // Test code
+ override def code = """
+ // This example should compile without errors, and the pattern match should be correctly displayed
+
+ import language.higherKinds
+
+ abstract class Base[M[_, _]] {
+ def foo[A, B]: M[(A, B), Any]
+ }
+
+ class Derived extends Base[PartialFunction] {
+ def foo[A, B] /*: PartialFunction[(A, B) => Any]*/ = { case (a, b) => (a: A, b: B) }
+ }
+
+ object Test {
+ lazy val lx = { println("hello"); 3 }
+ def test1(x: Int = lx) = ???
+ def test2(x: Int = lx match { case 0 => 1; case 3 => 4 }) = ???
+ }
+ """
+
+ // no need for special settings
+ def scaladocSettings = ""
+
+ def testModel(rootPackage: Package) = {
+ // get the quick access implicit defs in scope (_package(s), _class(es), _trait(s), object(s) _method(s), _value(s))
+ import access._
+
+ val Test = rootPackage._object("Test")
+ val test1 = Test._method("test1")
+ val test2 = Test._method("test2")
+
+ def assertEqual(s1: String, s2: String) = assert(s1 == s2, s1 + " == " + s2)
+
+ assertEqual(test1.valueParams(0)(0).defaultValue.get.expression, "lx")
+ assertEqual(test2.valueParams(0)(0).defaultValue.get.expression, "lx match { case 0 => 1; case 3 => 4 }")
+ }
+} \ No newline at end of file