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/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/pos/t6040.scala3
-rw-r--r--test/files/pos/t6145.scala11
-rw-r--r--test/files/pos/t6205.scala18
-rw-r--r--test/files/run/applydynamic_sip.flags1
-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
37 files changed, 900 insertions, 233 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/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/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/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/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