summaryrefslogtreecommitdiff
path: root/test/files/jvm
diff options
context:
space:
mode:
Diffstat (limited to 'test/files/jvm')
-rw-r--r--test/files/jvm/actor-exceptions.scala4
-rw-r--r--test/files/jvm/actor-executor.scala5
-rw-r--r--test/files/jvm/actor-executor2.scala6
-rw-r--r--test/files/jvm/actor-executor3.scala6
-rw-r--r--test/files/jvm/actor-getstate.scala6
-rw-r--r--test/files/jvm/actor-link-getstate.scala9
-rw-r--r--test/files/jvm/actor-looping.scala3
-rw-r--r--test/files/jvm/actor-normal-exit.scala4
-rw-r--r--test/files/jvm/actor-receivewithin.scala5
-rw-r--r--test/files/jvm/actor-sync-send-timeout.scala5
-rw-r--r--test/files/jvm/actor-termination.scala3
-rw-r--r--test/files/jvm/actor-uncaught-exception.scala3
-rw-r--r--test/files/jvm/actor-uncaught-exception2.check4
-rw-r--r--test/files/jvm/actor-uncaught-exception2.scala4
-rw-r--r--test/files/jvm/annotations.scala3
-rw-r--r--test/files/jvm/constant-optimization/Foo_1.flags1
-rw-r--r--test/files/jvm/constant-optimization/Foo_1.scala9
-rw-r--r--test/files/jvm/constant-optimization/Test.scala27
-rw-r--r--test/files/jvm/daemon-actor-termination.scala4
-rw-r--r--test/files/jvm/deprecation.check3
-rw-r--r--test/files/jvm/duration-tck.scala2
-rw-r--r--test/files/jvm/future-alarm.scala4
-rw-r--r--test/files/jvm/future-awaitall-zero.scala6
-rw-r--r--test/files/jvm/future-spec/FutureTests.scala2
-rw-r--r--test/files/jvm/future-spec/main.scala10
-rw-r--r--test/files/jvm/future-termination.scala4
-rw-r--r--test/files/jvm/interpreter.check6
-rw-r--r--test/files/jvm/interpreter.scala2
-rw-r--r--test/files/jvm/manifests-new.scala34
-rw-r--r--test/files/jvm/manifests-old.scala34
-rw-r--r--test/files/jvm/named-args-in-order.check3
-rw-r--r--test/files/jvm/named-args-in-order/SameBytecode.scala9
-rw-r--r--test/files/jvm/named-args-in-order/Test.scala10
-rw-r--r--test/files/jvm/non-fatal-tests.scala6
-rw-r--r--test/files/jvm/nooptimise/Foo_1.flags1
-rw-r--r--test/files/jvm/nooptimise/Foo_1.scala8
-rw-r--r--test/files/jvm/nooptimise/Test.scala23
-rw-r--r--test/files/jvm/reactor-exceptionOnSend.scala5
-rw-r--r--test/files/jvm/reactor-producer-consumer.scala4
-rw-r--r--test/files/jvm/reactor.scala16
-rw-r--r--test/files/jvm/replyablereactor.scala5
-rw-r--r--test/files/jvm/replyablereactor2.scala5
-rw-r--r--test/files/jvm/replyablereactor3.scala5
-rw-r--r--test/files/jvm/replyablereactor4.scala5
-rw-r--r--test/files/jvm/replyreactor-react-sender.scala6
-rw-r--r--test/files/jvm/replyreactor.scala4
-rw-r--r--test/files/jvm/scheduler-adapter.scala5
-rw-r--r--test/files/jvm/serialization.scala17
-rw-r--r--test/files/jvm/stringbuilder.scala1
-rw-r--r--test/files/jvm/t1143-2/t1143-2.scala26
-rw-r--r--test/files/jvm/t1143.scala12
-rw-r--r--test/files/jvm/t1342/SI.scala2
-rw-r--r--test/files/jvm/t1449.scala9
-rw-r--r--test/files/jvm/t1600.scala3
-rw-r--r--test/files/jvm/t1948.scala6
-rw-r--r--test/files/jvm/t2163/t2163.java (renamed from test/files/jvm/ticket2163/ticket2163.java)4
-rw-r--r--test/files/jvm/t2163/t2163.scala10
-rw-r--r--test/files/jvm/t2359.scala4
-rw-r--r--test/files/jvm/t2470.cmds3
-rw-r--r--test/files/jvm/t2530.scala6
-rw-r--r--test/files/jvm/t2570/Test.scala2
-rw-r--r--test/files/jvm/t3003.cmds2
-rw-r--r--test/files/jvm/t3102.scala7
-rw-r--r--test/files/jvm/t3356.scala5
-rw-r--r--test/files/jvm/t3365.scala5
-rw-r--r--test/files/jvm/t3407.scala4
-rw-r--r--test/files/jvm/t3412-channel.scala4
-rw-r--r--test/files/jvm/t3412.scala4
-rw-r--r--test/files/jvm/t3415/HelloWorld.scala2
-rw-r--r--test/files/jvm/t3470.scala4
-rw-r--r--test/files/jvm/t3838.scala4
-rw-r--r--test/files/jvm/t4283/AbstractFoo.java (renamed from test/files/jvm/ticket4283/AbstractFoo.java)0
-rw-r--r--test/files/jvm/t4283/ScalaBipp.scala (renamed from test/files/jvm/ticket4283/ScalaBipp.scala)0
-rw-r--r--test/files/jvm/t4283/Test.scala (renamed from test/files/jvm/ticket4283/Test.scala)0
-rw-r--r--test/files/jvm/t560bis.scala2
-rw-r--r--test/files/jvm/t6941/Analyzed_1.flags1
-rw-r--r--test/files/jvm/t7006.check28
-rw-r--r--test/files/jvm/t7006/Foo_1.flags1
-rw-r--r--test/files/jvm/t7006/Foo_1.scala10
-rw-r--r--test/files/jvm/t7006/Test.scala19
-rw-r--r--test/files/jvm/t7146.scala2
-rw-r--r--test/files/jvm/t7181/Foo_1.scala26
-rw-r--r--test/files/jvm/t7181/Test.scala24
-rw-r--r--test/files/jvm/ticket2163/ticket2163.scala5
-rw-r--r--test/files/jvm/try-type-tests.scala3
-rw-r--r--test/files/jvm/typerep.scala26
-rw-r--r--test/files/jvm/unreachable/Foo_1.flags1
-rw-r--r--test/files/jvm/unreachable/Foo_1.scala112
-rw-r--r--test/files/jvm/unreachable/Test.scala23
-rw-r--r--test/files/jvm/value-class-boxing.check7
-rw-r--r--test/files/jvm/value-class-boxing/Analyzed_1.scala17
-rw-r--r--test/files/jvm/value-class-boxing/test.scala15
-rw-r--r--test/files/jvm/xml01.scala3
-rwxr-xr-xtest/files/jvm/xml03syntax.check1
-rw-r--r--test/files/jvm/xml03syntax.scala2
-rw-r--r--test/files/jvm/xmlattr.scala7
96 files changed, 677 insertions, 142 deletions
diff --git a/test/files/jvm/actor-exceptions.scala b/test/files/jvm/actor-exceptions.scala
index 3ee4db9ed2..bdd983a0e8 100644
--- a/test/files/jvm/actor-exceptions.scala
+++ b/test/files/jvm/actor-exceptions.scala
@@ -1,4 +1,7 @@
+
+@deprecated("Suppress warnings", since="2.11")
+object Test {
import scala.actors.{Actor, Exit}
import Actor._
@@ -58,7 +61,6 @@ object Slave extends Actor {
case object A
-object Test {
def main(args: Array[String]) {
Master.start()
}
diff --git a/test/files/jvm/actor-executor.scala b/test/files/jvm/actor-executor.scala
index b1f9caebdd..0fc28b4d85 100644
--- a/test/files/jvm/actor-executor.scala
+++ b/test/files/jvm/actor-executor.scala
@@ -1,3 +1,7 @@
+
+
+@deprecated("Suppress warnings", since="2.11")
+object Test {
import java.util.concurrent.Executors
import scala.actors.{Actor, SchedulerAdapter}
import Actor._
@@ -50,7 +54,6 @@ object Two extends AdaptedActor {
}
}
-object Test {
val executor =
Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors())
diff --git a/test/files/jvm/actor-executor2.scala b/test/files/jvm/actor-executor2.scala
index f8fcaef69f..5badf2ae7e 100644
--- a/test/files/jvm/actor-executor2.scala
+++ b/test/files/jvm/actor-executor2.scala
@@ -1,3 +1,8 @@
+
+
+
+@deprecated("Suppress warnings", since="2.11")
+object Test {
import scala.actors.{Actor, SchedulerAdapter, Exit}
import Actor._
import java.util.concurrent.{Executors, RejectedExecutionException}
@@ -48,7 +53,6 @@ trait AdaptedActor extends Actor {
Test.scheduler
}
-object Test {
val NUM_MSG = 100000
val executor =
diff --git a/test/files/jvm/actor-executor3.scala b/test/files/jvm/actor-executor3.scala
index 4fde2c6c5f..f8b57d84b3 100644
--- a/test/files/jvm/actor-executor3.scala
+++ b/test/files/jvm/actor-executor3.scala
@@ -1,3 +1,8 @@
+
+
+
+@deprecated("Suppress warnings", since="2.11")
+object Test {
import scala.actors.Actor
import scala.actors.scheduler.ExecutorScheduler
import java.util.concurrent.Executors
@@ -48,7 +53,6 @@ trait AdaptedActor extends Actor {
Test.scheduler
}
-object Test {
val NUM_MSG = 100000
val executor =
diff --git a/test/files/jvm/actor-getstate.scala b/test/files/jvm/actor-getstate.scala
index a6e15a8721..425efbe5e6 100644
--- a/test/files/jvm/actor-getstate.scala
+++ b/test/files/jvm/actor-getstate.scala
@@ -1,7 +1,9 @@
-import scala.actors.{Reactor, Actor, TIMEOUT}
-import Actor._
+
+@deprecated("Suppress warnings", since="2.11")
object Test {
+ import scala.actors.{Reactor, Actor, TIMEOUT}
+ import Actor._
def assert(cond: => Boolean, hint: String) {
if (!cond)
diff --git a/test/files/jvm/actor-link-getstate.scala b/test/files/jvm/actor-link-getstate.scala
index c24daf2eff..d8b8ada1e6 100644
--- a/test/files/jvm/actor-link-getstate.scala
+++ b/test/files/jvm/actor-link-getstate.scala
@@ -1,5 +1,9 @@
-import scala.actors.{Actor, Exit}
-import scala.actors.Actor._
+
+
+@deprecated("Suppress warnings", since="2.11")
+object Test {
+ import scala.actors.{Actor, Exit}
+ import scala.actors.Actor._
case class MyException(text: String) extends Exception(text) {
override def fillInStackTrace() = this
@@ -39,7 +43,6 @@ object Master extends Actor {
}
}
-object Test {
def main(args: Array[String]) {
actor {
diff --git a/test/files/jvm/actor-looping.scala b/test/files/jvm/actor-looping.scala
index 475d4754ce..7bc6f1e5c5 100644
--- a/test/files/jvm/actor-looping.scala
+++ b/test/files/jvm/actor-looping.scala
@@ -1,7 +1,8 @@
-import scala.actors.Actor._
+@deprecated("Suppress warnings", since="2.11")
object Test {
+ import scala.actors.Actor._
case object A
def main(args: Array[String]) {
diff --git a/test/files/jvm/actor-normal-exit.scala b/test/files/jvm/actor-normal-exit.scala
index 20863d5bb0..90495866e2 100644
--- a/test/files/jvm/actor-normal-exit.scala
+++ b/test/files/jvm/actor-normal-exit.scala
@@ -1,7 +1,9 @@
-import scala.actors.{Actor, Exit}
+
+@deprecated("Suppress warnings", since="2.11")
object Test {
+ import scala.actors.{Actor, Exit}
object Master extends Actor {
trapExit = true
def act() {
diff --git a/test/files/jvm/actor-receivewithin.scala b/test/files/jvm/actor-receivewithin.scala
index a5c87c2722..5982462502 100644
--- a/test/files/jvm/actor-receivewithin.scala
+++ b/test/files/jvm/actor-receivewithin.scala
@@ -1,3 +1,7 @@
+
+
+@deprecated("Suppress warnings", since="2.11")
+object Test {
import scala.actors.{Actor, TIMEOUT}
object A extends Actor {
@@ -62,7 +66,6 @@ object B extends Actor {
}
}
-object Test {
def main(args:Array[String]) {
B.start()
}
diff --git a/test/files/jvm/actor-sync-send-timeout.scala b/test/files/jvm/actor-sync-send-timeout.scala
index 21e624bd0a..42e0be4a8c 100644
--- a/test/files/jvm/actor-sync-send-timeout.scala
+++ b/test/files/jvm/actor-sync-send-timeout.scala
@@ -1,8 +1,9 @@
+@deprecated("Suppress warnings", since="2.11")
+object Test {
import scala.actors.Actor
/* This test is a regression test for SI-4759.
*/
-object Test {
val Runs = 5
def main(args: Array[String]) = {
@@ -14,7 +15,6 @@ object Test {
}
//println("done sending to A1")
}
-}
object A2 extends Actor {
this.start()
@@ -45,3 +45,4 @@ object A1 extends Actor {
}
}
}
+}
diff --git a/test/files/jvm/actor-termination.scala b/test/files/jvm/actor-termination.scala
index d8e44a2797..4a6bf92d48 100644
--- a/test/files/jvm/actor-termination.scala
+++ b/test/files/jvm/actor-termination.scala
@@ -1,8 +1,9 @@
-import scala.actors.Actor
/* Test that an actor that hasn't finished prevents termination */
+@deprecated("Suppress warnings", since="2.11")
object Test {
+ import scala.actors.Actor
def main(args: Array[String]) {
Actor.actor {
try {
diff --git a/test/files/jvm/actor-uncaught-exception.scala b/test/files/jvm/actor-uncaught-exception.scala
index 5ae66de640..5285b7519f 100644
--- a/test/files/jvm/actor-uncaught-exception.scala
+++ b/test/files/jvm/actor-uncaught-exception.scala
@@ -1,10 +1,11 @@
+@deprecated("Suppress warnings", since="2.11")
+object Test {
import scala.actors.{Actor, Exit}
class MyException(msg: String) extends Exception(msg) {
override def fillInStackTrace() = this
}
-object Test {
case object StartError extends Actor {
def act() {
diff --git a/test/files/jvm/actor-uncaught-exception2.check b/test/files/jvm/actor-uncaught-exception2.check
index 870a5d32f9..a54f374aed 100644
--- a/test/files/jvm/actor-uncaught-exception2.check
+++ b/test/files/jvm/actor-uncaught-exception2.check
@@ -1,2 +1,2 @@
-UncaughtException(StartError,None,None,MyException: I don't want to run!)
-UncaughtException(MessageError,Some('ping),Some(Supervisor),MyException: No message for me!)
+UncaughtException(StartError,None,None,Test$MyException: I don't want to run!)
+UncaughtException(MessageError,Some('ping),Some(Supervisor),Test$MyException: No message for me!)
diff --git a/test/files/jvm/actor-uncaught-exception2.scala b/test/files/jvm/actor-uncaught-exception2.scala
index 0364cbeb03..f56217c187 100644
--- a/test/files/jvm/actor-uncaught-exception2.scala
+++ b/test/files/jvm/actor-uncaught-exception2.scala
@@ -1,11 +1,11 @@
+@deprecated("Suppress warnings", since="2.11")
+object Test {
import scala.actors.{Actor, Exit, Debug}
class MyException(msg: String) extends Exception(msg) {
override def fillInStackTrace() = this
}
-object Test {
-
case object StartError extends Actor {
def act() {
try {
diff --git a/test/files/jvm/annotations.scala b/test/files/jvm/annotations.scala
index 77a45fae89..c42eceef4c 100644
--- a/test/files/jvm/annotations.scala
+++ b/test/files/jvm/annotations.scala
@@ -1,3 +1,6 @@
+
+import scala.language.{ higherKinds, reflectiveCalls }
+
object Test1 {
class Foo {
@remote
diff --git a/test/files/jvm/constant-optimization/Foo_1.flags b/test/files/jvm/constant-optimization/Foo_1.flags
new file mode 100644
index 0000000000..86f52af447
--- /dev/null
+++ b/test/files/jvm/constant-optimization/Foo_1.flags
@@ -0,0 +1 @@
+-Ynooptimise -Yconst-opt \ No newline at end of file
diff --git a/test/files/jvm/constant-optimization/Foo_1.scala b/test/files/jvm/constant-optimization/Foo_1.scala
new file mode 100644
index 0000000000..cb67ad4e90
--- /dev/null
+++ b/test/files/jvm/constant-optimization/Foo_1.scala
@@ -0,0 +1,9 @@
+class Foo_1 {
+ def foo() {
+ // constant optimization should eliminate all branches
+ val i = 1
+ val x = if (i != 1) null else "good"
+ val y = if (x == null) "good" else x + ""
+ println(y)
+ }
+} \ No newline at end of file
diff --git a/test/files/jvm/constant-optimization/Test.scala b/test/files/jvm/constant-optimization/Test.scala
new file mode 100644
index 0000000000..283aa6f47a
--- /dev/null
+++ b/test/files/jvm/constant-optimization/Test.scala
@@ -0,0 +1,27 @@
+
+import scala.tools.partest.BytecodeTest
+import scala.tools.asm
+import asm.tree.InsnList
+import scala.collection.JavaConverters._
+
+object Test extends BytecodeTest {
+ val comparisons = Set(asm.Opcodes.IF_ACMPEQ, asm.Opcodes.IF_ACMPNE, asm.Opcodes.IF_ICMPEQ, asm.Opcodes.IF_ICMPGE, asm.Opcodes.IF_ICMPGT, asm.Opcodes.IF_ICMPLE,
+ asm.Opcodes.IF_ICMPLT, asm.Opcodes.IF_ICMPNE, asm.Opcodes.IFEQ, asm.Opcodes.IFGE, asm.Opcodes.IFGT, asm.Opcodes.IFLE, asm.Opcodes.IFLT,
+ asm.Opcodes.IFNE, asm.Opcodes.IFNONNULL, asm.Opcodes.IFNULL)
+
+ def show: Unit = {
+ val classNode = loadClassNode("Foo_1")
+ val methodNode = getMethod(classNode, "foo")
+ // after optimization there should be no comparisons left
+ val expected = 0
+
+ val got = countComparisons(methodNode.instructions)
+ assert(got == expected, s"expected $expected but got $got comparisons")
+ }
+
+ def countComparisons(insnList: InsnList): Int = {
+ def isComparison(node: asm.tree.AbstractInsnNode): Boolean =
+ (comparisons contains node.getOpcode)
+ insnList.iterator.asScala count isComparison
+ }
+} \ No newline at end of file
diff --git a/test/files/jvm/daemon-actor-termination.scala b/test/files/jvm/daemon-actor-termination.scala
index 6ddfc3139d..40acd8583e 100644
--- a/test/files/jvm/daemon-actor-termination.scala
+++ b/test/files/jvm/daemon-actor-termination.scala
@@ -1,8 +1,10 @@
-import scala.actors.{Actor, DaemonActor}
/* Test that a daemon Actor that hasn't finished does not prevent termination */
+
+@deprecated("Suppress warnings", since="2.11")
object Test {
+ import scala.actors.{Actor, DaemonActor}
class MyDaemon extends DaemonActor {
def act() {
try {
diff --git a/test/files/jvm/deprecation.check b/test/files/jvm/deprecation.check
new file mode 100644
index 0000000000..e263e4909d
--- /dev/null
+++ b/test/files/jvm/deprecation.check
@@ -0,0 +1,3 @@
+warning: there were 5 deprecation warning(s); re-run with -deprecation for details
+Note: deprecation/Use_2.java uses or overrides a deprecated API.
+Note: Recompile with -Xlint:deprecation for details.
diff --git a/test/files/jvm/duration-tck.scala b/test/files/jvm/duration-tck.scala
index b2573448c7..3bc8a2c100 100644
--- a/test/files/jvm/duration-tck.scala
+++ b/test/files/jvm/duration-tck.scala
@@ -6,6 +6,8 @@ import scala.concurrent.duration._
import scala.reflect._
import scala.tools.partest.TestUtil.intercept
+import scala.language.{ postfixOps }
+
object Test extends App {
implicit class Assert(val left: Any) extends AnyVal {
diff --git a/test/files/jvm/future-alarm.scala b/test/files/jvm/future-alarm.scala
index 8ee902b5ea..3e71fa681c 100644
--- a/test/files/jvm/future-alarm.scala
+++ b/test/files/jvm/future-alarm.scala
@@ -1,6 +1,8 @@
-import scala.actors.Futures
+
+@deprecated("Suppress warnings", since="2.11")
object Test {
+ import scala.actors.Futures
def main(args: Array[String]) {
try {
for (i <- 1 to 100000) {
diff --git a/test/files/jvm/future-awaitall-zero.scala b/test/files/jvm/future-awaitall-zero.scala
index cd6ba172cc..56f4bab16f 100644
--- a/test/files/jvm/future-awaitall-zero.scala
+++ b/test/files/jvm/future-awaitall-zero.scala
@@ -1,7 +1,9 @@
-import scala.actors.Futures._
-import scala.actors.Actor._
+
+@deprecated("Suppress warnings", since="2.11")
object Test {
+ import scala.actors.Futures._
+ import scala.actors.Actor._
def main(args: Array[String]) {
try {
val ft1 = future { reactWithin(10000) {
diff --git a/test/files/jvm/future-spec/FutureTests.scala b/test/files/jvm/future-spec/FutureTests.scala
index ddd819c109..7deb4929d4 100644
--- a/test/files/jvm/future-spec/FutureTests.scala
+++ b/test/files/jvm/future-spec/FutureTests.scala
@@ -96,7 +96,7 @@ object FutureTests extends MinimalScalaTest {
val logThrowable: Throwable => Unit = p.trySuccess(_)
val ec: ExecutionContext = ExecutionContext.fromExecutor(null, logThrowable)
- val t = new NotImplementedError("foo")
+ val t = new InterruptedException()
val f = Future(throw t)(ec)
Await.result(p.future, 2.seconds) mustBe t
}
diff --git a/test/files/jvm/future-spec/main.scala b/test/files/jvm/future-spec/main.scala
index 90048ccda0..e000431dda 100644
--- a/test/files/jvm/future-spec/main.scala
+++ b/test/files/jvm/future-spec/main.scala
@@ -17,6 +17,12 @@ object Test {
}
+trait Features {
+ implicit def implicitously = scala.language.implicitConversions
+ implicit def reflectively = scala.language.reflectiveCalls
+ implicit def postulously = scala.language.postfixOps
+}
+
trait Output {
val buffer = new StringBuilder
@@ -27,7 +33,7 @@ trait Output {
}
-trait MinimalScalaTest extends Output {
+trait MinimalScalaTest extends Output with Features {
val throwables = mutable.ArrayBuffer[Throwable]()
@@ -70,7 +76,7 @@ trait MinimalScalaTest extends Output {
throw new Exception("Exception of type %s was not thrown".format(manifest[T]))
} catch {
case t: Throwable =>
- if (manifest[T].erasure != t.getClass) throw t
+ if (manifest[T].runtimeClass != t.getClass) throw t
else t.asInstanceOf[T]
}
}
diff --git a/test/files/jvm/future-termination.scala b/test/files/jvm/future-termination.scala
index f51642cb7a..668b3f74ba 100644
--- a/test/files/jvm/future-termination.scala
+++ b/test/files/jvm/future-termination.scala
@@ -1,8 +1,10 @@
-import scala.actors.Futures
/* Test that unevaluated futures do not prevent program termination */
+
+@deprecated("Suppress warnings", since="2.11")
object Test {
+ import scala.actors.Futures
def main(args: Array[String]) {
try {
val meaningOfLife = Futures.future {
diff --git a/test/files/jvm/interpreter.check b/test/files/jvm/interpreter.check
index 96b57c7742..44930c2932 100644
--- a/test/files/jvm/interpreter.check
+++ b/test/files/jvm/interpreter.check
@@ -357,10 +357,8 @@ defined class Term
scala> def f(e: Exp) = e match { // non-exhaustive warning here
case _:Fact => 3
}
-<console>:18: warning: match is not exhaustive!
-missing combination Exp
-missing combination Term
-
+<console>:18: warning: match may not be exhaustive.
+It would fail on the following inputs: Exp(), Term()
def f(e: Exp) = e match { // non-exhaustive warning here
^
f: (e: Exp)Int
diff --git a/test/files/jvm/interpreter.scala b/test/files/jvm/interpreter.scala
index f45eb034a9..bd1851053f 100644
--- a/test/files/jvm/interpreter.scala
+++ b/test/files/jvm/interpreter.scala
@@ -2,7 +2,7 @@ import scala.tools.nsc._
import scala.tools.partest.ReplTest
object Test extends ReplTest {
- override def extraSettings = "-deprecation -Xoldpatmat"
+ override def extraSettings = "-deprecation"
def code = <code>
// basics
3+4
diff --git a/test/files/jvm/manifests-new.scala b/test/files/jvm/manifests-new.scala
index f730be67bb..3937fdec69 100644
--- a/test/files/jvm/manifests-new.scala
+++ b/test/files/jvm/manifests-new.scala
@@ -56,7 +56,7 @@ object Test1 extends TestUtil {
}
object Test2 {
- import scala.util.Marshal._
+ import Marshal._
println("()="+load[Unit](dump(())))
println("true="+load[Boolean](dump(true)))
println("a="+load[Char](dump('a')))
@@ -88,6 +88,38 @@ object Test2 {
println()
}
+object Marshal {
+ import java.io._
+ import scala.reflect.ClassTag
+
+ def dump[A](o: A)(implicit t: ClassTag[A]): Array[Byte] = {
+ val ba = new ByteArrayOutputStream(512)
+ val out = new ObjectOutputStream(ba)
+ out.writeObject(t)
+ out.writeObject(o)
+ out.close()
+ ba.toByteArray()
+ }
+
+ @throws(classOf[IOException])
+ @throws(classOf[ClassCastException])
+ @throws(classOf[ClassNotFoundException])
+ def load[A](buffer: Array[Byte])(implicit expected: ClassTag[A]): A = {
+ val in = new ObjectInputStream(new ByteArrayInputStream(buffer))
+ val found = in.readObject.asInstanceOf[ClassTag[_]]
+ try {
+ found.runtimeClass.asSubclass(expected.runtimeClass)
+ in.readObject.asInstanceOf[A]
+ } catch {
+ case _: ClassCastException =>
+ in.close()
+ throw new ClassCastException("type mismatch;"+
+ "\n found : "+found+
+ "\n required: "+expected)
+ }
+ }
+}
+
trait TestUtil {
import java.io._
def write[A](o: A): Array[Byte] = {
diff --git a/test/files/jvm/manifests-old.scala b/test/files/jvm/manifests-old.scala
index 241966fd9d..bb1928f094 100644
--- a/test/files/jvm/manifests-old.scala
+++ b/test/files/jvm/manifests-old.scala
@@ -55,7 +55,7 @@ object Test1 extends TestUtil {
}
object Test2 {
- import scala.util.Marshal._
+ import Marshal._
println("()="+load[Unit](dump(())))
println("true="+load[Boolean](dump(true)))
println("a="+load[Char](dump('a')))
@@ -87,6 +87,38 @@ object Test2 {
println()
}
+object Marshal {
+ import java.io._
+ import scala.reflect.ClassTag
+
+ def dump[A](o: A)(implicit t: ClassTag[A]): Array[Byte] = {
+ val ba = new ByteArrayOutputStream(512)
+ val out = new ObjectOutputStream(ba)
+ out.writeObject(t)
+ out.writeObject(o)
+ out.close()
+ ba.toByteArray()
+ }
+
+ @throws(classOf[IOException])
+ @throws(classOf[ClassCastException])
+ @throws(classOf[ClassNotFoundException])
+ def load[A](buffer: Array[Byte])(implicit expected: ClassTag[A]): A = {
+ val in = new ObjectInputStream(new ByteArrayInputStream(buffer))
+ val found = in.readObject.asInstanceOf[ClassTag[_]]
+ try {
+ found.runtimeClass.asSubclass(expected.runtimeClass)
+ in.readObject.asInstanceOf[A]
+ } catch {
+ case _: ClassCastException =>
+ in.close()
+ throw new ClassCastException("type mismatch;"+
+ "\n found : "+found+
+ "\n required: "+expected)
+ }
+ }
+}
+
trait TestUtil {
import java.io._
def write[A](o: A): Array[Byte] = {
diff --git a/test/files/jvm/named-args-in-order.check b/test/files/jvm/named-args-in-order.check
new file mode 100644
index 0000000000..29a3ba55d3
--- /dev/null
+++ b/test/files/jvm/named-args-in-order.check
@@ -0,0 +1,3 @@
+bytecode identical
+bytecode identical
+bytecode identical
diff --git a/test/files/jvm/named-args-in-order/SameBytecode.scala b/test/files/jvm/named-args-in-order/SameBytecode.scala
new file mode 100644
index 0000000000..c00641777e
--- /dev/null
+++ b/test/files/jvm/named-args-in-order/SameBytecode.scala
@@ -0,0 +1,9 @@
+class SameBytecode {
+ def foo(a: Int, b: String) = 0
+ def foo(a: Int, b: Any) = 0
+
+ def a = foo(0, "")
+ def b = foo(a = 0, "")
+ def c = foo(0, b = "")
+ def d = foo(a = 0, b = "")
+} \ No newline at end of file
diff --git a/test/files/jvm/named-args-in-order/Test.scala b/test/files/jvm/named-args-in-order/Test.scala
new file mode 100644
index 0000000000..36b9cbc1d1
--- /dev/null
+++ b/test/files/jvm/named-args-in-order/Test.scala
@@ -0,0 +1,10 @@
+import scala.tools.partest.BytecodeTest
+
+object Test extends BytecodeTest {
+ def show: Unit = {
+ val classNode = loadClassNode("SameBytecode")
+ def sameAsA(meth: String) =
+ sameBytecode(getMethod(classNode, "a"), getMethod(classNode, meth))
+ Seq("b", "c", "d").foreach(sameAsA)
+ }
+}
diff --git a/test/files/jvm/non-fatal-tests.scala b/test/files/jvm/non-fatal-tests.scala
index 471a9d227a..22c7cba51f 100644
--- a/test/files/jvm/non-fatal-tests.scala
+++ b/test/files/jvm/non-fatal-tests.scala
@@ -7,7 +7,8 @@ trait NonFatalTests {
Seq(new StackOverflowError,
new RuntimeException,
new Exception,
- new Throwable)
+ new Throwable,
+ new NotImplementedError)
//Fatals
val fatals: Seq[Throwable] =
@@ -15,8 +16,7 @@ trait NonFatalTests {
new OutOfMemoryError,
new LinkageError,
new VirtualMachineError {},
- new Throwable with scala.util.control.ControlThrowable,
- new NotImplementedError)
+ new Throwable with scala.util.control.ControlThrowable)
def testFatalsUsingApply(): Unit = {
fatals foreach { t => assert(NonFatal(t) == false) }
diff --git a/test/files/jvm/nooptimise/Foo_1.flags b/test/files/jvm/nooptimise/Foo_1.flags
new file mode 100644
index 0000000000..9686c20775
--- /dev/null
+++ b/test/files/jvm/nooptimise/Foo_1.flags
@@ -0,0 +1 @@
+-optimise -Ynooptimise \ No newline at end of file
diff --git a/test/files/jvm/nooptimise/Foo_1.scala b/test/files/jvm/nooptimise/Foo_1.scala
new file mode 100644
index 0000000000..c6f1b06c8e
--- /dev/null
+++ b/test/files/jvm/nooptimise/Foo_1.scala
@@ -0,0 +1,8 @@
+class Foo_1 {
+ def foo() {
+ // optimization will remove this magic 3 from appearing in the source
+ // so -Ynooptimize should prevent that
+ val x = 3
+
+ }
+}
diff --git a/test/files/jvm/nooptimise/Test.scala b/test/files/jvm/nooptimise/Test.scala
new file mode 100644
index 0000000000..ec8daa6e16
--- /dev/null
+++ b/test/files/jvm/nooptimise/Test.scala
@@ -0,0 +1,23 @@
+import scala.tools.partest.BytecodeTest
+import scala.tools.asm
+import asm.tree.InsnList
+import scala.collection.JavaConverters._
+
+object Test extends BytecodeTest {
+ def show: Unit = {
+ val classNode = loadClassNode("Foo_1")
+ val methodNode = getMethod(classNode, "foo")
+ // if optimization didn't run then
+ // there should be some useless instructions
+ // with the magic constant 3
+ val expected = 1
+ val got = countMagicThrees(methodNode.instructions)
+ assert(got == expected, s"expected $expected but got $got magic threes")
+ }
+
+ def countMagicThrees(insnList: InsnList): Int = {
+ def isMagicThree(node: asm.tree.AbstractInsnNode): Boolean =
+ (node.getOpcode == asm.Opcodes.ICONST_3)
+ insnList.iterator.asScala.count(isMagicThree)
+ }
+}
diff --git a/test/files/jvm/reactor-exceptionOnSend.scala b/test/files/jvm/reactor-exceptionOnSend.scala
index 3d9a042131..6d79fc9d13 100644
--- a/test/files/jvm/reactor-exceptionOnSend.scala
+++ b/test/files/jvm/reactor-exceptionOnSend.scala
@@ -1,3 +1,7 @@
+
+
+@deprecated("Suppress warnings", since="2.11")
+object Test {
import scala.actors.Reactor
import scala.actors.Actor._
@@ -48,7 +52,6 @@ object B extends Reactor[Any] {
}
}
-object Test {
def main(args: Array[String]) {
B.start()
}
diff --git a/test/files/jvm/reactor-producer-consumer.scala b/test/files/jvm/reactor-producer-consumer.scala
index 8a6b17c3ad..ec34febe01 100644
--- a/test/files/jvm/reactor-producer-consumer.scala
+++ b/test/files/jvm/reactor-producer-consumer.scala
@@ -1,6 +1,8 @@
-import scala.actors.Reactor
+
+@deprecated("Suppress warnings", since="2.11")
object Test {
+ import scala.actors.Reactor
case class Stop()
case class Get(from: Reactor[Any])
case class Put(x: Int)
diff --git a/test/files/jvm/reactor.scala b/test/files/jvm/reactor.scala
index dbc9a6bdda..91ded27f07 100644
--- a/test/files/jvm/reactor.scala
+++ b/test/files/jvm/reactor.scala
@@ -1,3 +1,11 @@
+/**
+ * Ping pong example for Reactor.
+ *
+ * @author Philipp Haller
+ */
+
+@deprecated("Suppress warnings", since="2.11")
+object Test {
import scala.actors.Reactor
@@ -5,19 +13,12 @@ case class Ping(from: Reactor[Any])
case object Pong
case object Stop
-/**
- * Ping pong example for Reactor.
- *
- * @author Philipp Haller
- */
-object Test {
def main(args: Array[String]) {
val pong = new PongActor
val ping = new PingActor(100000, pong)
ping.start
pong.start
}
-}
class PingActor(count: Int, pong: Reactor[Any]) extends Reactor[Any] {
def act() {
@@ -68,3 +69,4 @@ class PongActor extends Reactor[Any] {
}
}
}
+}
diff --git a/test/files/jvm/replyablereactor.scala b/test/files/jvm/replyablereactor.scala
index e1fabc98da..4c4e13d9ab 100644
--- a/test/files/jvm/replyablereactor.scala
+++ b/test/files/jvm/replyablereactor.scala
@@ -1,3 +1,7 @@
+
+
+@deprecated("Suppress warnings", since="2.11")
+object Test {
import scala.actors.ReplyReactor
class MyActor extends ReplyReactor {
@@ -18,7 +22,6 @@ class MyActor extends ReplyReactor {
}
}
-object Test {
def main(args: Array[String]) {
val a = new MyActor
a.start()
diff --git a/test/files/jvm/replyablereactor2.scala b/test/files/jvm/replyablereactor2.scala
index da9e0e269e..21f33cce56 100644
--- a/test/files/jvm/replyablereactor2.scala
+++ b/test/files/jvm/replyablereactor2.scala
@@ -1,3 +1,7 @@
+
+
+@deprecated("Suppress warnings", since="2.11")
+object Test {
import scala.actors._
import scala.actors.Actor._
@@ -19,7 +23,6 @@ class MyActor extends ReplyReactor {
}
}
-object Test {
def main(args: Array[String]) {
val a = new MyActor
a.start()
diff --git a/test/files/jvm/replyablereactor3.scala b/test/files/jvm/replyablereactor3.scala
index 2c26b8a176..5810ed053f 100644
--- a/test/files/jvm/replyablereactor3.scala
+++ b/test/files/jvm/replyablereactor3.scala
@@ -1,3 +1,7 @@
+
+
+@deprecated("Suppress warnings", since="2.11")
+object Test {
import scala.actors._
import scala.actors.Actor._
@@ -19,7 +23,6 @@ class MyActor extends ReplyReactor {
}
}
-object Test {
def main(args: Array[String]) {
val a = new MyActor
a.start()
diff --git a/test/files/jvm/replyablereactor4.scala b/test/files/jvm/replyablereactor4.scala
index 8776cf63f0..95d63684dd 100644
--- a/test/files/jvm/replyablereactor4.scala
+++ b/test/files/jvm/replyablereactor4.scala
@@ -1,3 +1,7 @@
+
+
+@deprecated("Suppress warnings", since="2.11")
+object Test {
import scala.actors._
import scala.actors.Actor._
@@ -19,7 +23,6 @@ class MyActor extends ReplyReactor {
}
}
-object Test {
def main(args: Array[String]) {
val a = new MyActor
a.start()
diff --git a/test/files/jvm/replyreactor-react-sender.scala b/test/files/jvm/replyreactor-react-sender.scala
index c9884295f6..fdcea09035 100644
--- a/test/files/jvm/replyreactor-react-sender.scala
+++ b/test/files/jvm/replyreactor-react-sender.scala
@@ -1,7 +1,9 @@
-import scala.actors.ReplyReactor
-import scala.actors.Actor._
+
+@deprecated("Suppress warnings", since="2.11")
object Test {
+ import scala.actors.ReplyReactor
+ import scala.actors.Actor._
val NUM = 2000
diff --git a/test/files/jvm/replyreactor.scala b/test/files/jvm/replyreactor.scala
index 0cecf29ec7..7512fb0eb2 100644
--- a/test/files/jvm/replyreactor.scala
+++ b/test/files/jvm/replyreactor.scala
@@ -1,6 +1,8 @@
-import scala.actors.ReplyReactor
+
+@deprecated("Suppress warnings", since="2.11")
object Test {
+ import scala.actors.ReplyReactor
def main(args: Array[String]) {
val a = new ReplyReactor {
def act() {
diff --git a/test/files/jvm/scheduler-adapter.scala b/test/files/jvm/scheduler-adapter.scala
index d6a8a446a0..1c9cfe7019 100644
--- a/test/files/jvm/scheduler-adapter.scala
+++ b/test/files/jvm/scheduler-adapter.scala
@@ -1,3 +1,7 @@
+
+
+@deprecated("Suppress warnings", since="2.11")
+object Test {
import scala.actors.{Actor, SchedulerAdapter}
trait AdaptedActor extends Actor {
@@ -36,7 +40,6 @@ object Two extends AdaptedActor {
}
}
-object Test {
val adapted =
new SchedulerAdapter {
def execute(block: => Unit) {
diff --git a/test/files/jvm/serialization.scala b/test/files/jvm/serialization.scala
index 34b64938b4..a64b7115fa 100644
--- a/test/files/jvm/serialization.scala
+++ b/test/files/jvm/serialization.scala
@@ -281,6 +281,7 @@ object Test2_immutable {
//############################################################################
// Test classes in package "scala.collection.mutable"
+@deprecated("Suppress warnings", since="2.11")
object Test3_mutable {
import scala.reflect.ClassManifest
import scala.collection.mutable.{
@@ -593,6 +594,7 @@ object Test8 {
//############################################################################
// Test code
+@deprecated("Suppress warnings", since="2.11")
object Test {
def main(args: Array[String]) {
Test1_scala
@@ -604,6 +606,7 @@ object Test {
Test7
Test8
Test9_parallel
+ Test10_util
}
}
@@ -669,3 +672,17 @@ object Test9_parallel {
throw e
}
}
+
+//############################################################################
+// Test classes in package scala.util
+
+object Test10_util {
+ import scala.util.Random
+ def rep[A](n: Int)(f: => A) { if (n > 0) { f; rep(n-1)(f) } }
+
+ {
+ val random = new Random(345)
+ val random2: Random = read(write(random))
+ rep(5) { assert(random.nextInt == random2.nextInt) }
+ }
+}
diff --git a/test/files/jvm/stringbuilder.scala b/test/files/jvm/stringbuilder.scala
index 54951d657b..1fbf61aeab 100644
--- a/test/files/jvm/stringbuilder.scala
+++ b/test/files/jvm/stringbuilder.scala
@@ -2,6 +2,7 @@
*
* @author Stephane Micheloud
*/
+import scala.language.{ postfixOps }
object Test {
def main(args: Array[String]) {
Test1.run() //ctor, reverse
diff --git a/test/files/jvm/t1143-2/t1143-2.scala b/test/files/jvm/t1143-2/t1143-2.scala
index 44b1febd8b..13ab13b48c 100644
--- a/test/files/jvm/t1143-2/t1143-2.scala
+++ b/test/files/jvm/t1143-2/t1143-2.scala
@@ -16,43 +16,39 @@ object Serialize {
}
}
-@serializable
@SerialVersionUID(1L)
-class VarModel[T]( getter: => T, setter: T => Unit )
-{
+class VarModel[T](getter: => T, setter: T => Unit) extends Serializable {
Serialize.write(getter)
Serialize.write(setter)
- def this( getter: => T ) = this( getter, null )
+ def this(getter: => T) = this(getter, null)
def getObject: AnyRef = getter.asInstanceOf[AnyRef]
- def setObject( v: AnyRef ) = {
- if( setter==null )
- throw new RuntimeException( "Tried to set readonly model!")
- setter( v.asInstanceOf[T] )
+ def setObject(v: AnyRef) = {
+ if(setter==null)
+ throw new RuntimeException("Tried to set readonly model!")
+ setter(v.asInstanceOf[T])
}
def detach = ()
}
-@serializable
@SerialVersionUID(1L)
-class Printer( p: VarModel[String] ) {
- def print = println( p.getObject );
+class Printer(p: VarModel[String]) extends Serializable {
+ def print = println(p.getObject)
}
class Component extends Marker { }
class Form extends Component { }
-@serializable
@SerialVersionUID(1L)
-class Main {
+class Main extends Serializable {
var pass = "pass"
- def main(args : Array[String]) : Unit = {
+ def main(args: Array[String]): Unit = {
val f = new Form {
- val p = new Printer( new VarModel( pass, s => pass = s ) );
+ val p = new Printer(new VarModel(pass, s => pass = s))
p.print
}
()
diff --git a/test/files/jvm/t1143.scala b/test/files/jvm/t1143.scala
index 7dd374f432..eb03c7224e 100644
--- a/test/files/jvm/t1143.scala
+++ b/test/files/jvm/t1143.scala
@@ -16,9 +16,8 @@ object Serialize {
}
}
-@serializable
@SerialVersionUID(1L)
-class VarModel[T](getter: => T, setter: T => Unit) {
+class VarModel[T](getter: => T, setter: T => Unit) extends Serializable {
Serialize.write(getter)
Serialize.write(setter)
@@ -35,23 +34,20 @@ class VarModel[T](getter: => T, setter: T => Unit) {
def detach = ()
}
-@serializable
@SerialVersionUID(1L)
-class Printer(p: VarModel[String]) {
+class Printer(p: VarModel[String]) extends Serializable {
def print = println(p.getObject)
}
-@serializable
@SerialVersionUID(1L)
-class Component {
+class Component extends Serializable {
}
class Form extends Component {
}
-@serializable
@SerialVersionUID(1L)
-class Main {
+class Main extends Serializable {
var pass = "pass"
def main(args: Array[String]) {
val f = new Form {
diff --git a/test/files/jvm/t1342/SI.scala b/test/files/jvm/t1342/SI.scala
index 8e3b753210..7c37d4bcd7 100644
--- a/test/files/jvm/t1342/SI.scala
+++ b/test/files/jvm/t1342/SI.scala
@@ -4,7 +4,7 @@ class SI extends JI {
}
}
-object Test extends Application {
+object Test extends App {
val x: JI = new SI
x.varArgsMethod("one", "two")
}
diff --git a/test/files/jvm/t1449.scala b/test/files/jvm/t1449.scala
index 3822cf7dd5..7917d6f6d5 100644
--- a/test/files/jvm/t1449.scala
+++ b/test/files/jvm/t1449.scala
@@ -1,7 +1,10 @@
-import scala.actors.Actor._
-import scala.actors.Future
-import scala.actors.Futures._
+
+
+@deprecated("Suppress warnings", since="2.11")
object Test {
+ import scala.actors.Actor._
+ import scala.actors.Future
+ import scala.actors.Futures._
def main(args: Array[String]) {
val a = actor {
try {
diff --git a/test/files/jvm/t1600.scala b/test/files/jvm/t1600.scala
index 7e23687425..69179c1ba4 100644
--- a/test/files/jvm/t1600.scala
+++ b/test/files/jvm/t1600.scala
@@ -69,8 +69,7 @@ object Test {
var hashCodeModifier = 0
}
- @serializable
- class Foo {
+ class Foo extends Serializable {
override def hashCode = System.identityHashCode(this) + Foo.hashCodeModifier
}
}
diff --git a/test/files/jvm/t1948.scala b/test/files/jvm/t1948.scala
index 084c956398..95777b8037 100644
--- a/test/files/jvm/t1948.scala
+++ b/test/files/jvm/t1948.scala
@@ -1,7 +1,9 @@
-import scala.actors._
-import scala.actors.Actor._
+
+@deprecated("Suppress warnings", since="2.11")
object Test {
+ import scala.actors._
+ import scala.actors.Actor._
def main (args: Array[String]) {
val actors = (1 to 1000).toList map { x => actor {
diff --git a/test/files/jvm/ticket2163/ticket2163.java b/test/files/jvm/t2163/t2163.java
index b6511d241c..83bd37d212 100644
--- a/test/files/jvm/ticket2163/ticket2163.java
+++ b/test/files/jvm/t2163/t2163.java
@@ -1,9 +1,9 @@
import java.util.*;
-public class ticket2163 {
+public class t2163 {
public void test() {
List<Integer> array = new ArrayList<Integer>();
- Ticket2163Scala<List> foo = new Ticket2163Scala<List>(array);
+ T2163Scala<List> foo = new T2163Scala<List>(array);
foo.bar(array);
}
}
diff --git a/test/files/jvm/t2163/t2163.scala b/test/files/jvm/t2163/t2163.scala
new file mode 100644
index 0000000000..fdf19c4e25
--- /dev/null
+++ b/test/files/jvm/t2163/t2163.scala
@@ -0,0 +1,10 @@
+
+import scala.language.{ higherKinds }
+
+class T2163Scala[CC[X]](x: CC[Int]) {
+ def bar[DD[X]](meh: DD[Int]): CC[Int] = x
+}
+
+object Test extends App {
+ new t2163().test()
+}
diff --git a/test/files/jvm/t2359.scala b/test/files/jvm/t2359.scala
index 69c69d7b3b..76b78d44f7 100644
--- a/test/files/jvm/t2359.scala
+++ b/test/files/jvm/t2359.scala
@@ -1,6 +1,8 @@
-import scala.actors.Futures._
+
+@deprecated("Suppress warnings", since="2.11")
object Test {
+ import scala.actors.Futures._
def main(args: Array[String]) {
val x = future {
try {
diff --git a/test/files/jvm/t2470.cmds b/test/files/jvm/t2470.cmds
deleted file mode 100644
index b4ef0f4aeb..0000000000
--- a/test/files/jvm/t2470.cmds
+++ /dev/null
@@ -1,3 +0,0 @@
-javac Action.java Task.java
-scalac Test_1.scala
-scalac Read_Classfile_2.scala
diff --git a/test/files/jvm/t2530.scala b/test/files/jvm/t2530.scala
index c2925a92d1..b41661e623 100644
--- a/test/files/jvm/t2530.scala
+++ b/test/files/jvm/t2530.scala
@@ -1,6 +1,8 @@
-import scala.actors.{Future, Futures}
+
+@deprecated("Suppress warnings", since="2.11")
object Test {
+ import scala.actors.{Future, Futures}
def main(args:Array[String]) : Unit = {
//scala.actors.Debug.level = 3
@@ -29,7 +31,6 @@ object Test {
}
println("Test done with no deadlock. Try again, it will not occur...")
}
-}
case class Matrix(numRows: Int, numCols: Int, values: Array[Double]) {
@@ -94,3 +95,4 @@ case class Matrix(numRows: Int, numCols: Int, values: Array[Double]) {
}
}
+}
diff --git a/test/files/jvm/t2570/Test.scala b/test/files/jvm/t2570/Test.scala
index 7944aedae6..f1cba53546 100644
--- a/test/files/jvm/t2570/Test.scala
+++ b/test/files/jvm/t2570/Test.scala
@@ -1,3 +1,3 @@
class Test2 extends Test1[Test3[Test4]]
class Test4
-object Test extends Application {} \ No newline at end of file
+object Test extends App {} \ No newline at end of file
diff --git a/test/files/jvm/t3003.cmds b/test/files/jvm/t3003.cmds
deleted file mode 100644
index c00396627c..0000000000
--- a/test/files/jvm/t3003.cmds
+++ /dev/null
@@ -1,2 +0,0 @@
-javac Annot.java
-scalac Test_1.scala
diff --git a/test/files/jvm/t3102.scala b/test/files/jvm/t3102.scala
index fbcf2e60e6..d0e0704859 100644
--- a/test/files/jvm/t3102.scala
+++ b/test/files/jvm/t3102.scala
@@ -1,7 +1,10 @@
-import scala.actors.{Actor, TIMEOUT}
-import Actor._
+
+@deprecated("Suppress warnings", since="2.11")
object Test {
+ import scala.actors.{Actor, TIMEOUT}
+ import Actor._
+
def main(args: Array[String]) {
val a = actor {
try {
diff --git a/test/files/jvm/t3356.scala b/test/files/jvm/t3356.scala
index a9e83fe503..53bfd737cd 100644
--- a/test/files/jvm/t3356.scala
+++ b/test/files/jvm/t3356.scala
@@ -1,3 +1,7 @@
+
+
+@deprecated("Suppress warnings", since="2.11")
+object Test {
import scala.actors.{Actor, Exit, !, UncaughtException}
import Actor._
@@ -10,7 +14,6 @@ case class ImageInfo(text: String) {
case class ImageData(text: String)
case class Download(info: ImageInfo)
-object Test {
def scanForImageInfo(url: String): List[ImageInfo] =
List(ImageInfo("A"), ImageInfo("B"))
diff --git a/test/files/jvm/t3365.scala b/test/files/jvm/t3365.scala
index b94e804e63..8321428093 100644
--- a/test/files/jvm/t3365.scala
+++ b/test/files/jvm/t3365.scala
@@ -1,3 +1,7 @@
+
+
+@deprecated("Suppress warnings", since="2.11")
+object Test {
import scala.actors.{ReplyReactor, Channel, Actor, Future}
case class ChannelMsg(chan: Channel[Any])
@@ -27,7 +31,6 @@ class MyActor extends Actor {
}
}
-object Test {
def main(args: Array[String]) {
val a = new MyActor
a.start()
diff --git a/test/files/jvm/t3407.scala b/test/files/jvm/t3407.scala
index 6c2ce85c71..757fa3a438 100644
--- a/test/files/jvm/t3407.scala
+++ b/test/files/jvm/t3407.scala
@@ -1,6 +1,8 @@
-import scala.actors._, scala.actors.Actor._
+
+@deprecated("Suppress warnings", since="2.11")
object Test {
+ import scala.actors._, scala.actors.Actor._
def main(args: Array[String]) {
for (i <- 1 to 10) {
diff --git a/test/files/jvm/t3412-channel.scala b/test/files/jvm/t3412-channel.scala
index fcc439b488..af319d2303 100644
--- a/test/files/jvm/t3412-channel.scala
+++ b/test/files/jvm/t3412-channel.scala
@@ -1,6 +1,8 @@
-import scala.actors._, scala.actors.Actor._, scala.actors.Futures._
+
+@deprecated("Suppress warnings", since="2.11")
object Test {
+ import scala.actors._, scala.actors.Actor._, scala.actors.Futures._
def main(args: Array[String]) {
diff --git a/test/files/jvm/t3412.scala b/test/files/jvm/t3412.scala
index ced15ab5dc..fde6c04cb7 100644
--- a/test/files/jvm/t3412.scala
+++ b/test/files/jvm/t3412.scala
@@ -1,6 +1,8 @@
-import scala.actors._, scala.actors.Actor._, scala.actors.Futures._
+
+@deprecated("Suppress warnings", since="2.11")
object Test {
+ import scala.actors._, scala.actors.Actor._, scala.actors.Futures._
def main(args: Array[String]) {
diff --git a/test/files/jvm/t3415/HelloWorld.scala b/test/files/jvm/t3415/HelloWorld.scala
index 53bf55e444..5ef012390e 100644
--- a/test/files/jvm/t3415/HelloWorld.scala
+++ b/test/files/jvm/t3415/HelloWorld.scala
@@ -1,4 +1,4 @@
-object Test extends Application {
+object Test extends App {
@Hello
def foo() { }
}
diff --git a/test/files/jvm/t3470.scala b/test/files/jvm/t3470.scala
index 5e4242cdd7..bcb1d4f8de 100644
--- a/test/files/jvm/t3470.scala
+++ b/test/files/jvm/t3470.scala
@@ -1,6 +1,8 @@
-import scala.actors._
+
+@deprecated("Suppress warnings", since="2.11")
object Test {
+ import scala.actors._
def expectActorState(a: Reactor[T] forSome { type T }, s: Actor.State.Value) {
var done = false
diff --git a/test/files/jvm/t3838.scala b/test/files/jvm/t3838.scala
index ba8f15fc31..a1a71d1049 100644
--- a/test/files/jvm/t3838.scala
+++ b/test/files/jvm/t3838.scala
@@ -1,6 +1,8 @@
-import scala.actors.Actor._
+
+@deprecated("Suppress warnings", since="2.11")
object Test {
+ import scala.actors.Actor._
def main(args: Array[String]) {
actor {
try {
diff --git a/test/files/jvm/ticket4283/AbstractFoo.java b/test/files/jvm/t4283/AbstractFoo.java
index 74f3827fe3..74f3827fe3 100644
--- a/test/files/jvm/ticket4283/AbstractFoo.java
+++ b/test/files/jvm/t4283/AbstractFoo.java
diff --git a/test/files/jvm/ticket4283/ScalaBipp.scala b/test/files/jvm/t4283/ScalaBipp.scala
index 36dea9f4de..36dea9f4de 100644
--- a/test/files/jvm/ticket4283/ScalaBipp.scala
+++ b/test/files/jvm/t4283/ScalaBipp.scala
diff --git a/test/files/jvm/ticket4283/Test.scala b/test/files/jvm/t4283/Test.scala
index 9bbfaab928..9bbfaab928 100644
--- a/test/files/jvm/ticket4283/Test.scala
+++ b/test/files/jvm/t4283/Test.scala
diff --git a/test/files/jvm/t560bis.scala b/test/files/jvm/t560bis.scala
index b04303c8a0..21eb8dde28 100644
--- a/test/files/jvm/t560bis.scala
+++ b/test/files/jvm/t560bis.scala
@@ -6,7 +6,7 @@ import scala.xml._;
case _ => Console.println("bah")
}
def foo(args: List[String]) =
- Elem(null,"bla",Null, TopScope, (args map {x => Text(x)}):_*) match {
+ Elem(null,"bla",Null, TopScope, minimizeEmpty = true, (args map {x => Text(x)}):_*) match {
case Elem(_,_,_,_,Text("1"),_*) =>
Console.println("cool!")
case _ =>
diff --git a/test/files/jvm/t6941/Analyzed_1.flags b/test/files/jvm/t6941/Analyzed_1.flags
new file mode 100644
index 0000000000..ad51758c39
--- /dev/null
+++ b/test/files/jvm/t6941/Analyzed_1.flags
@@ -0,0 +1 @@
+-nowarn
diff --git a/test/files/jvm/t7006.check b/test/files/jvm/t7006.check
new file mode 100644
index 0000000000..7c99eba30c
--- /dev/null
+++ b/test/files/jvm/t7006.check
@@ -0,0 +1,28 @@
+[running phase parser on Foo_1.scala]
+[running phase namer on Foo_1.scala]
+[running phase packageobjects on Foo_1.scala]
+[running phase typer on Foo_1.scala]
+[running phase patmat on Foo_1.scala]
+[running phase superaccessors on Foo_1.scala]
+[running phase extmethods on Foo_1.scala]
+[running phase pickler on Foo_1.scala]
+[running phase refchecks on Foo_1.scala]
+[running phase uncurry on Foo_1.scala]
+[running phase tailcalls on Foo_1.scala]
+[running phase specialize on Foo_1.scala]
+[running phase explicitouter on Foo_1.scala]
+[running phase erasure on Foo_1.scala]
+[running phase posterasure on Foo_1.scala]
+[running phase lazyvals on Foo_1.scala]
+[running phase lambdalift on Foo_1.scala]
+[running phase constructors on Foo_1.scala]
+[running phase flatten on Foo_1.scala]
+[running phase mixin on Foo_1.scala]
+[running phase cleanup on Foo_1.scala]
+[running phase icode on Foo_1.scala]
+[running phase inliner on Foo_1.scala]
+[running phase inlinehandlers on Foo_1.scala]
+[running phase closelim on Foo_1.scala]
+[running phase constopt on Foo_1.scala]
+[running phase dce on Foo_1.scala]
+[running phase jvm on icode]
diff --git a/test/files/jvm/t7006/Foo_1.flags b/test/files/jvm/t7006/Foo_1.flags
new file mode 100644
index 0000000000..37b2116413
--- /dev/null
+++ b/test/files/jvm/t7006/Foo_1.flags
@@ -0,0 +1 @@
+-optimise -Ydebug -Xfatal-warnings
diff --git a/test/files/jvm/t7006/Foo_1.scala b/test/files/jvm/t7006/Foo_1.scala
new file mode 100644
index 0000000000..995619ce6b
--- /dev/null
+++ b/test/files/jvm/t7006/Foo_1.scala
@@ -0,0 +1,10 @@
+class Foo_1 {
+ def foo {
+ try {
+ val x = 3 // this will be optimized away, leaving a useless jump only block
+ } finally {
+ print("hello")
+ }
+ while(true){} // ensure infinite loop doesn't break the algoirthm
+ }
+}
diff --git a/test/files/jvm/t7006/Test.scala b/test/files/jvm/t7006/Test.scala
new file mode 100644
index 0000000000..065a23510e
--- /dev/null
+++ b/test/files/jvm/t7006/Test.scala
@@ -0,0 +1,19 @@
+import scala.tools.partest.BytecodeTest
+import scala.tools.asm
+import asm.tree.InsnList
+import scala.collection.JavaConverters._
+
+object Test extends BytecodeTest {
+ def show: Unit = {
+ val classNode = loadClassNode("Foo_1")
+ val methodNode = getMethod(classNode, "foo")
+ assert(count(methodNode.instructions, asm.Opcodes.NOP) == 0)
+ assert(count(methodNode.instructions, asm.Opcodes.GOTO) == 1)
+ }
+
+ def count(insnList: InsnList, opcode: Int): Int = {
+ def isNop(node: asm.tree.AbstractInsnNode): Boolean =
+ (node.getOpcode == opcode)
+ insnList.iterator.asScala.count(isNop)
+ }
+}
diff --git a/test/files/jvm/t7146.scala b/test/files/jvm/t7146.scala
index 2bd03d6d02..aaa3dc7ca4 100644
--- a/test/files/jvm/t7146.scala
+++ b/test/files/jvm/t7146.scala
@@ -1,3 +1,5 @@
+
+import scala.language.{ reflectiveCalls }
import java.util.concurrent.Executor
import scala.concurrent._
import scala.util.control.NoStackTrace
diff --git a/test/files/jvm/t7181/Foo_1.scala b/test/files/jvm/t7181/Foo_1.scala
new file mode 100644
index 0000000000..f9dfdd4442
--- /dev/null
+++ b/test/files/jvm/t7181/Foo_1.scala
@@ -0,0 +1,26 @@
+class Exception1 extends RuntimeException
+class Exception2 extends RuntimeException
+
+class Foo_1 {
+ def foo(baz: Baz) {
+ try {
+ baz.bar
+ } catch {
+ case _: Exception1 => println("exception 1")
+ case _: Exception2 => println("exception 2")
+ } finally {
+ // this should be the only copy of the magic constant 3
+ // making it easy to detect copies of this finally block
+ println(s"finally ${3}")
+ }
+ println(s"normal flow")
+ }
+}
+
+trait Baz {
+ // does it throw? who knows? This way
+ // I can ensure that no optimization that honors
+ // separate compilation could ever
+ // change the exception handling structure
+ def bar: Unit
+}
diff --git a/test/files/jvm/t7181/Test.scala b/test/files/jvm/t7181/Test.scala
new file mode 100644
index 0000000000..35dba436c1
--- /dev/null
+++ b/test/files/jvm/t7181/Test.scala
@@ -0,0 +1,24 @@
+import scala.tools.partest.BytecodeTest
+import scala.tools.asm
+import asm.tree.InsnList
+import scala.collection.JavaConverters._
+
+object Test extends BytecodeTest {
+ def show: Unit = {
+ val classNode = loadClassNode("Foo_1")
+ val methodNode = getMethod(classNode, "foo")
+ // there should be 2 copies of the finally block, each with the magic constant 3
+ // one for the "normal" exit
+ // one for the uncaught exception exit
+ // prior to this PR there would have been 4 since each exception handler would also get a copy
+ val expected = 2
+ val got = countMagicThrees(methodNode.instructions)
+ assert(got == expected, s"expected $expected but got $got magic threes")
+ }
+
+ def countMagicThrees(insnList: InsnList): Int = {
+ def isMagicThree(node: asm.tree.AbstractInsnNode): Boolean =
+ (node.getOpcode == asm.Opcodes.ICONST_3)
+ insnList.iterator.asScala.count(isMagicThree)
+ }
+}
diff --git a/test/files/jvm/ticket2163/ticket2163.scala b/test/files/jvm/ticket2163/ticket2163.scala
deleted file mode 100644
index d30bfe251b..0000000000
--- a/test/files/jvm/ticket2163/ticket2163.scala
+++ /dev/null
@@ -1,5 +0,0 @@
-class Ticket2163Scala[CC[X]](x: CC[Int]) {
- def bar[DD[X]](meh: DD[Int]): CC[Int] = x
-}
-
-object Test extends Application {}
diff --git a/test/files/jvm/try-type-tests.scala b/test/files/jvm/try-type-tests.scala
index 17811f64c5..e5e53ee737 100644
--- a/test/files/jvm/try-type-tests.scala
+++ b/test/files/jvm/try-type-tests.scala
@@ -49,6 +49,7 @@ trait TryStandard {
n match {
case Success(v) => assert(false)
case Failure(e: NoSuchElementException) => assert(true)
+ case _ => assert(false)
}
}
@@ -141,4 +142,4 @@ object Test
extends App
with TryStandard {
System.exit(0)
-} \ No newline at end of file
+}
diff --git a/test/files/jvm/typerep.scala b/test/files/jvm/typerep.scala
index 3befc7ff3f..47bd16a467 100644
--- a/test/files/jvm/typerep.scala
+++ b/test/files/jvm/typerep.scala
@@ -280,100 +280,74 @@ object TypeRep {
override def toString = "Nothing"
}
- @serializable
case class ClassRep[A](elemRep: TypeRep[A]) extends TypeRep[Class[A]] {
override def toString = "Class[" + elemRep + "]"
}
- @serializable
case class SomeRep[A](elemRep: TypeRep[A]) extends TypeRep[Some[A]] {
override def toString = "Some[" + elemRep + "]"
}
- @serializable
case class NoneRep[A](elemRep: TypeRep[A]) extends TypeRep[Option[A]] {
override def toString = "None[" + elemRep + "]"
}
-
- @serializable
case class ListRep[A](elemRep: TypeRep[A]) extends TypeRep[List[A]] {
override def toString = "List[" + elemRep + "]"
}
-
- @serializable
case class ArrayRep[A](elemRep: TypeRep[A]) extends TypeRep[Array[A]] {
override def toString = "Array[" + elemRep + "]"
}
-
- @serializable
case class Tuple2Rep[A1, A2](_1: TypeRep[A1], _2: TypeRep[A2]) extends TypeRep[(A1, A2)] {
override def toString = "Tuple2[" + _1 + ", " + _2 + "]"
}
- @serializable
case class Tuple3Rep[A1, A2, A3](_1: TypeRep[A1], _2: TypeRep[A2], _3: TypeRep[A3]) extends TypeRep[Tuple3[A1, A2, A3]] {
override def toString = "Tuple3[" + _1 + ", " + _2 + ", " + _3 + "]"
}
- @serializable
case class Tuple4Rep[A1, A2, A3, A4](_1: TypeRep[A1], _2: TypeRep[A2], _3: TypeRep[A3], _4: TypeRep[A4]) extends TypeRep[Tuple4[A1, A2, A3, A4]] {
override def toString = "Tuple4[" + _1 + ", " + _2 + ", " + _3 + ", " + _4 + "]"
}
- @serializable
case class Tuple5Rep[A1, A2, A3, A4, A5](_1: TypeRep[A1], _2: TypeRep[A2], _3: TypeRep[A3], _4: TypeRep[A4], _5: TypeRep[A5]) extends TypeRep[Tuple5[A1, A2, A3, A4, A5]] {
override def toString = "Tuple5[" + _1 + ", " + _2 + ", " + _3 + ", " + _4 + ", " + _5 + "]"
}
- @serializable
case class Tuple6Rep[A1, A2, A3, A4, A5, A6](val _1: TypeRep[A1], val _2: TypeRep[A2], val _3: TypeRep[A3], val _4: TypeRep[A4], val _5: TypeRep[A5], val _6: TypeRep[A6]) extends TypeRep[Tuple6[A1, A2, A3, A4, A5, A6]] {
override def toString = "Tuple6[" + _1 + ", " + _2 + ", " + _3 + ", " + _4 + ", " + _5 + ", " + _6 + "]"
}
- @serializable
case class Tuple7Rep[A1, A2, A3, A4, A5, A6, A7](val _1: TypeRep[A1], val _2: TypeRep[A2], val _3: TypeRep[A3], val _4: TypeRep[A4], val _5: TypeRep[A5], val _6: TypeRep[A6], val _7: TypeRep[A7]) extends TypeRep[Tuple7[A1, A2, A3, A4, A5, A6, A7]] {
override def toString = "Tuple7[" + _1 + ", " + _2 + ", " + _3 + ", " + _4 + ", " + _5 + ", " + _6 + ", " + _7 + "]"
}
- @serializable
case class Tuple8Rep[A1, A2, A3, A4, A5, A6, A7, A8](val _1: TypeRep[A1], val _2: TypeRep[A2], val _3: TypeRep[A3], val _4: TypeRep[A4], val _5: TypeRep[A5], val _6: TypeRep[A6], val _7: TypeRep[A7], val _8: TypeRep[A8]) extends TypeRep[Tuple8[A1, A2, A3, A4, A5, A6, A7, A8]] {
override def toString = "Tuple8[" + _1 + ", " + _2 + ", " + _3 + ", " + _4 + ", " + _5 + ", " + _6 + ", " + _7 + ", " + _8 + "]"
}
- @serializable
case class Tuple9Rep[A1, A2, A3, A4, A5, A6, A7, A8, A9](val _1: TypeRep[A1], val _2: TypeRep[A2], val _3: TypeRep[A3], val _4: TypeRep[A4], val _5: TypeRep[A5], val _6: TypeRep[A6], val _7: TypeRep[A7], val _8: TypeRep[A8], val _9: TypeRep[A9]) extends TypeRep[Tuple9[A1, A2, A3, A4, A5, A6, A7, A8, A9]] {
override def toString = "Tuple9[" + _1 + ", " + _2 + ", " + _3 + ", " + _4 + ", " + _5 + ", " + _6 + ", " + _7 + ", " + _8 + ", " + _9 + "]"
}
- @serializable
case class Function1Rep[A1, B](a1: TypeRep[A1], b: TypeRep[B]) extends TypeRep[Function1[A1, B]] {
override def toString = "Function1[" + a1 + ", " + b + "]"
}
- @serializable
case class Function2Rep[A1, A2, B](a1: TypeRep[A1], a2: TypeRep[A2], b: TypeRep[B]) extends TypeRep[Function2[A1, A2, B]] {
override def toString = "Function2[" + a1 + ", " + a2 + ", " + b + "]"
}
- @serializable
case class Function3Rep[A1, A2, A3, B](a1: TypeRep[A1], a2: TypeRep[A2], a3: TypeRep[A3], b: TypeRep[B]) extends TypeRep[Function3[A1, A2, A3, B]] {
override def toString = "Function3[" + a1 + ", " + a2 + ", " + a3 + ", " + b + "]"
}
- @serializable
case class Function4Rep[A1, A2, A3, A4, B](a1: TypeRep[A1], a2: TypeRep[A2], a3: TypeRep[A3], a4: TypeRep[A4], b: TypeRep[B]) extends TypeRep[Function4[A1, A2, A3, A4, B]] {
override def toString = "Function4[" + a1 + ", " + a2 + ", " + a3 + ", " + a4 + ", " + b + "]"
}
- @serializable
case class Function5Rep[A1, A2, A3, A4, A5, B](a1: TypeRep[A1], a2: TypeRep[A2], a3: TypeRep[A3], a4: TypeRep[A4], a5: TypeRep[A5], b: TypeRep[B]) extends TypeRep[Function5[A1, A2, A3, A4, A5, B]] {
override def toString = "Function5[" + a1 + ", " + a2 + ", " + a3 + ", " + a4 + ", " + a5 + ", " + b + "]"
}
- @serializable
case class Function6Rep[A1, A2, A3, A4, A5, A6, B](a1: TypeRep[A1], a2: TypeRep[A2], a3: TypeRep[A3], a4: TypeRep[A4], a5: TypeRep[A5], a6: TypeRep[A6], b: TypeRep[B]) extends TypeRep[Function6[A1, A2, A3, A4, A5, A6, B]] {
override def toString = "Function6[" + a1 + ", " + a2 + ", " + a3 + ", " + a4 + ", " + a5 + ", " + a6 + ", " + b + "]"
}
- @serializable
case class Function7Rep[A1, A2, A3, A4, A5, A6, A7, B](a1: TypeRep[A1], a2: TypeRep[A2], a3: TypeRep[A3], a4: TypeRep[A4], a5: TypeRep[A5], a6: TypeRep[A6], a7: TypeRep[A7], b: TypeRep[B]) extends TypeRep[Function7[A1, A2, A3, A4, A5, A6, A7, B]] {
override def toString = "Function7[" + a1 + ", " + a2 + ", " + a3 + ", " + a4 + ", " + a5 + ", " + a6 + ", " + a7 + ", " + b + "]"
}
- @serializable
case class Function8Rep[A1, A2, A3, A4, A5, A6, A7, A8, B](a1: TypeRep[A1], a2: TypeRep[A2], a3: TypeRep[A3], a4: TypeRep[A4], a5: TypeRep[A5], a6: TypeRep[A6], a7: TypeRep[A7], a8: TypeRep[A8], b: TypeRep[B]) extends TypeRep[Function8[A1, A2, A3, A4, A5, A6, A7, A8, B]] {
override def toString = "Function8[" + a1 + ", " + a2 + ", " + a3 + ", " + a4 + ", " + a5 + ", " + a6 + ", " + a7 + ", " + a8 + b + "]"
}
- @serializable
case class Function9Rep[A1, A2, A3, A4, A5, A6, A7, A8, A9, B](a1: TypeRep[A1], a2: TypeRep[A2], a3: TypeRep[A3], a4: TypeRep[A4], a5: TypeRep[A5], a6: TypeRep[A6], a7: TypeRep[A7], a8: TypeRep[A8], a9: TypeRep[A9], b: TypeRep[B]) extends TypeRep[Function9[A1, A2, A3, A4, A5, A6, A7, A8, A9, B]] {
override def toString = "Function9[" + a1 + ", " + a2 + ", " + a3 + ", " + a4 + ", " + a5 + ", " + a6 + ", " + a7 + ", " + a8 + ", " + b + "]"
}
/*
- @serializable
case class ObjectRep[A](c: Class) extends TypeRep[A] {
override def toString = c.getName
}
diff --git a/test/files/jvm/unreachable/Foo_1.flags b/test/files/jvm/unreachable/Foo_1.flags
new file mode 100644
index 0000000000..ce6e93b3da
--- /dev/null
+++ b/test/files/jvm/unreachable/Foo_1.flags
@@ -0,0 +1 @@
+-Ynooptimise \ No newline at end of file
diff --git a/test/files/jvm/unreachable/Foo_1.scala b/test/files/jvm/unreachable/Foo_1.scala
new file mode 100644
index 0000000000..c223718097
--- /dev/null
+++ b/test/files/jvm/unreachable/Foo_1.scala
@@ -0,0 +1,112 @@
+import scala.sys.error
+
+class Foo_1 {
+ def unreachableNormalExit: Int = {
+ return 42
+ 0
+ }
+
+ def unreachableIf: Int = {
+ return 42
+ if (util.Random.nextInt % 2 == 0)
+ 0
+ else
+ 1
+ }
+
+ def unreachableIfBranches: Int = {
+ if (util.Random.nextInt % 2 == 0)
+ return 42
+ else
+ return 42
+
+ return 0
+ }
+
+ def unreachableOneLegIf: Int = {
+ if (util.Random.nextInt % 2 == 0)
+ return 42
+
+ return 42
+ }
+
+ def unreachableLeftBranch: Int = {
+ val result = if (util.Random.nextInt % 2 == 0)
+ return 42
+ else
+ 42
+
+ return result
+ }
+
+ def unreachableRightBranch: Int = {
+ val result = if (util.Random.nextInt % 2 == 0)
+ 42
+ else
+ return 42
+
+ return result
+ }
+
+ def unreachableTryCatchFinally: Int = {
+ return 42
+ try {
+ return 0
+ } catch {
+ case x: Throwable => return 1
+ } finally {
+ return 2
+ }
+ return 3
+ }
+
+ def unreachableAfterTry: Int = {
+ try {
+ return 42
+ } catch {
+ case x: Throwable => return 2
+ }
+ return 3
+ }
+
+ def unreachableAfterCatch: Int = {
+ try {
+ error("haha")
+ } catch {
+ case x: Throwable => return 42
+ }
+ return 3
+ }
+
+ def unreachableAfterFinally: Int = {
+ try {
+ return 1
+ } catch {
+ case x: Throwable => return 2
+ } finally {
+ return 42
+ }
+ return 3
+ }
+
+ def unreachableSwitch: Int = {
+ return 42
+ val x = util.Random.nextInt % 2
+ x match {
+ case 0 => return 0
+ case 1 => return 1
+ case _ => error("wtf")
+ }
+ 2
+ }
+
+ def unreachableAfterSwitch: Int = {
+ val x = util.Random.nextInt % 2
+ x match {
+ case 0 => return 42
+ case 1 => return 41 + x
+ case _ => error("wtf")
+ }
+ 2
+ }
+}
diff --git a/test/files/jvm/unreachable/Test.scala b/test/files/jvm/unreachable/Test.scala
new file mode 100644
index 0000000000..3f520eb106
--- /dev/null
+++ b/test/files/jvm/unreachable/Test.scala
@@ -0,0 +1,23 @@
+import scala.tools.partest.BytecodeTest
+import scala.tools.asm
+import asm.tree.InsnList
+import scala.collection.JavaConverters._
+
+object Test extends BytecodeTest {
+ def show: Unit = {
+ val classNode = loadClassNode("Foo_1")
+ // Foo_1 is full of unreachable code which if not elimintated
+ // will result in NOPs as can be confirmed by adding -Ydisable-unreachable-prevention
+ // to Foo_1.flags
+ for (methodNode <- classNode.methods.asScala) {
+ val got = count(methodNode.instructions, asm.Opcodes.NOP)
+ if (got != 0) println(s"Found $got NOP(s) in ${methodNode.name}")
+ }
+ }
+
+ def count(insnList: InsnList, opcode: Int): Int = {
+ def isNop(node: asm.tree.AbstractInsnNode): Boolean =
+ (node.getOpcode == opcode)
+ insnList.iterator.asScala.count(isNop)
+ }
+} \ No newline at end of file
diff --git a/test/files/jvm/value-class-boxing.check b/test/files/jvm/value-class-boxing.check
new file mode 100644
index 0000000000..20a9fe2ba8
--- /dev/null
+++ b/test/files/jvm/value-class-boxing.check
@@ -0,0 +1,7 @@
+a2 and a1: bytecode identical
+a3 and a1: bytecode identical
+a4 and a1: bytecode identical
+b2 and b1: bytecode identical
+b3 and b1: bytecode identical
+b4 and b1: bytecode identical
+b5 and b1: bytecode identical
diff --git a/test/files/jvm/value-class-boxing/Analyzed_1.scala b/test/files/jvm/value-class-boxing/Analyzed_1.scala
new file mode 100644
index 0000000000..dec8565351
--- /dev/null
+++ b/test/files/jvm/value-class-boxing/Analyzed_1.scala
@@ -0,0 +1,17 @@
+class Wrap(val x: Int) extends AnyVal {
+ def ***(other: Bip): Wrap = new Wrap(x * other.x)
+}
+class Bip(val x: Int) extends AnyVal
+
+class SameBytecode {
+ def a1(x: Int, y: Int): Int = x + y
+ def a2(x: Wrap, y: Wrap): Wrap = new Wrap(x.x + y.x)
+ def a3(x: Int, y: Wrap): Wrap = new Wrap(x + y.x)
+ def a4(x: Int, y: Wrap): Int = x + y.x
+
+ def b1(x: Wrap, y: Int): Int = (x *** new Bip(y)).x
+ def b2(x: Wrap, y: Bip): Wrap = x *** y
+ def b3(x: Wrap, y: Int): Wrap = x *** new Bip(y)
+ def b4(x: Wrap, y: Bip): Bip = new Bip((x *** y).x)
+ def b5(x: Wrap, y: Int): Bip = new Bip((x *** new Bip(y)).x)
+}
diff --git a/test/files/jvm/value-class-boxing/test.scala b/test/files/jvm/value-class-boxing/test.scala
new file mode 100644
index 0000000000..cf331832de
--- /dev/null
+++ b/test/files/jvm/value-class-boxing/test.scala
@@ -0,0 +1,15 @@
+import scala.tools.partest.BytecodeTest
+
+object Test extends BytecodeTest {
+ def show: Unit = {
+ val classNode = loadClassNode("SameBytecode")
+ List("a2", "a3", "a4") foreach { m =>
+ print(m + " and a1: ")
+ sameBytecode(getMethod(classNode, "a1"), getMethod(classNode, m))
+ }
+ List("b2", "b3", "b4", "b5") foreach { m =>
+ print(m + " and b1: ")
+ sameBytecode(getMethod(classNode, "b1"), getMethod(classNode, m))
+ }
+ }
+}
diff --git a/test/files/jvm/xml01.scala b/test/files/jvm/xml01.scala
index 2fab650637..2b456f5ff5 100644
--- a/test/files/jvm/xml01.scala
+++ b/test/files/jvm/xml01.scala
@@ -1,10 +1,11 @@
import java.io.StringReader
import org.xml.sax.InputSource
-import scala.util.logging._
import scala.xml._
object Test extends App {
+ def Elem(prefix: String, label: String, attributes: MetaData, scope: NamespaceBinding, child: Node*): Elem =
+ scala.xml.Elem.apply(prefix, label, attributes, scope, minimizeEmpty = true, child: _*)
val e: scala.xml.MetaData = Null //Node.NoAttributes
val sc: scala.xml.NamespaceBinding = TopScope
diff --git a/test/files/jvm/xml03syntax.check b/test/files/jvm/xml03syntax.check
index edcdbdd2ba..599cbad686 100755
--- a/test/files/jvm/xml03syntax.check
+++ b/test/files/jvm/xml03syntax.check
@@ -24,3 +24,4 @@ true
node=<elem key="<b>hello</b>"/>, key=Some(<b>hello</b>)
node=<elem/>, key=None
+<a>Š</a>
diff --git a/test/files/jvm/xml03syntax.scala b/test/files/jvm/xml03syntax.scala
index 2c93f7c176..41663681c7 100644
--- a/test/files/jvm/xml03syntax.scala
+++ b/test/files/jvm/xml03syntax.scala
@@ -91,7 +91,7 @@ object Test {
}
val parsed = parser.element(TopScope) // parse the source as element
// alternatively, we could call document()
- parsed
+ println(parsed)
}
}
diff --git a/test/files/jvm/xmlattr.scala b/test/files/jvm/xmlattr.scala
index d214642eb6..6423268ba7 100644
--- a/test/files/jvm/xmlattr.scala
+++ b/test/files/jvm/xmlattr.scala
@@ -6,6 +6,7 @@ object Test {
UnprefixedAttributeTest()
AttributeWithOptionTest()
AttributeOutputTest()
+ AttributeOperatorTest()
}
object UnprefixedAttributeTest {
@@ -60,4 +61,10 @@ object Test {
}
}
+ object AttributeOperatorTest {
+ def apply() {
+ val xml = <foo bar="apple" />
+ assert(xml \@ "bar" == "apple")
+ }
+ }
}