summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/files/continuations-neg/t5314-missing-result-type.check4
-rw-r--r--test/files/continuations-neg/t5314-missing-result-type.scala13
-rw-r--r--test/files/continuations-neg/t5314-npe.check4
-rw-r--r--test/files/continuations-neg/t5314-npe.scala3
-rw-r--r--test/files/continuations-neg/t5314-return-reset.check4
-rw-r--r--test/files/continuations-neg/t5314-return-reset.scala21
-rw-r--r--test/files/continuations-neg/t5314-type-error.check6
-rw-r--r--test/files/continuations-neg/t5314-type-error.scala17
-rw-r--r--test/files/continuations-run/t5314-2.check5
-rw-r--r--test/files/continuations-run/t5314-2.scala44
-rw-r--r--test/files/continuations-run/t5314-3.check4
-rw-r--r--test/files/continuations-run/t5314-3.scala27
-rw-r--r--test/files/continuations-run/t5314-with-if.check1
-rw-r--r--test/files/continuations-run/t5314-with-if.scala17
-rw-r--r--test/files/continuations-run/t5314.check8
-rw-r--r--test/files/continuations-run/t5314.scala52
-rw-r--r--test/files/jvm/actmig-PinS.scala4
-rw-r--r--test/files/jvm/actmig-PinS_1.scala5
-rw-r--r--test/files/jvm/actmig-PinS_2.scala7
-rw-r--r--test/files/jvm/actmig-PinS_3.scala9
-rw-r--r--test/files/jvm/actmig-hierarchy.scala47
-rw-r--r--test/files/jvm/actmig-hierarchy_1.scala45
-rw-r--r--test/files/jvm/actmig-instantiation.scala96
-rw-r--r--test/files/jvm/actmig-loop-react.check1
-rw-r--r--test/files/jvm/actmig-loop-react.scala196
-rw-r--r--test/files/jvm/actmig-public-methods.check4
-rw-r--r--test/files/jvm/actmig-public-methods.scala74
-rw-r--r--test/files/jvm/actmig-public-methods_1.check4
-rw-r--r--test/files/jvm/actmig-public-methods_1.scala90
-rw-r--r--test/files/jvm/actmig-react-receive.scala9
-rw-r--r--test/files/jvm/actmig-react-within.check2
-rw-r--r--test/files/jvm/actmig-react-within.scala48
-rw-r--r--test/files/jvm/actmig-receive.check27
-rw-r--r--test/files/jvm/actmig-receive.scala120
-rw-r--r--test/files/neg/patmat-type-check.check10
-rw-r--r--test/files/neg/t1872.check4
-rw-r--r--test/files/neg/t4302.check2
-rw-r--r--test/files/neg/t5762.check13
-rw-r--r--test/files/neg/t5762.flags1
-rw-r--r--test/files/neg/t5762.scala24
-rw-r--r--test/files/neg/unchecked-abstract.check25
-rw-r--r--test/files/neg/unchecked-abstract.flags1
-rw-r--r--test/files/neg/unchecked-abstract.scala93
-rw-r--r--test/files/neg/unchecked-impossible.check4
-rw-r--r--test/files/neg/unchecked-impossible.flags1
-rw-r--r--test/files/neg/unchecked-impossible.scala16
-rw-r--r--test/files/neg/unchecked-knowable.check4
-rw-r--r--test/files/neg/unchecked-knowable.flags1
-rw-r--r--test/files/neg/unchecked-knowable.scala20
-rw-r--r--test/files/neg/unchecked-refinement.check13
-rw-r--r--test/files/neg/unchecked-refinement.flags1
-rw-r--r--test/files/neg/unchecked-refinement.scala27
-rw-r--r--test/files/neg/unchecked.check2
-rw-r--r--test/files/neg/unchecked.scala4
-rw-r--r--test/files/neg/unchecked2.check62
-rw-r--r--test/files/neg/unchecked2.scala37
-rw-r--r--test/files/neg/unchecked3.check37
-rw-r--r--test/files/neg/unchecked3.flags1
-rw-r--r--test/files/neg/unchecked3.scala83
-rw-r--r--test/files/pos/t1107b/O.scala (renamed from test/files/pos/t1107/O.scala)0
-rw-r--r--test/files/pos/t1107b/T.scala (renamed from test/files/pos/t1107/T.scala)0
-rw-r--r--test/files/pos/t1203b/J.java (renamed from test/files/pos/t1203/J.java)0
-rw-r--r--test/files/pos/t1203b/S.scala (renamed from test/files/pos/t1203/S.scala)0
-rw-r--r--test/files/pos/t6275.flags1
-rw-r--r--test/files/pos/t6275.scala11
-rw-r--r--test/files/run/existentials3-new.check8
-rw-r--r--test/files/run/macro-openmacros/Impls_Macros_1.scala3
-rw-r--r--test/files/run/macro-reify-nested-a/Impls_Macros_1.scala3
-rw-r--r--test/files/run/macro-reify-nested-b/Impls_Macros_1.scala3
-rw-r--r--test/files/run/macro-reify-splice-outside-reify/Impls_Macros_1.scala13
-rw-r--r--test/files/run/macro-reify-unreify/Macros_1.scala5
-rw-r--r--test/files/run/macro-sip19-revised/Impls_Macros_1.scala2
-rw-r--r--test/files/run/macro-sip19/Impls_Macros_1.scala2
-rw-r--r--test/files/run/macro-typecheck-macrosdisabled.check4
-rw-r--r--test/files/run/macro-typecheck-macrosdisabled2.check4
-rw-r--r--test/files/run/reflection-java-annotations.scala4
-rw-r--r--test/files/run/reflection-magicsymbols-invoke.check4
-rw-r--r--test/files/run/reflection-mem-typecheck.scala26
-rw-r--r--test/files/run/reify_ann1a.scala1
-rw-r--r--test/files/run/reify_ann1b.scala1
-rw-r--r--test/files/run/reify_ann2a.scala1
-rw-r--r--test/files/run/reify_ann3.scala1
-rw-r--r--test/files/run/reify_ann4.scala1
-rw-r--r--test/files/run/reify_ann5.scala1
-rw-r--r--test/files/run/t5423.scala2
-rw-r--r--test/files/run/t576.scala10
-rw-r--r--test/files/run/t6277.check1
-rw-r--r--test/files/run/t6277.scala9
-rw-r--r--test/files/run/t6344.check132
-rw-r--r--test/files/run/t6344.scala106
-rw-r--r--test/files/run/t6380.check7
-rw-r--r--test/files/run/t6380.scala20
-rw-r--r--test/files/run/t6410.check2
-rw-r--r--test/files/run/t6410.scala9
-rw-r--r--test/files/run/toolbox_console_reporter.check8
-rw-r--r--test/files/run/toolbox_console_reporter.scala35
-rw-r--r--test/files/run/toolbox_silent_reporter.scala4
-rw-r--r--test/files/run/toolbox_typecheck_macrosdisabled.check4
-rw-r--r--test/files/run/toolbox_typecheck_macrosdisabled2.check4
-rw-r--r--test/files/run/typetags_without_scala_reflect_manifest_lookup.scala2
-rw-r--r--test/osgi/src/BasicLibrary.scala2
-rw-r--r--test/pending/pos/exhaust_2.scala54
-rw-r--r--test/pending/run/reflection-mem-eval.scala26
-rw-r--r--test/scaladoc/resources/links.scala37
-rw-r--r--test/scaladoc/run/links.scala4
105 files changed, 1925 insertions, 156 deletions
diff --git a/test/files/continuations-neg/t5314-missing-result-type.check b/test/files/continuations-neg/t5314-missing-result-type.check
new file mode 100644
index 0000000000..341e580cf3
--- /dev/null
+++ b/test/files/continuations-neg/t5314-missing-result-type.check
@@ -0,0 +1,4 @@
+t5314-missing-result-type.scala:6: error: method bar has return statement; needs result type
+ def bar(x:Int) = return foo(x)
+ ^
+one error found
diff --git a/test/files/continuations-neg/t5314-missing-result-type.scala b/test/files/continuations-neg/t5314-missing-result-type.scala
new file mode 100644
index 0000000000..d7c5043a86
--- /dev/null
+++ b/test/files/continuations-neg/t5314-missing-result-type.scala
@@ -0,0 +1,13 @@
+import scala.util.continuations._
+
+object Test extends App {
+ def foo(x:Int): Int @cps[Int] = x
+
+ def bar(x:Int) = return foo(x)
+
+ reset {
+ val res = bar(8)
+ println(res)
+ res
+ }
+}
diff --git a/test/files/continuations-neg/t5314-npe.check b/test/files/continuations-neg/t5314-npe.check
new file mode 100644
index 0000000000..b5f024aa89
--- /dev/null
+++ b/test/files/continuations-neg/t5314-npe.check
@@ -0,0 +1,4 @@
+t5314-npe.scala:2: error: method bar has return statement; needs result type
+ def bar(x:Int) = { return x; x } // NPE
+ ^
+one error found
diff --git a/test/files/continuations-neg/t5314-npe.scala b/test/files/continuations-neg/t5314-npe.scala
new file mode 100644
index 0000000000..2b5966e07c
--- /dev/null
+++ b/test/files/continuations-neg/t5314-npe.scala
@@ -0,0 +1,3 @@
+object Test extends App {
+ def bar(x:Int) = { return x; x } // NPE
+}
diff --git a/test/files/continuations-neg/t5314-return-reset.check b/test/files/continuations-neg/t5314-return-reset.check
new file mode 100644
index 0000000000..4c817ae14d
--- /dev/null
+++ b/test/files/continuations-neg/t5314-return-reset.check
@@ -0,0 +1,4 @@
+t5314-return-reset.scala:14: error: return expression not allowed, since method calls CPS method
+ if (rnd.nextInt(100) > 50) return 5 // not allowed, since method is calling `reset`
+ ^
+one error found
diff --git a/test/files/continuations-neg/t5314-return-reset.scala b/test/files/continuations-neg/t5314-return-reset.scala
new file mode 100644
index 0000000000..df9d58e4cb
--- /dev/null
+++ b/test/files/continuations-neg/t5314-return-reset.scala
@@ -0,0 +1,21 @@
+import scala.util.continuations._
+import scala.util.Random
+
+object Test extends App {
+ val rnd = new Random
+
+ def foo(x: Int): Int @cps[Int] = shift { k => k(x) }
+
+ def bar(x: Int): Int @cps[Int] = return foo(x)
+
+ def caller(): Int = {
+ val v: Int = reset {
+ val res: Int = bar(8)
+ if (rnd.nextInt(100) > 50) return 5 // not allowed, since method is calling `reset`
+ 42
+ }
+ v
+ }
+
+ caller()
+}
diff --git a/test/files/continuations-neg/t5314-type-error.check b/test/files/continuations-neg/t5314-type-error.check
new file mode 100644
index 0000000000..1f4e46a7f2
--- /dev/null
+++ b/test/files/continuations-neg/t5314-type-error.check
@@ -0,0 +1,6 @@
+t5314-type-error.scala:7: error: type mismatch;
+ found : Int @util.continuations.cps[Int]
+ required: Int @util.continuations.cps[String]
+ def bar(x:Int): Int @cps[String] = return foo(x)
+ ^
+one error found
diff --git a/test/files/continuations-neg/t5314-type-error.scala b/test/files/continuations-neg/t5314-type-error.scala
new file mode 100644
index 0000000000..e36ce6c203
--- /dev/null
+++ b/test/files/continuations-neg/t5314-type-error.scala
@@ -0,0 +1,17 @@
+import scala.util.continuations._
+
+object Test extends App {
+ def foo(x:Int): Int @cps[Int] = shift { k => k(x) }
+
+ // should be a type error
+ def bar(x:Int): Int @cps[String] = return foo(x)
+
+ def caller(): Unit = {
+ val v: String = reset {
+ val res: Int = bar(8)
+ "hello"
+ }
+ }
+
+ caller()
+}
diff --git a/test/files/continuations-run/t5314-2.check b/test/files/continuations-run/t5314-2.check
new file mode 100644
index 0000000000..35b3c93780
--- /dev/null
+++ b/test/files/continuations-run/t5314-2.check
@@ -0,0 +1,5 @@
+8
+hi
+8
+from try
+8
diff --git a/test/files/continuations-run/t5314-2.scala b/test/files/continuations-run/t5314-2.scala
new file mode 100644
index 0000000000..8a896dec2c
--- /dev/null
+++ b/test/files/continuations-run/t5314-2.scala
@@ -0,0 +1,44 @@
+import scala.util.continuations._
+
+class ReturnRepro {
+ def s1: Int @cps[Any] = shift { k => k(5) }
+ def caller = reset { println(p(3)) }
+ def caller2 = reset { println(p2(3)) }
+ def caller3 = reset { println(p3(3)) }
+
+ def p(i: Int): Int @cps[Any] = {
+ val v= s1 + 3
+ return v
+ }
+
+ def p2(i: Int): Int @cps[Any] = {
+ val v = s1 + 3
+ if (v > 0) {
+ println("hi")
+ return v
+ } else {
+ println("hi")
+ return 8
+ }
+ }
+
+ def p3(i: Int): Int @cps[Any] = {
+ val v = s1 + 3
+ try {
+ println("from try")
+ return v
+ } catch {
+ case e: Exception =>
+ println("from catch")
+ return 7
+ }
+ }
+
+}
+
+object Test extends App {
+ val repro = new ReturnRepro
+ repro.caller
+ repro.caller2
+ repro.caller3
+}
diff --git a/test/files/continuations-run/t5314-3.check b/test/files/continuations-run/t5314-3.check
new file mode 100644
index 0000000000..71489f097c
--- /dev/null
+++ b/test/files/continuations-run/t5314-3.check
@@ -0,0 +1,4 @@
+enter return expr
+8
+hi
+8
diff --git a/test/files/continuations-run/t5314-3.scala b/test/files/continuations-run/t5314-3.scala
new file mode 100644
index 0000000000..62c547f5a2
--- /dev/null
+++ b/test/files/continuations-run/t5314-3.scala
@@ -0,0 +1,27 @@
+import scala.util.continuations._
+
+class ReturnRepro {
+ def s1: Int @cpsParam[Any, Unit] = shift { k => k(5) }
+ def caller = reset { println(p(3)) }
+ def caller2 = reset { println(p2(3)) }
+
+ def p(i: Int): Int @cpsParam[Unit, Any] = {
+ val v= s1 + 3
+ return { println("enter return expr"); v }
+ }
+
+ def p2(i: Int): Int @cpsParam[Unit, Any] = {
+ val v = s1 + 3
+ if (v > 0) {
+ return { println("hi"); v }
+ } else {
+ return { println("hi"); 8 }
+ }
+ }
+}
+
+object Test extends App {
+ val repro = new ReturnRepro
+ repro.caller
+ repro.caller2
+}
diff --git a/test/files/continuations-run/t5314-with-if.check b/test/files/continuations-run/t5314-with-if.check
new file mode 100644
index 0000000000..7f8f011eb7
--- /dev/null
+++ b/test/files/continuations-run/t5314-with-if.check
@@ -0,0 +1 @@
+7
diff --git a/test/files/continuations-run/t5314-with-if.scala b/test/files/continuations-run/t5314-with-if.scala
new file mode 100644
index 0000000000..5840199a3c
--- /dev/null
+++ b/test/files/continuations-run/t5314-with-if.scala
@@ -0,0 +1,17 @@
+import scala.util.continuations._
+
+object Test extends App {
+
+ def foo(x:Int): Int @cps[Int] = 7
+
+ def bar(x:Int): Int @cps[Int] = {
+ val v = foo(x)
+ if (v > 0)
+ return v
+ else
+ return 10
+ }
+
+ println(reset { bar(10) })
+
+}
diff --git a/test/files/continuations-run/t5314.check b/test/files/continuations-run/t5314.check
new file mode 100644
index 0000000000..4b35d8e6d0
--- /dev/null
+++ b/test/files/continuations-run/t5314.check
@@ -0,0 +1,8 @@
+7
+7
+7
+8
+8
+hi
+8
+8
diff --git a/test/files/continuations-run/t5314.scala b/test/files/continuations-run/t5314.scala
new file mode 100644
index 0000000000..d611016ce4
--- /dev/null
+++ b/test/files/continuations-run/t5314.scala
@@ -0,0 +1,52 @@
+import scala.util.continuations._
+
+class ReturnRepro {
+ def s1: Int @cpsParam[Any, Unit] = shift { k => k(5) }
+ def caller = reset { println(p(3)) }
+ def caller2 = reset { println(p2(3)) }
+
+ def p(i: Int): Int @cpsParam[Unit, Any] = {
+ val v= s1 + 3
+ return v
+ }
+
+ def p2(i: Int): Int @cpsParam[Unit, Any] = {
+ val v = s1 + 3
+ if (v > 0) {
+ println("hi")
+ return v
+ } else {
+ println("hi")
+ return 8
+ }
+ }
+}
+
+object Test extends App {
+ def foo(x:Int): Int @cps[Int] = shift { k => k(x) }
+
+ def bar(x:Int): Int @cps[Int] = return foo(x)
+
+ def nocps(x: Int): Int = { return x; x }
+
+ def foo2(x:Int): Int @cps[Int] = 7
+ def bar2(x:Int): Int @cps[Int] = { foo2(x); return 7 }
+ def bar3(x:Int): Int @cps[Int] = { foo2(x); if (x == 7) return 7 else return foo2(x) }
+ def bar4(x:Int): Int @cps[Int] = { foo2(x); if (x == 7) return 7 else foo2(x) }
+ def bar5(x:Int): Int @cps[Int] = { foo2(x); if (x == 7) return 7 else 8 }
+ println(reset { bar2(10) })
+ println(reset { bar3(10) })
+ println(reset { bar4(10) })
+ println(reset { bar5(10) })
+
+ /* original test case */
+ val repro = new ReturnRepro
+ repro.caller
+ repro.caller2
+
+ reset {
+ val res = bar(8)
+ println(res)
+ res
+ }
+}
diff --git a/test/files/jvm/actmig-PinS.scala b/test/files/jvm/actmig-PinS.scala
index 30307f3737..3f07fab12e 100644
--- a/test/files/jvm/actmig-PinS.scala
+++ b/test/files/jvm/actmig-PinS.scala
@@ -1,3 +1,7 @@
+/**
+ * NOTE: Code snippets from this test are included in the Actor Migration Guide. In case you change
+ * code in these tests prior to the 2.10.0 release please send the notification to @vjovanov.
+ */
import scala.actors._
import scala.concurrent.duration._
import scala.concurrent.{ Promise, Await }
diff --git a/test/files/jvm/actmig-PinS_1.scala b/test/files/jvm/actmig-PinS_1.scala
index 640684f728..876688ca75 100644
--- a/test/files/jvm/actmig-PinS_1.scala
+++ b/test/files/jvm/actmig-PinS_1.scala
@@ -1,4 +1,9 @@
+/**
+ * NOTE: Code snippets from this test are included in the Actor Migration Guide. In case you change
+ * code in these tests prior to the 2.10.0 release please send the notification to @vjovanov.
+ */
import scala.actors._
+import scala.actors.migration._
import scala.concurrent.duration._
import scala.concurrent.{ Promise, Await }
diff --git a/test/files/jvm/actmig-PinS_2.scala b/test/files/jvm/actmig-PinS_2.scala
index 761df6b5a7..7d12578f71 100644
--- a/test/files/jvm/actmig-PinS_2.scala
+++ b/test/files/jvm/actmig-PinS_2.scala
@@ -1,4 +1,9 @@
-import scala.actors.{ MigrationSystem, StashingActor, ActorRef, Props, Exit }
+/**
+ * NOTE: Code snippets from this test are included in the Actor Migration Guide. In case you change
+ * code in these tests prior to the 2.10.0 release please send the notification to @vjovanov.
+ */
+import scala.actors._
+import scala.actors.migration._
import scala.concurrent.duration._
import scala.concurrent.{ Promise, Await }
diff --git a/test/files/jvm/actmig-PinS_3.scala b/test/files/jvm/actmig-PinS_3.scala
index de9788724d..c2943008b0 100644
--- a/test/files/jvm/actmig-PinS_3.scala
+++ b/test/files/jvm/actmig-PinS_3.scala
@@ -1,4 +1,9 @@
-import scala.actors.{ MigrationSystem, StashingActor, ActorRef, Terminated, Props }
+/**
+ * NOTE: Code snippets from this test are included in the Actor Migration Guide. In case you change
+ * code in these tests prior to the 2.10.0 release please send the notification to @vjovanov.
+ */
+import scala.actors._
+import scala.actors.migration._
import scala.concurrent.duration._
import scala.concurrent.{ Promise, Await }
@@ -158,4 +163,4 @@ object Test extends App {
stash(m)
}
}, "default-stash-dispatcher"))
-} \ No newline at end of file
+}
diff --git a/test/files/jvm/actmig-hierarchy.scala b/test/files/jvm/actmig-hierarchy.scala
new file mode 100644
index 0000000000..17a44fda7a
--- /dev/null
+++ b/test/files/jvm/actmig-hierarchy.scala
@@ -0,0 +1,47 @@
+/**
+ * NOTE: Code snippets from this test are included in the Actor Migration Guide. In case you change
+ * code in these tests prior to the 2.10.0 release please send the notification to @vjovanov.
+ */
+import scala.actors._
+
+
+class ReactorActor extends Reactor[String] {
+ def act() {
+ var cond = true
+ loopWhile(cond) {
+ react {
+ case x if x == "hello1" => println("hello")
+ case "exit" => cond = false
+ }
+ }
+ }
+}
+
+class ReplyActor extends ReplyReactor {
+ def act() {
+ var cond = true
+ loopWhile(cond) {
+ react {
+ case "hello" => println("hello")
+ case "exit" => cond = false;
+ }
+ }
+ }
+}
+
+
+object Test {
+
+ def main(args: Array[String]) {
+ val reactorActor = new ReactorActor
+ val replyActor = new ReplyActor
+ reactorActor.start()
+ replyActor.start()
+
+ reactorActor ! "hello1"
+ replyActor ! "hello"
+
+ reactorActor ! "exit"
+ replyActor ! "exit"
+ }
+} \ No newline at end of file
diff --git a/test/files/jvm/actmig-hierarchy_1.scala b/test/files/jvm/actmig-hierarchy_1.scala
new file mode 100644
index 0000000000..14f03c9d48
--- /dev/null
+++ b/test/files/jvm/actmig-hierarchy_1.scala
@@ -0,0 +1,45 @@
+/**
+ * NOTE: Code snippets from this test are included in the Actor Migration Guide. In case you change
+ * code in these tests prior to the 2.10.0 release please send the notification to @vjovanov.
+ */
+import scala.actors._
+
+class ReactorActor extends Actor {
+ def act() {
+ var cond = true
+ loopWhile(cond) {
+ react {
+ case x: String if x == "hello1" => println("hello")
+ case "exit" => cond = false
+ }
+ }
+ }
+}
+
+class ReplyActor extends Actor {
+ def act() {
+ var cond = true
+ loopWhile(cond) {
+ react {
+ case "hello" => println("hello")
+ case "exit" => cond = false;
+ }
+ }
+ }
+}
+
+object Test {
+
+ def main(args: Array[String]) {
+ val reactorActor = new ReactorActor
+ val replyActor = new ReplyActor
+ reactorActor.start()
+ replyActor.start()
+
+ reactorActor ! "hello1"
+ replyActor ! "hello"
+
+ reactorActor ! "exit"
+ replyActor ! "exit"
+ }
+} \ No newline at end of file
diff --git a/test/files/jvm/actmig-instantiation.scala b/test/files/jvm/actmig-instantiation.scala
new file mode 100644
index 0000000000..d54dff9558
--- /dev/null
+++ b/test/files/jvm/actmig-instantiation.scala
@@ -0,0 +1,96 @@
+/**
+ * NOTE: Code snippets from this test are included in the Actor Migration Guide. In case you change
+ * code in these tests prior to the 2.10.0 release please send the notification to @vjovanov.
+ */
+import scala.actors.migration.MigrationSystem._
+import scala.actors.migration._
+import scala.actors.Actor._
+import scala.actors._
+import java.util.concurrent.{ TimeUnit, CountDownLatch }
+import scala.collection.mutable.ArrayBuffer
+
+class TestStashingActor extends StashingActor {
+
+ def receive = { case v: Int => Test.append(v); Test.latch.countDown() }
+
+}
+
+object Test {
+ val NUMBER_OF_TESTS = 5
+
+ // used for sorting non-deterministic output
+ val buff = ArrayBuffer[Int](0)
+ val latch = new CountDownLatch(NUMBER_OF_TESTS)
+ val toStop = ArrayBuffer[ActorRef]()
+
+ def append(v: Int) = synchronized {
+ buff += v
+ }
+
+ def main(args: Array[String]) = {
+ // plain scala actor
+ val a1 = actor {
+ react { case v: Int => Test.append(v); Test.latch.countDown() }
+ }
+ a1 ! 100
+
+ // simple instantiation
+ val a2 = MigrationSystem.actorOf(Props(() => new TestStashingActor, "akka.actor.default-stash-dispatcher"))
+ a2 ! 200
+ toStop += a2
+
+ // actor of with scala actor
+ val a3 = MigrationSystem.actorOf(Props(() => actor {
+ react { case v: Int => Test.append(v); Test.latch.countDown() }
+ }, "akka.actor.default-stash-dispatcher"))
+ a3 ! 300
+
+ // using the manifest
+ val a4 = MigrationSystem.actorOf(Props(() => new TestStashingActor, "akka.actor.default-stash-dispatcher"))
+ a4 ! 400
+ toStop += a4
+
+ // deterministic part of a test
+ // creation without actorOf
+ try {
+ val a3 = new TestStashingActor
+ a3 ! -1
+ } catch {
+ case e => println("OK error: " + e)
+ }
+
+ // actorOf double creation
+ try {
+ val a3 = MigrationSystem.actorOf(Props(() => {
+ new TestStashingActor
+ new TestStashingActor
+ }, "akka.actor.default-stash-dispatcher"))
+ a3 ! -1
+ } catch {
+ case e => println("OK error: " + e)
+ }
+
+ // actorOf nesting
+ try {
+ val a5 = MigrationSystem.actorOf(Props(() => {
+ val a6 = MigrationSystem.actorOf(Props(() => new TestStashingActor, "akka.actor.default-stash-dispatcher"))
+ toStop += a6
+ new TestStashingActor
+ }, "akka.actor.default-stash-dispatcher"))
+
+ a5 ! 500
+ toStop += a5
+ } catch {
+ case e => println("Should not throw an exception: " + e)
+ }
+
+ // output
+ latch.await(5, TimeUnit.SECONDS)
+ if (latch.getCount() > 0) {
+ println("Error: Tasks have not finished!!!")
+ }
+
+ buff.sorted.foreach(println)
+ toStop.foreach(_ ! PoisonPill)
+ }
+} \ No newline at end of file
diff --git a/test/files/jvm/actmig-loop-react.check b/test/files/jvm/actmig-loop-react.check
index 54cbe942c0..2474cbe71b 100644
--- a/test/files/jvm/actmig-loop-react.check
+++ b/test/files/jvm/actmig-loop-react.check
@@ -13,3 +13,4 @@ after react
do task 1
do string I am a String
do task 42
+after react
diff --git a/test/files/jvm/actmig-loop-react.scala b/test/files/jvm/actmig-loop-react.scala
new file mode 100644
index 0000000000..7f4c6f96dc
--- /dev/null
+++ b/test/files/jvm/actmig-loop-react.scala
@@ -0,0 +1,196 @@
+/**
+ * NOTE: Code snippets from this test are included in the Actor Migration Guide. In case you change
+ * code in these tests prior to the 2.10.0 release please send the notification to @vjovanov.
+ */
+import scala.actors.migration.MigrationSystem._
+import scala.actors.Actor._
+import scala.actors._
+import scala.actors.migration._
+import java.util.concurrent.{ TimeUnit, CountDownLatch }
+import scala.collection.mutable.ArrayBuffer
+import scala.concurrent.duration._
+import scala.concurrent.{ Promise, Await }
+
+object Test {
+ val finishedLWCR, finishedTNR, finishedEH = Promise[Boolean]
+ val finishedLWCR1, finishedTNR1, finishedEH1 = Promise[Boolean]
+
+ def testLoopWithConditionReact() = {
+ // Snippet showing composition of receives
+ // Loop with Condition Snippet - before
+ val myActor = actor {
+ var c = true
+ loopWhile(c) {
+ react {
+ case x: Int =>
+ // do task
+ println("do task")
+ if (x == 42) {
+ c = false
+ finishedLWCR1.success(true)
+ }
+ }
+ }
+ }
+
+ myActor.start()
+ myActor ! 1
+ myActor ! 42
+
+ Await.ready(finishedLWCR1.future, 5 seconds)
+
+ // Loop with Condition Snippet - migrated
+ val myAkkaActor = MigrationSystem.actorOf(Props(() => new StashingActor {
+
+ def receive = {
+ case x: Int =>
+ // do task
+ println("do task")
+ if (x == 42) {
+ finishedLWCR.success(true)
+ context.stop(self)
+ }
+ }
+ }, "default-stashing-dispatcher"))
+ myAkkaActor ! 1
+ myAkkaActor ! 42
+ }
+
+ def testNestedReact() = {
+ // Snippet showing composition of receives
+ // Loop with Condition Snippet - before
+ val myActor = actor {
+ var c = true
+ loopWhile(c) {
+ react {
+ case x: Int =>
+ // do task
+ println("do task " + x)
+ if (x == 42) {
+ c = false
+ } else {
+ react {
+ case y: String =>
+ println("do string " + y)
+ }
+ }
+ println("after react")
+ finishedTNR1.success(true)
+ }
+ }
+ }
+ myActor.start()
+
+ myActor ! 1
+ myActor ! "I am a String"
+ myActor ! 42
+
+ Await.ready(finishedTNR1.future, 5 seconds)
+
+ // Loop with Condition Snippet - migrated
+ val myAkkaActor = MigrationSystem.actorOf(Props(() => new StashingActor {
+
+ def receive = {
+ case x: Int =>
+ // do task
+ println("do task " + x)
+ if (x == 42) {
+ println("after react")
+ finishedTNR.success(true)
+ context.stop(self)
+ } else
+ context.become(({
+ case y: String =>
+ println("do string " + y)
+ }: Receive).andThen(x => {
+ unstashAll()
+ context.unbecome()
+ }).orElse { case x => stash() })
+ }
+ }, "default-stashing-dispatcher"))
+
+ myAkkaActor ! 1
+ myAkkaActor ! "I am a String"
+ myAkkaActor ! 42
+
+ }
+
+ def exceptionHandling() = {
+ // Stashing actor with act and exception handler
+ val myActor = MigrationSystem.actorOf(Props(() => new StashingActor {
+
+ def receive = { case _ => println("Dummy method.") }
+ override def act() = {
+ loop {
+ react {
+ case "fail" =>
+ throw new Exception("failed")
+ case "work" =>
+ println("working")
+ case "die" =>
+ finishedEH1.success(true)
+ exit()
+ }
+ }
+ }
+
+ override def exceptionHandler = {
+ case x: Exception => println("scala got exception")
+ }
+
+ }, "default-stashing-dispatcher"))
+
+ myActor ! "work"
+ myActor ! "fail"
+ myActor ! "die"
+
+ Await.ready(finishedEH1.future, 5 seconds)
+ // Stashing actor in Akka style
+ val myAkkaActor = MigrationSystem.actorOf(Props(() => new StashingActor {
+ def receive = PFCatch({
+ case "fail" =>
+ throw new Exception("failed")
+ case "work" =>
+ println("working")
+ case "die" =>
+ finishedEH.success(true)
+ context.stop(self)
+ }, { case x: Exception => println("akka got exception") })
+ }, "default-stashing-dispatcher"))
+
+ myAkkaActor ! "work"
+ myAkkaActor ! "fail"
+ myAkkaActor ! "die"
+ }
+
+ def main(args: Array[String]) = {
+ testLoopWithConditionReact()
+ Await.ready(finishedLWCR.future, 5 seconds)
+ exceptionHandling()
+ Await.ready(finishedEH.future, 5 seconds)
+ testNestedReact()
+ Await.ready(finishedTNR.future, 5 seconds)
+ }
+
+}
+
+// As per Jim Mcbeath's blog (http://jim-mcbeath.blogspot.com/2008/07/actor-exceptions.html)
+class PFCatch(f: PartialFunction[Any, Unit],
+ handler: PartialFunction[Exception, Unit])
+ extends PartialFunction[Any, Unit] {
+
+ def apply(x: Any) = {
+ try {
+ f(x)
+ } catch {
+ case e: Exception if handler.isDefinedAt(e) => handler(e)
+ }
+ }
+
+ def isDefinedAt(x: Any) = f.isDefinedAt(x)
+}
+
+object PFCatch {
+ def apply(f: PartialFunction[Any, Unit],
+ handler: PartialFunction[Exception, Unit]) = new PFCatch(f, handler)
+}
diff --git a/test/files/jvm/actmig-public-methods.check b/test/files/jvm/actmig-public-methods.check
index bb6530c926..c861c90e63 100644
--- a/test/files/jvm/actmig-public-methods.check
+++ b/test/files/jvm/actmig-public-methods.check
@@ -1,6 +1,6 @@
None
Some(bang qmark after 1)
bang
+bang bang in the future after 0
bang qmark after 0
-bang qmark in future after 0
-typed bang qmark in future after 0
+typed bang bang in the future after 0
diff --git a/test/files/jvm/actmig-public-methods.scala b/test/files/jvm/actmig-public-methods.scala
new file mode 100644
index 0000000000..58d7a1a9d4
--- /dev/null
+++ b/test/files/jvm/actmig-public-methods.scala
@@ -0,0 +1,74 @@
+/**
+ * NOTE: Code snippets from this test are included in the Actor Migration Guide. In case you change
+ * code in these tests prior to the 2.10.0 release please send the notification to @vjovanov.
+ */
+import scala.collection.mutable.ArrayBuffer
+import scala.actors.Actor._
+import scala.actors._
+import scala.actors.migration.MigrationSystem
+import scala.util.continuations._
+import java.util.concurrent.{ TimeUnit, CountDownLatch }
+
+object Test {
+ val NUMBER_OF_TESTS = 6
+
+ // used for sorting non-deterministic output
+ val buff = ArrayBuffer[String]()
+ val latch = new CountDownLatch(NUMBER_OF_TESTS)
+ val toStop = ArrayBuffer[Actor]()
+
+ def append(v: String) = synchronized {
+ buff += v
+ }
+
+ def main(args: Array[String]) = {
+
+ val respActor = actor {
+ loop {
+ react {
+ case (x: String, time: Long) =>
+ Thread.sleep(time)
+ reply(x + " after " + time)
+ case str: String =>
+ append(str)
+ latch.countDown()
+ case _ => exit()
+ }
+ }
+ }
+
+ toStop += respActor
+
+ respActor ! ("bang")
+
+ val res1 = respActor !? (("bang qmark", 0L))
+ append(res1.toString)
+ latch.countDown()
+
+ val res2 = respActor !? (5000, ("bang qmark", 1L))
+ append(res2.toString)
+ latch.countDown()
+
+ // this one should timeout
+ val res21 = respActor !? (1, ("bang qmark", 5000L))
+ append(res21.toString)
+ latch.countDown()
+
+ val fut1 = respActor !! (("bang bang in the future", 0L))
+ append(fut1().toString())
+ latch.countDown()
+
+ val fut2 = respActor !! (("typed bang bang in the future", 0L), { case x: String => x })
+ append(fut2())
+ latch.countDown()
+
+ // output
+ latch.await(10, TimeUnit.SECONDS)
+ if (latch.getCount() > 0) {
+ println("Error: Tasks have not finished!!!")
+ }
+
+ buff.sorted.foreach(println)
+ toStop.foreach(_ ! 'stop)
+ }
+} \ No newline at end of file
diff --git a/test/files/jvm/actmig-public-methods_1.check b/test/files/jvm/actmig-public-methods_1.check
index bb6530c926..c861c90e63 100644
--- a/test/files/jvm/actmig-public-methods_1.check
+++ b/test/files/jvm/actmig-public-methods_1.check
@@ -1,6 +1,6 @@
None
Some(bang qmark after 1)
bang
+bang bang in the future after 0
bang qmark after 0
-bang qmark in future after 0
-typed bang qmark in future after 0
+typed bang bang in the future after 0
diff --git a/test/files/jvm/actmig-public-methods_1.scala b/test/files/jvm/actmig-public-methods_1.scala
index 4bbdc9a71f..15516a5d51 100644
--- a/test/files/jvm/actmig-public-methods_1.scala
+++ b/test/files/jvm/actmig-public-methods_1.scala
@@ -1,10 +1,18 @@
+/**
+ * NOTE: Code snippets from this test are included in the Actor Migration Guide. In case you change
+ * code in these tests prior to the 2.10.0 release please send the notification to @vjovanov.
+ */
import scala.collection.mutable.ArrayBuffer
import scala.actors.Actor._
import scala.actors._
+import scala.actors.migration._
import scala.util._
+import scala.concurrent._
+import scala.concurrent.duration._
import java.util.concurrent.{ TimeUnit, CountDownLatch }
-import scala.concurrent.duration.Duration
-import scala.actors.pattern._
+import scala.concurrent.duration._
+import scala.actors.migration.pattern._
+import scala.concurrent.ExecutionContext.Implicits.global
object Test {
val NUMBER_OF_TESTS = 6
@@ -39,45 +47,53 @@ object Test {
respActor ! "bang"
- implicit val timeout = Timeout(Duration(500, TimeUnit.MILLISECONDS))
- val msg = ("bang qmark", 0L)
- val res1 = respActor.?(msg)(Timeout(Duration.Inf))
- append(res1().toString)
- latch.countDown()
-
- val msg1 = ("bang qmark", 1L)
- val res2 = respActor.?(msg1)(Timeout(Duration(500, TimeUnit.MILLISECONDS)))
- append((res2() match {
- case x: AskTimeoutException => None
- case v => Some(v)
- }).toString)
- latch.countDown()
-
- // this one should time out
- val msg11 = ("bang qmark", 500L)
- val res21 = respActor.?(msg11)(Timeout(Duration(1, TimeUnit.MILLISECONDS)))
- append((res21() match {
- case x: AskTimeoutException => None
- case v => Some(v)
- }).toString)
- latch.countDown()
-
- val msg2 = ("bang qmark in future", 0L)
- val fut1 = respActor.?(msg2)(Duration.Inf)
- append(fut1().toString())
- latch.countDown()
-
- val handler: PartialFunction[Any, String] = {
- case x: String => x.toString
+ {
+ val msg = ("bang qmark", 0L)
+ val res = respActor.?(msg)(Timeout(Duration.Inf))
+ append(Await.result(res, Duration.Inf).toString)
+ latch.countDown()
}
- val msg3 = ("typed bang qmark in future", 0L)
- val fut2 = (respActor.?(msg3)(Duration.Inf))
- append(Futures.future { handler.apply(fut2()) }().toString)
- latch.countDown()
+ {
+ val msg = ("bang qmark", 1L)
+ val res = respActor.?(msg)(Timeout(5 seconds))
+
+ val promise = Promise[Option[Any]]()
+ res.onComplete(v => promise.success(v.toOption))
+ append(Await.result(promise.future, Duration.Inf).toString)
+
+ latch.countDown()
+ }
+
+ {
+ val msg = ("bang qmark", 5000L)
+ val res = respActor.?(msg)(Timeout(1 millisecond))
+ val promise = Promise[Option[Any]]()
+ res.onComplete(v => promise.success(v.toOption))
+ append(Await.result(promise.future, Duration.Inf).toString)
+ latch.countDown()
+ }
+
+ {
+ val msg = ("bang bang in the future", 0L)
+ val fut = respActor.?(msg)(Timeout(Duration.Inf))
+ append(Await.result(fut, Duration.Inf).toString)
+ latch.countDown()
+ }
+
+ {
+ val handler: PartialFunction[Any, String] = {
+ case x: String => x
+ }
+
+ val msg = ("typed bang bang in the future", 0L)
+ val fut = (respActor.?(msg)(Timeout(Duration.Inf)))
+ append((Await.result(fut.map(handler), Duration.Inf)).toString)
+ latch.countDown()
+ }
// output
- latch.await(200, TimeUnit.MILLISECONDS)
+ latch.await(10, TimeUnit.SECONDS)
if (latch.getCount() > 0) {
println("Error: Tasks have not finished!!!")
}
diff --git a/test/files/jvm/actmig-react-receive.scala b/test/files/jvm/actmig-react-receive.scala
index 280582511f..6adeac8b52 100644
--- a/test/files/jvm/actmig-react-receive.scala
+++ b/test/files/jvm/actmig-react-receive.scala
@@ -1,6 +1,11 @@
-import scala.actors.MigrationSystem._
+/**
+ * NOTE: Code snippets from this test are included in the Actor Migration Guide. In case you change
+ * code in these tests prior to the 2.10.0 release please send the notification to @vjovanov.
+ */
+import scala.actors.migration.MigrationSystem._
import scala.actors.Actor._
-import scala.actors.{ Actor, StashingActor, ActorRef, Props, MigrationSystem, PoisonPill }
+import scala.actors._
+import scala.actors.migration._
import java.util.concurrent.{ TimeUnit, CountDownLatch }
import scala.collection.mutable.ArrayBuffer
import scala.concurrent.duration._
diff --git a/test/files/jvm/actmig-react-within.check b/test/files/jvm/actmig-react-within.check
new file mode 100644
index 0000000000..57798dbefb
--- /dev/null
+++ b/test/files/jvm/actmig-react-within.check
@@ -0,0 +1,2 @@
+received
+received
diff --git a/test/files/jvm/actmig-react-within.scala b/test/files/jvm/actmig-react-within.scala
new file mode 100644
index 0000000000..43350ef120
--- /dev/null
+++ b/test/files/jvm/actmig-react-within.scala
@@ -0,0 +1,48 @@
+/**
+ * NOTE: Code snippets from this test are included in the Actor Migration Guide. In case you change
+ * code in these tests prior to the 2.10.0 release please send the notification to @vjovanov.
+ */
+import scala.actors.migration.MigrationSystem._
+import scala.actors.Actor._
+import scala.actors._
+import scala.actors.migration._
+import java.util.concurrent.{ TimeUnit, CountDownLatch }
+import scala.collection.mutable.ArrayBuffer
+import scala.concurrent.duration._
+import scala.concurrent.{ Promise, Await }
+
+object Test {
+ val finished = Promise[Boolean]
+
+ def testReactWithin() = {
+ val sActor = actor {
+ loop {
+ reactWithin(1) {
+ case scala.actors.TIMEOUT =>
+ println("received")
+ exit()
+ case _ =>
+ println("Should not occur.")
+ }
+ }
+ }
+
+ val myActor = MigrationSystem.actorOf(Props(() => new StashingActor {
+ context.setReceiveTimeout(1 millisecond)
+ def receive = {
+ case ReceiveTimeout =>
+ println("received")
+ finished.success(true)
+ context.stop(self)
+ case _ =>
+ println("Should not occur.")
+ }
+ }, "default-stashing-dispatcher"))
+ }
+
+ def main(args: Array[String]) = {
+ testReactWithin()
+ Await.ready(finished.future, 5 seconds)
+ }
+
+}
diff --git a/test/files/jvm/actmig-receive.check b/test/files/jvm/actmig-receive.check
new file mode 100644
index 0000000000..30886140e1
--- /dev/null
+++ b/test/files/jvm/actmig-receive.check
@@ -0,0 +1,27 @@
+Original
+do before
+receive 1
+do in between
+receive 1
+do after
+Transformed
+do before
+receive 1
+do in between
+receive 1
+do after
+Test Loop Receive
+Original
+do before body
+receive 1
+do after receive
+do before body
+do after receive
+after loop
+Transformed
+do before body
+receive 1
+do after receive
+do before body
+do after receive
+after loop
diff --git a/test/files/jvm/actmig-receive.scala b/test/files/jvm/actmig-receive.scala
new file mode 100644
index 0000000000..03dc1be63b
--- /dev/null
+++ b/test/files/jvm/actmig-receive.scala
@@ -0,0 +1,120 @@
+/**
+ * NOTE: Code snippets from this test are included in the Actor Migration Guide. In case you change
+ * code in these tests prior to the 2.10.0 release please send the notification to @vjovanov.
+ */
+import scala.actors.migration.MigrationSystem._
+import scala.actors.Actor._
+import scala.actors._
+import scala.actors.migration._
+import java.util.concurrent.{ TimeUnit, CountDownLatch }
+import scala.collection.mutable.ArrayBuffer
+import scala.concurrent.duration._
+import scala.concurrent.{ Promise, Await }
+
+object Test {
+ val finishedSingle, finishedSingle1, finishedLoop, finishedLoop1 = Promise[Boolean]
+
+ def testDoubleReceive() = {
+ println("Original")
+ // Snippet that shows how to get rid of receive calls in Scala Actors.
+ // This snippet is used in the Actors Migration Kit.
+ val myActor = actor {
+ println("do before")
+ receive {
+ case "hello" =>
+ println("receive 1")
+ }
+ println("do in between")
+ receive {
+ case "hello" =>
+ println("receive 1")
+ }
+ println("do after")
+ finishedSingle.success(true)
+ }
+
+ myActor ! "hello"
+ myActor ! "hello"
+
+ Await.ready(finishedSingle.future, 5 seconds)
+ println("Transformed")
+ val myActorReact = actor {
+ println("do before")
+ react (({
+ case "hello" =>
+ println("receive 1")
+ }: PartialFunction[Any, Unit]).andThen { x =>
+ println("do in between")
+ react (({
+ case "hello" =>
+ println("receive 1")
+ }: PartialFunction[Any, Unit]).andThen { x =>
+ println("do after")
+ finishedSingle1.success(true)
+ })
+ })
+ }
+
+ myActorReact ! "hello"
+ myActorReact ! "hello"
+
+ Await.ready(finishedSingle1.future, 5 seconds)
+ }
+
+ def testLoopReceive() = {
+ println("Test Loop Receive")
+ // Snippet that shows how to get rid of receive calls in loops.
+ // This snippet is used in the Actors Migration Kit.
+ println("Original")
+ val myActor = actor {
+ var c = true
+ while (c) {
+ println("do before body")
+ receive {
+ case "hello" =>
+ println("receive 1")
+ case "exit" =>
+ c = false
+ }
+ println("do after receive")
+ }
+ println("after loop")
+ finishedLoop.success(true)
+ }
+
+ myActor ! "hello"
+ myActor ! "exit"
+ Await.ready(finishedLoop.future, 5 seconds)
+ println("Transformed")
+
+ val myActorReact = actor {
+ var c = true
+ loopWhile(c) {
+ println("do before body")
+ react (({
+ case "hello" =>
+ println("receive 1")
+ case "exit" =>
+ c = false
+ }: PartialFunction[Any, Unit]).andThen { x =>
+ println("do after receive")
+ if (c == false) {
+ println("after loop")
+ finishedLoop1.success(true)
+ }
+ })
+ }
+ }
+
+ myActorReact ! "hello"
+ myActorReact ! "exit"
+
+ Await.ready(finishedLoop1.future, 5 seconds)
+ }
+
+ def main(args: Array[String]) = {
+ testDoubleReceive()
+ testLoopReceive()
+ }
+
+}
diff --git a/test/files/neg/patmat-type-check.check b/test/files/neg/patmat-type-check.check
index e045841ce1..721217c314 100644
--- a/test/files/neg/patmat-type-check.check
+++ b/test/files/neg/patmat-type-check.check
@@ -1,3 +1,12 @@
+patmat-type-check.scala:11: warning: fruitless type test: a value of type Test.Bop4[T] cannot also be a Seq[A]
+ def s3[T](x: Bop4[T]) = x match { case Seq('b', 'o', 'b') => true }
+ ^
+patmat-type-check.scala:15: warning: fruitless type test: a value of type Test.Bop5[_$1,T1,T2] cannot also be a Seq[A]
+ def s4[T1, T2](x: Bop5[_, T1, T2]) = x match { case Seq('b', 'o', 'b') => true }
+ ^
+patmat-type-check.scala:19: warning: fruitless type test: a value of type Test.Bop3[T] cannot also be a Seq[A]
+ def f4[T](x: Bop3[T]) = x match { case Seq('b', 'o', 'b') => true }
+ ^
patmat-type-check.scala:22: error: scrutinee is incompatible with pattern type;
found : Seq[A]
required: String
@@ -18,4 +27,5 @@ patmat-type-check.scala:30: error: scrutinee is incompatible with pattern type;
required: Test.Bop3[Char]
def f4[T](x: Bop3[Char]) = x match { case Seq('b', 'o', 'b') => true } // fail
^
+three warnings found
four errors found
diff --git a/test/files/neg/t1872.check b/test/files/neg/t1872.check
index ef84ef79e0..c5dc2a8080 100644
--- a/test/files/neg/t1872.check
+++ b/test/files/neg/t1872.check
@@ -1,4 +1,8 @@
+t1872.scala:3: warning: fruitless type test: a value of type Int cannot also be a scala.util.Random
+ def f(x: Int) = x.isInstanceOf[util.Random]
+ ^
t1872.scala:3: error: isInstanceOf cannot test if value types are references.
def f(x: Int) = x.isInstanceOf[util.Random]
^
+one warning found
one error found
diff --git a/test/files/neg/t4302.check b/test/files/neg/t4302.check
index 327425acb0..450d28bbc5 100644
--- a/test/files/neg/t4302.check
+++ b/test/files/neg/t4302.check
@@ -1,4 +1,4 @@
-t4302.scala:2: error: abstract type T in type T is unchecked since it is eliminated by erasure
+t4302.scala:2: error: abstract type T is unchecked since it is eliminated by erasure
def hasMatch[T](x: AnyRef) = x.isInstanceOf[T]
^
one error found
diff --git a/test/files/neg/t5762.check b/test/files/neg/t5762.check
new file mode 100644
index 0000000000..10064032aa
--- /dev/null
+++ b/test/files/neg/t5762.check
@@ -0,0 +1,13 @@
+t5762.scala:6: error: non-variable type argument Int in type pattern D[Int] is unchecked since it is eliminated by erasure
+ case _: D[Int] if bippy => 1
+ ^
+t5762.scala:7: error: non-variable type argument String in type pattern D[String] is unchecked since it is eliminated by erasure
+ case _: D[String] => 2
+ ^
+t5762.scala:20: error: non-variable type argument D[Int] in type pattern D[D[Int]] is unchecked since it is eliminated by erasure
+ case _: D[D[Int]] if bippy => 1
+ ^
+t5762.scala:21: error: non-variable type argument D[String] in type pattern D[D[String]] is unchecked since it is eliminated by erasure
+ case _: D[D[String]] => 2
+ ^
+four errors found
diff --git a/test/files/neg/t5762.flags b/test/files/neg/t5762.flags
new file mode 100644
index 0000000000..85d8eb2ba2
--- /dev/null
+++ b/test/files/neg/t5762.flags
@@ -0,0 +1 @@
+-Xfatal-warnings
diff --git a/test/files/neg/t5762.scala b/test/files/neg/t5762.scala
new file mode 100644
index 0000000000..fb73552b12
--- /dev/null
+++ b/test/files/neg/t5762.scala
@@ -0,0 +1,24 @@
+class D[-A]
+
+object Test {
+ var bippy: Boolean = true
+ def f1(x: D[Int with String]) = x match {
+ case _: D[Int] if bippy => 1
+ case _: D[String] => 2
+ }
+ // Correctly warns:
+ //
+ // a.scala:5: warning: non variable type-argument Int in type pattern D[Int] is unchecked since it is eliminated by erasure
+ // case _: D[Int] => 1
+ // ^
+ // a.scala:6: warning: non variable type-argument String in type pattern D[String] is unchecked since it is eliminated by erasure
+ // case _: D[String] => 2
+ // ^
+ // two warnings found
+
+ def f2(x: D[D[Int] with D[String]]) = x match {
+ case _: D[D[Int]] if bippy => 1
+ case _: D[D[String]] => 2
+ }
+ // No warnings!
+}
diff --git a/test/files/neg/unchecked-abstract.check b/test/files/neg/unchecked-abstract.check
new file mode 100644
index 0000000000..dc7a8d93d0
--- /dev/null
+++ b/test/files/neg/unchecked-abstract.check
@@ -0,0 +1,25 @@
+unchecked-abstract.scala:16: error: abstract type H in type Con[M.this.H] is unchecked since it is eliminated by erasure
+ /* warn */ println(x.isInstanceOf[Con[H]])
+ ^
+unchecked-abstract.scala:21: error: abstract type H in type Con[M.this.H] is unchecked since it is eliminated by erasure
+ /* warn */ println(x.isInstanceOf[Con[H]])
+ ^
+unchecked-abstract.scala:27: error: abstract type T in type Inv[M.this.T] is unchecked since it is eliminated by erasure
+ /* warn */ println(x.isInstanceOf[Inv[T]])
+ ^
+unchecked-abstract.scala:28: error: abstract type L in type Inv[M.this.L] is unchecked since it is eliminated by erasure
+ /* warn */ println(x.isInstanceOf[Inv[L]])
+ ^
+unchecked-abstract.scala:31: error: abstract type H in type Inv[M.this.H] is unchecked since it is eliminated by erasure
+ /* warn */ println(x.isInstanceOf[Inv[H]])
+ ^
+unchecked-abstract.scala:33: error: abstract type L in type Inv[M.this.L] is unchecked since it is eliminated by erasure
+ /* warn */ println(x.isInstanceOf[Inv[L]])
+ ^
+unchecked-abstract.scala:36: error: abstract type H in type Inv[M.this.H] is unchecked since it is eliminated by erasure
+ /* warn */ println(x.isInstanceOf[Inv[H]])
+ ^
+unchecked-abstract.scala:37: error: abstract type T in type Inv[M.this.T] is unchecked since it is eliminated by erasure
+ /* warn */ println(x.isInstanceOf[Inv[T]])
+ ^
+8 errors found
diff --git a/test/files/neg/unchecked-abstract.flags b/test/files/neg/unchecked-abstract.flags
new file mode 100644
index 0000000000..85d8eb2ba2
--- /dev/null
+++ b/test/files/neg/unchecked-abstract.flags
@@ -0,0 +1 @@
+-Xfatal-warnings
diff --git a/test/files/neg/unchecked-abstract.scala b/test/files/neg/unchecked-abstract.scala
new file mode 100644
index 0000000000..5b915755f4
--- /dev/null
+++ b/test/files/neg/unchecked-abstract.scala
@@ -0,0 +1,93 @@
+trait Con[-X]
+trait Inv[X]
+trait Cov[+X]
+
+abstract class M {
+ type H
+ type L <: H
+ type T >: L <: H
+
+ def h1(x: Con[H]) = {
+ /* nowarn */ println(x.isInstanceOf[Con[H]])
+ /* nowarn */ println(x.isInstanceOf[Con[T]])
+ /* nowarn */ println(x.isInstanceOf[Con[L]])
+ }
+ def h2(x: Con[T]) = {
+ /* warn */ println(x.isInstanceOf[Con[H]])
+ /* nowarn */ println(x.isInstanceOf[Con[T]])
+ /* nowarn */ println(x.isInstanceOf[Con[L]])
+ }
+ def h3(x: Con[L]) = {
+ /* warn */ println(x.isInstanceOf[Con[H]])
+ /* warn */ println(x.isInstanceOf[Con[T]])
+ /* nowarn */ println(x.isInstanceOf[Con[L]])
+ }
+ def h4(x: Inv[H]) = {
+ /* nowarn */ println(x.isInstanceOf[Inv[H]])
+ /* warn */ println(x.isInstanceOf[Inv[T]])
+ /* warn */ println(x.isInstanceOf[Inv[L]])
+ }
+ def h5(x: Inv[T]) = {
+ /* warn */ println(x.isInstanceOf[Inv[H]])
+ /* nowarn */ println(x.isInstanceOf[Inv[T]])
+ /* warn */ println(x.isInstanceOf[Inv[L]])
+ }
+ def h6(x: Inv[L]) = {
+ /* warn */ println(x.isInstanceOf[Inv[H]])
+ /* warn */ println(x.isInstanceOf[Inv[T]])
+ /* nowarn */ println(x.isInstanceOf[Inv[L]])
+ }
+ def h7(x: Cov[H]) = {
+ /* nowarn */ println(x.isInstanceOf[Cov[H]])
+ /* warn */ println(x.isInstanceOf[Cov[T]])
+ /* warn */ println(x.isInstanceOf[Cov[L]])
+ }
+ def h8(x: Cov[T]) = {
+ /* nowarn */ println(x.isInstanceOf[Cov[H]])
+ /* nowarn */ println(x.isInstanceOf[Cov[T]])
+ /* warn */ println(x.isInstanceOf[Cov[L]])
+ }
+ def h9(x: Cov[L]) = {
+ /* nowarn */ println(x.isInstanceOf[Cov[H]])
+ /* nowarn */ println(x.isInstanceOf[Cov[T]])
+ /* nowarn */ println(x.isInstanceOf[Cov[L]])
+ }
+}
+
+object Test extends M {
+ type H = Any
+ type T = Int
+ type L = Nothing
+
+ val conh = new Con[H] { }
+ val cont = new Con[T] { }
+ val conl = new Con[L] { }
+
+ val invh = new Inv[H] { }
+ val invt = new Inv[T] { }
+ val invl = new Inv[L] { }
+
+ val covh = new Cov[H] { }
+ val covt = new Cov[T] { }
+ val covl = new Cov[L] { }
+
+ def main(args: Array[String]): Unit = {
+ h1(conh)
+ h2(conh)
+ h2(cont)
+ h3(conh)
+ h3(cont)
+ h3(conl)
+
+ h4(invh)
+ h5(invt)
+ h6(invl)
+
+ h7(covh)
+ h7(covt)
+ h7(covl)
+ h8(covt)
+ h8(covl)
+ h9(covl)
+ }
+}
diff --git a/test/files/neg/unchecked-impossible.check b/test/files/neg/unchecked-impossible.check
new file mode 100644
index 0000000000..0ab371dbaa
--- /dev/null
+++ b/test/files/neg/unchecked-impossible.check
@@ -0,0 +1,4 @@
+unchecked-impossible.scala:5: error: fruitless type test: a value of type T2[Int,Int] cannot also be a Seq[A]
+ case Seq(x) =>
+ ^
+one error found
diff --git a/test/files/neg/unchecked-impossible.flags b/test/files/neg/unchecked-impossible.flags
new file mode 100644
index 0000000000..85d8eb2ba2
--- /dev/null
+++ b/test/files/neg/unchecked-impossible.flags
@@ -0,0 +1 @@
+-Xfatal-warnings
diff --git a/test/files/neg/unchecked-impossible.scala b/test/files/neg/unchecked-impossible.scala
new file mode 100644
index 0000000000..985a2d0b08
--- /dev/null
+++ b/test/files/neg/unchecked-impossible.scala
@@ -0,0 +1,16 @@
+final case class T2[+A, +B](a: A, b: B)
+
+class A {
+ def f1 = T2(1, 2) match {
+ case Seq(x) =>
+ case _ =>
+ }
+ def f2 = T2(1, 2) match {
+ case _: T2[Int, Int] => /* nowarn */
+ case _ =>
+ }
+ def f3 = T2(1, 2) match {
+ case _: T2[_, Int] => /* nowarn */
+ case _ =>
+ }
+}
diff --git a/test/files/neg/unchecked-knowable.check b/test/files/neg/unchecked-knowable.check
new file mode 100644
index 0000000000..3a6ef994b5
--- /dev/null
+++ b/test/files/neg/unchecked-knowable.check
@@ -0,0 +1,4 @@
+unchecked-knowable.scala:17: error: fruitless type test: a value of type Bippy cannot also be a A1
+ /* warn */ (new Bippy).isInstanceOf[A1]
+ ^
+one error found
diff --git a/test/files/neg/unchecked-knowable.flags b/test/files/neg/unchecked-knowable.flags
new file mode 100644
index 0000000000..85d8eb2ba2
--- /dev/null
+++ b/test/files/neg/unchecked-knowable.flags
@@ -0,0 +1 @@
+-Xfatal-warnings
diff --git a/test/files/neg/unchecked-knowable.scala b/test/files/neg/unchecked-knowable.scala
new file mode 100644
index 0000000000..667b47f504
--- /dev/null
+++ b/test/files/neg/unchecked-knowable.scala
@@ -0,0 +1,20 @@
+/** Knowable - only final leaves */
+sealed abstract class A1
+sealed abstract class A2 extends A1
+final class A3 extends A1
+final class A4 extends A2
+
+/** Unknowable */
+sealed abstract class B1
+sealed abstract class B2 extends B1
+final class B3 extends B1
+trait B4 extends B2
+
+class Bippy
+trait Dingus
+
+class A {
+ /* warn */ (new Bippy).isInstanceOf[A1]
+ /* nowarn */ (new Bippy).isInstanceOf[B1]
+ /* nowarn */ ((new Bippy): Any).isInstanceOf[A1]
+}
diff --git a/test/files/neg/unchecked-refinement.check b/test/files/neg/unchecked-refinement.check
new file mode 100644
index 0000000000..d81517464f
--- /dev/null
+++ b/test/files/neg/unchecked-refinement.check
@@ -0,0 +1,13 @@
+unchecked-refinement.scala:17: error: abstract type U in type pattern Foo[U,U,V] is unchecked since it is eliminated by erasure
+ /* warn */ case _: Foo[U, U, V] if b => ()
+ ^
+unchecked-refinement.scala:19: error: non-variable type argument Any in type pattern Foo[Any,U,V] is unchecked since it is eliminated by erasure
+ /* warn */ case _: Foo[Any, U, V] if b => ()
+ ^
+unchecked-refinement.scala:23: error: a pattern match on a refinement type is unchecked
+ /* nowarn - todo */ case x: AnyRef { def bippy: Int } if b => x.bippy // this could/should do an instance check and not warn
+ ^
+unchecked-refinement.scala:24: error: a pattern match on a refinement type is unchecked
+ /* nowarn - todo */ case x: AnyRef { def size: Int } if b => x.size // this could/should do a static conformance test and not warn
+ ^
+four errors found
diff --git a/test/files/neg/unchecked-refinement.flags b/test/files/neg/unchecked-refinement.flags
new file mode 100644
index 0000000000..85d8eb2ba2
--- /dev/null
+++ b/test/files/neg/unchecked-refinement.flags
@@ -0,0 +1 @@
+-Xfatal-warnings
diff --git a/test/files/neg/unchecked-refinement.scala b/test/files/neg/unchecked-refinement.scala
new file mode 100644
index 0000000000..79ed7f13c1
--- /dev/null
+++ b/test/files/neg/unchecked-refinement.scala
@@ -0,0 +1,27 @@
+// a.scala
+// Thu Sep 27 09:42:16 PDT 2012
+
+trait Bar[-T1, T2, +T3] { }
+trait Foo[-T1, T2, +T3] extends Bar[T1, T2, T3]
+
+class A {
+ var b = true
+
+ def f1(x: Foo[Int, Int, Int]) = x match {
+ /* nowarn */ case _: Foo[Nothing, Int, Any] => true
+ }
+ def f2[T, U, V](x: Foo[T, U, V]) = x match {
+ /* nowarn */ case _: Foo[Nothing, U, Any] => true
+ }
+ def f3[T, U, V](x: Foo[T, U, V]) = x match {
+ /* warn */ case _: Foo[U, U, V] if b => ()
+ /* nowarn */ case _: Foo[Nothing, U, V] if b => ()
+ /* warn */ case _: Foo[Any, U, V] if b => ()
+ }
+
+ def f4(xs: List[Int]) = xs match {
+ /* nowarn - todo */ case x: AnyRef { def bippy: Int } if b => x.bippy // this could/should do an instance check and not warn
+ /* nowarn - todo */ case x: AnyRef { def size: Int } if b => x.size // this could/should do a static conformance test and not warn
+ /* nowarn */ case x: ((AnyRef { def size: Int }) @unchecked) if b => x.size
+ }
+}
diff --git a/test/files/neg/unchecked.check b/test/files/neg/unchecked.check
index 34a11db1a0..2883b716c9 100644
--- a/test/files/neg/unchecked.check
+++ b/test/files/neg/unchecked.check
@@ -2,7 +2,7 @@ unchecked.scala:18: error: non-variable type argument String in type pattern Ite
case xs: Iterable[String] => xs.head // unchecked
^
unchecked.scala:22: error: non-variable type argument Any in type pattern Set[Any] is unchecked since it is eliminated by erasure
- case xs: Set[Any] => xs.head // unchecked
+ case xs: Set[Any] => xs.head // unchecked
^
unchecked.scala:26: error: non-variable type argument Any in type pattern Map[Any,Any] is unchecked since it is eliminated by erasure
case xs: Map[Any, Any] => xs.head // unchecked
diff --git a/test/files/neg/unchecked.scala b/test/files/neg/unchecked.scala
index b50cdf9d7a..e491b253ba 100644
--- a/test/files/neg/unchecked.scala
+++ b/test/files/neg/unchecked.scala
@@ -19,8 +19,8 @@ object Test {
case _ => 0
}
def f3(x: Any) = x match {
- case xs: Set[Any] => xs.head // unchecked
- case _ => 0
+ case xs: Set[Any] => xs.head // unchecked
+ case _ => 0
}
def f4(x: Any) = x match {
case xs: Map[Any, Any] => xs.head // unchecked
diff --git a/test/files/neg/unchecked2.check b/test/files/neg/unchecked2.check
index e37865928e..68fdfa82ac 100644
--- a/test/files/neg/unchecked2.check
+++ b/test/files/neg/unchecked2.check
@@ -1,19 +1,43 @@
-unchecked2.scala:2: error: non-variable type argument Int in type Option[Int] is unchecked since it is eliminated by erasure
- Some(123).isInstanceOf[Option[Int]]
- ^
-unchecked2.scala:3: error: non-variable type argument String in type Option[String] is unchecked since it is eliminated by erasure
- Some(123).isInstanceOf[Option[String]]
- ^
-unchecked2.scala:4: error: non-variable type argument List[String] in type Option[List[String]] is unchecked since it is eliminated by erasure
- Some(123).isInstanceOf[Option[List[String]]]
- ^
-unchecked2.scala:5: error: non-variable type argument List[Int => String] in type Option[List[Int => String]] is unchecked since it is eliminated by erasure
- Some(123).isInstanceOf[Option[List[Int => String]]]
- ^
-unchecked2.scala:6: error: non-variable type argument (String, Double) in type Option[(String, Double)] is unchecked since it is eliminated by erasure
- Some(123).isInstanceOf[Option[(String, Double)]]
- ^
-unchecked2.scala:7: error: non-variable type argument String => Double in type Option[String => Double] is unchecked since it is eliminated by erasure
- Some(123).isInstanceOf[Option[String => Double]]
- ^
-6 errors found
+unchecked2.scala:4: error: fruitless type test: a value of type Some[List[Int]] cannot also be a Option[List[String]] (but still might match its erasure)
+ /* warn */ Some(List(1)).isInstanceOf[Option[List[String]]]
+ ^
+unchecked2.scala:5: error: non-variable type argument Option[_] in type Option[Option[_]] is unchecked since it is eliminated by erasure
+ /* warn */ Some(123).isInstanceOf[Option[Option[_]]]
+ ^
+unchecked2.scala:6: error: fruitless type test: a value of type Some[Int] cannot also be a Option[String] (but still might match its erasure)
+ /* warn */ Some(123).isInstanceOf[Option[String]]
+ ^
+unchecked2.scala:7: error: fruitless type test: a value of type Some[Int] cannot also be a Option[List[String]] (but still might match its erasure)
+ /* warn */ Some(123).isInstanceOf[Option[List[String]]]
+ ^
+unchecked2.scala:8: error: fruitless type test: a value of type Some[Int] cannot also be a Option[List[Int => String]] (but still might match its erasure)
+ /* warn */ Some(123).isInstanceOf[Option[List[Int => String]]]
+ ^
+unchecked2.scala:9: error: fruitless type test: a value of type Some[Int] cannot also be a Option[(String, Double)] (but still might match its erasure)
+ /* warn */ Some(123).isInstanceOf[Option[(String, Double)]]
+ ^
+unchecked2.scala:10: error: fruitless type test: a value of type Some[Int] cannot also be a Option[String => Double] (but still might match its erasure)
+ /* warn */ Some(123).isInstanceOf[Option[String => Double]]
+ ^
+unchecked2.scala:14: error: non-variable type argument List[String] in type Option[List[String]] is unchecked since it is eliminated by erasure
+ /* warn */ (Some(List(1)): Any).isInstanceOf[Option[List[String]]]
+ ^
+unchecked2.scala:15: error: non-variable type argument Int in type Option[Int] is unchecked since it is eliminated by erasure
+ /* warn */ (Some(123): Any).isInstanceOf[Option[Int]]
+ ^
+unchecked2.scala:16: error: non-variable type argument String in type Option[String] is unchecked since it is eliminated by erasure
+ /* warn */ (Some(123): Any).isInstanceOf[Option[String]]
+ ^
+unchecked2.scala:17: error: non-variable type argument List[String] in type Option[List[String]] is unchecked since it is eliminated by erasure
+ /* warn */ (Some(123): Any).isInstanceOf[Option[List[String]]]
+ ^
+unchecked2.scala:18: error: non-variable type argument List[Int => String] in type Option[List[Int => String]] is unchecked since it is eliminated by erasure
+ /* warn */ (Some(123): Any).isInstanceOf[Option[List[Int => String]]]
+ ^
+unchecked2.scala:19: error: non-variable type argument (String, Double) in type Option[(String, Double)] is unchecked since it is eliminated by erasure
+ /* warn */ (Some(123): Any).isInstanceOf[Option[(String, Double)]]
+ ^
+unchecked2.scala:20: error: non-variable type argument String => Double in type Option[String => Double] is unchecked since it is eliminated by erasure
+ /* warn */ (Some(123): Any).isInstanceOf[Option[String => Double]]
+ ^
+14 errors found
diff --git a/test/files/neg/unchecked2.scala b/test/files/neg/unchecked2.scala
index a2e757e1dc..616b05aad8 100644
--- a/test/files/neg/unchecked2.scala
+++ b/test/files/neg/unchecked2.scala
@@ -1,8 +1,33 @@
object Test {
- Some(123).isInstanceOf[Option[Int]]
- Some(123).isInstanceOf[Option[String]]
- Some(123).isInstanceOf[Option[List[String]]]
- Some(123).isInstanceOf[Option[List[Int => String]]]
- Some(123).isInstanceOf[Option[(String, Double)]]
- Some(123).isInstanceOf[Option[String => Double]]
+ // These warn because it can be statically shown they won't match.
+
+ /* warn */ Some(List(1)).isInstanceOf[Option[List[String]]]
+ /* warn */ Some(123).isInstanceOf[Option[Option[_]]]
+ /* warn */ Some(123).isInstanceOf[Option[String]]
+ /* warn */ Some(123).isInstanceOf[Option[List[String]]]
+ /* warn */ Some(123).isInstanceOf[Option[List[Int => String]]]
+ /* warn */ Some(123).isInstanceOf[Option[(String, Double)]]
+ /* warn */ Some(123).isInstanceOf[Option[String => Double]]
+
+ // These warn because you can't check at runtime.
+
+ /* warn */ (Some(List(1)): Any).isInstanceOf[Option[List[String]]]
+ /* warn */ (Some(123): Any).isInstanceOf[Option[Int]]
+ /* warn */ (Some(123): Any).isInstanceOf[Option[String]]
+ /* warn */ (Some(123): Any).isInstanceOf[Option[List[String]]]
+ /* warn */ (Some(123): Any).isInstanceOf[Option[List[Int => String]]]
+ /* warn */ (Some(123): Any).isInstanceOf[Option[(String, Double)]]
+ /* warn */ (Some(123): Any).isInstanceOf[Option[String => Double]]
+
+ // These don't warn.
+
+ /* nowarn */ Some(List(1)).isInstanceOf[Option[List[Int]]]
+ /* nowarn */ Some(123).isInstanceOf[Option[Int]]
+ /* nowarn */ Some(123).isInstanceOf[Some[Int]]
+ /* nowarn */ Some(123).isInstanceOf[AnyRef]
+
+ /* nowarn */ (Some(List(1)): Any).isInstanceOf[Option[_]]
+ /* nowarn */ (Some(123): Any).isInstanceOf[Option[_]]
+ /* nowarn */ (Some(123): Any).isInstanceOf[Some[_]]
+ /* nowarn */ (Some(123): Any).isInstanceOf[AnyRef]
}
diff --git a/test/files/neg/unchecked3.check b/test/files/neg/unchecked3.check
new file mode 100644
index 0000000000..f4f0c74257
--- /dev/null
+++ b/test/files/neg/unchecked3.check
@@ -0,0 +1,37 @@
+unchecked3.scala:24: error: non-variable type argument Double in type pattern E1[Double] is unchecked since it is eliminated by erasure
+ /* warn */ def peerTypes2(x: B1[Int]) = x match { case _: E1[Double] => true }
+ ^
+unchecked3.scala:25: error: non-variable type argument Double in type pattern F1[Double] is unchecked since it is eliminated by erasure
+ /* warn */ def peerTypes3(x: B1[_]) = x match { case _: F1[Double] => true }
+ ^
+unchecked3.scala:28: error: non-variable type argument Int in type pattern A2[Int] is unchecked since it is eliminated by erasure
+ /* warn */ def twotypes1[T](x: B2[T, Int]) = x match { case _: A2[Int] => true }
+ ^
+unchecked3.scala:32: error: non-variable type argument Int in type pattern B2[_,Int] is unchecked since it is eliminated by erasure
+ /* warn */ def twotypes5[T](x: A2[T]) = x match { case _: B2[_, Int] => true }
+ ^
+unchecked3.scala:40: error: non-variable type argument String in type pattern Array[List[String]] is unchecked since it is eliminated by erasure
+ /* warn */ case _: Array[List[String]] => ()
+ ^
+unchecked3.scala:43: error: non-variable type argument String in type pattern Array[Array[List[String]]] is unchecked since it is eliminated by erasure
+ /* warn */ case _: Array[Array[List[String]]] => ()
+ ^
+unchecked3.scala:50: error: non-variable type argument String in type pattern Array[List[String]] is unchecked since it is eliminated by erasure
+ /* warn */ case _: Array[List[String]] => ()
+ ^
+unchecked3.scala:53: error: non-variable type argument String in type pattern Array[Array[List[String]]] is unchecked since it is eliminated by erasure
+ /* warn */ case _: Array[Array[List[String]]] => ()
+ ^
+unchecked3.scala:60: error: non-variable type argument String in type pattern Array[List[String]] is unchecked since it is eliminated by erasure
+ /* warn */ case _: Array[List[String]] => ()
+ ^
+unchecked3.scala:62: error: non-variable type argument Array[String] in type pattern Array[List[Array[String]]] is unchecked since it is eliminated by erasure
+ /* warn */ case _: Array[List[Array[String]]] => ()
+ ^
+unchecked3.scala:63: error: non-variable type argument String in type pattern Array[Array[List[String]]] is unchecked since it is eliminated by erasure
+ /* warn */ case _: Array[Array[List[String]]] => ()
+ ^
+unchecked3.scala:75: error: abstract type A in type pattern Set[Q.this.A] is unchecked since it is eliminated by erasure
+ /* warn */ case xs: Set[A] => xs.head
+ ^
+12 errors found
diff --git a/test/files/neg/unchecked3.flags b/test/files/neg/unchecked3.flags
new file mode 100644
index 0000000000..85d8eb2ba2
--- /dev/null
+++ b/test/files/neg/unchecked3.flags
@@ -0,0 +1 @@
+-Xfatal-warnings
diff --git a/test/files/neg/unchecked3.scala b/test/files/neg/unchecked3.scala
new file mode 100644
index 0000000000..7b8c13e8f8
--- /dev/null
+++ b/test/files/neg/unchecked3.scala
@@ -0,0 +1,83 @@
+sealed trait A2[T1]
+final class B2[T1, T2] extends A2[T1]
+
+sealed trait A[T]
+final class B[T] extends A[T]
+
+sealed trait A1[T]
+trait B1[T] extends A1[T]
+trait C1[T] extends A1[T]
+trait D1[T] extends A1[Int]
+trait E1[T] extends B1[Int]
+trait F1[T] extends B1[T]
+
+object MiscUnchecked {
+ /* nowarn */ def knownType1(x: A[Int]) = x match { case _: B[Int] if true => 1 }
+ /* nowarn */ def knownType2(x: B[Int]) = x match { case _: A[Int] if true => 1 }
+ /* nowarn */ def tparamLeakage1(x: Any) = x match { case Array() => 1 }
+ /* nowarn */ def tparamLeakage2(x: Any) = x match { case List() => 1 }
+
+ // E1[Double] implies B1[Int], but B1[Int] does not imply E1[Double], even if .isInstanceOf[E1[_]]
+ // F1[Int] implies B1[Int], and B1[Int] implies F1[Int]
+
+ /* nowarn */ def peerTypes1(x: B1[Int]) = x match { case _: C1[Int] => true }
+ /* warn */ def peerTypes2(x: B1[Int]) = x match { case _: E1[Double] => true }
+ /* warn */ def peerTypes3(x: B1[_]) = x match { case _: F1[Double] => true }
+ /* nowarn */ def peerTypes4(x: B1[Int]) = x match { case _: F1[Int] => true }
+
+ /* warn */ def twotypes1[T](x: B2[T, Int]) = x match { case _: A2[Int] => true }
+ /* nowarn */ def twotypes2[T](x: B2[Int, T]) = x match { case _: A2[Int] => true }
+ /* nowarn */ def twotypes3(x: A2[Int]) = x match { case _: B2[Int, _] => true }
+ /* nowarn */ def twotypes4[T](x: A2[T]) = x match { case _: B2[T, _] => true }
+ /* warn */ def twotypes5[T](x: A2[T]) = x match { case _: B2[_, Int] => true }
+}
+
+object Arrays {
+ def f1(x: Any) = x match {
+ /* nowarn */ case _: Array[Int] => ()
+ /* nowarn */ case _: Array[Boolean] => ()
+ /* nowarn */ case _: Array[String] => ()
+ /* warn */ case _: Array[List[String]] => ()
+ /* nowarn */ case _: Array[Array[String]] => ()
+ /* nowarn */ case _: Array[Array[Array[String]]] => ()
+ /* warn */ case _: Array[Array[List[String]]] => ()
+ }
+
+ def f2(x: Array[_]) = x match {
+ /* nowarn */ case _: Array[Int] => ()
+ /* nowarn */ case _: Array[Boolean] => ()
+ /* nowarn */ case _: Array[String] => ()
+ /* warn */ case _: Array[List[String]] => ()
+ /* nowarn */ case _: Array[Array[String]] => ()
+ /* nowarn */ case _: Array[Array[Array[String]]] => ()
+ /* warn */ case _: Array[Array[List[String]]] => ()
+ }
+
+ def f3[T](x: Array[T]) = x match {
+ /* nowarn */ case _: Array[Int] => ()
+ /* nowarn */ case _: Array[Boolean] => ()
+ /* nowarn */ case _: Array[String] => ()
+ /* warn */ case _: Array[List[String]] => ()
+ /* nowarn */ case _: Array[Array[String]] => ()
+ /* warn */ case _: Array[List[Array[String]]] => ()
+ /* warn */ case _: Array[Array[List[String]]] => ()
+ }
+}
+
+object Matching {
+ class Q {
+ type A
+ type B <: A
+
+ def f(xs: Traversable[B]) = xs match {
+ /* nowarn */ case xs: List[A] => xs.head
+ /* nowarn */ case xs: Seq[B] => xs.head
+ /* warn */ case xs: Set[A] => xs.head
+ }
+ def f2[T <: B](xs: Traversable[T]) = xs match {
+ /* nowarn */ case xs: List[B with T] => xs.head
+ /* nowarn */ case xs: Seq[A] => xs.head
+ /* nowarn */ case xs: Set[T] => xs.head
+ }
+ }
+}
diff --git a/test/files/pos/t1107/O.scala b/test/files/pos/t1107b/O.scala
index aa605a6d09..aa605a6d09 100644
--- a/test/files/pos/t1107/O.scala
+++ b/test/files/pos/t1107b/O.scala
diff --git a/test/files/pos/t1107/T.scala b/test/files/pos/t1107b/T.scala
index 1f3712d529..1f3712d529 100644
--- a/test/files/pos/t1107/T.scala
+++ b/test/files/pos/t1107b/T.scala
diff --git a/test/files/pos/t1203/J.java b/test/files/pos/t1203b/J.java
index 7fae118e04..7fae118e04 100644
--- a/test/files/pos/t1203/J.java
+++ b/test/files/pos/t1203b/J.java
diff --git a/test/files/pos/t1203/S.scala b/test/files/pos/t1203b/S.scala
index 68eac4bf6d..68eac4bf6d 100644
--- a/test/files/pos/t1203/S.scala
+++ b/test/files/pos/t1203b/S.scala
diff --git a/test/files/pos/t6275.flags b/test/files/pos/t6275.flags
new file mode 100644
index 0000000000..85d8eb2ba2
--- /dev/null
+++ b/test/files/pos/t6275.flags
@@ -0,0 +1 @@
+-Xfatal-warnings
diff --git a/test/files/pos/t6275.scala b/test/files/pos/t6275.scala
new file mode 100644
index 0000000000..6b5ec7dceb
--- /dev/null
+++ b/test/files/pos/t6275.scala
@@ -0,0 +1,11 @@
+
+sealed trait A[T]
+final class B[T] extends A[T]
+
+object ParsedAxis {
+ type BI = B[Int]
+
+ def f1(a: A[Int]) = a match { case b: B[Int] => 3 }
+ def f2(a: A[Int]) = a match { case b: BI => 3 }
+ def f3(a: A[Int]) = a match { case b: B[t] => 3 }
+}
diff --git a/test/files/run/existentials3-new.check b/test/files/run/existentials3-new.check
index bb6fe1a5e3..00614b19db 100644
--- a/test/files/run/existentials3-new.check
+++ b/test/files/run/existentials3-new.check
@@ -3,8 +3,8 @@ Bar, t=TypeRef, s=type Bar
Test.ToS, t=RefinedType, s=f3
Test.ToS, t=RefinedType, s=f4
Test.ToS, t=RefinedType, s=f5
-() => Test.ToS, t=TypeRef, s=class Function0
-() => Test.ToS, t=TypeRef, s=class Function0
+() => Test.ToS, t=TypeRef, s=trait Function0
+() => Test.ToS, t=TypeRef, s=trait Function0
$anon, t=TypeRef, s=type $anon
$anon, t=TypeRef, s=type $anon
List[java.lang.Object{type T1}#T1], t=TypeRef, s=class List
@@ -15,8 +15,8 @@ Bar, t=TypeRef, s=type Bar
Test.ToS, t=RefinedType, s=g3
Test.ToS, t=RefinedType, s=g4
Test.ToS, t=RefinedType, s=g5
-() => Test.ToS, t=TypeRef, s=class Function0
-() => Test.ToS, t=TypeRef, s=class Function0
+() => Test.ToS, t=TypeRef, s=trait Function0
+() => Test.ToS, t=TypeRef, s=trait Function0
$anon, t=TypeRef, s=type $anon
$anon, t=TypeRef, s=type $anon
List[java.lang.Object{type T1}#T1], t=TypeRef, s=class List
diff --git a/test/files/run/macro-openmacros/Impls_Macros_1.scala b/test/files/run/macro-openmacros/Impls_Macros_1.scala
index 38d46c5185..b863ac048b 100644
--- a/test/files/run/macro-openmacros/Impls_Macros_1.scala
+++ b/test/files/run/macro-openmacros/Impls_Macros_1.scala
@@ -4,8 +4,7 @@ object Macros {
def impl(c: Context): c.Expr[Unit] = {
// we're macros, so we can reflect against our source path
// so we don't need any partests to clean up after us!
- val c.CompilationUnit(file, _, _) = c.enclosingUnit
- val dir = file.getCanonicalFile.getParentFile
+ val dir = c.enclosingUnit.source.file.file.getCanonicalFile.getParentFile
def normalizePaths(s: String) = {
val base = (dir.getCanonicalPath + java.io.File.separator).replace('\\', '/')
var regex = """\Q%s\E""" format base
diff --git a/test/files/run/macro-reify-nested-a/Impls_Macros_1.scala b/test/files/run/macro-reify-nested-a/Impls_Macros_1.scala
index ae2def2d3e..b4351c2c53 100644
--- a/test/files/run/macro-reify-nested-a/Impls_Macros_1.scala
+++ b/test/files/run/macro-reify-nested-a/Impls_Macros_1.scala
@@ -23,9 +23,10 @@ case class Utils[C <: Context]( c:C ) {
object QueryableMacros{
def _helper[C <: Context,S:c.WeakTypeTag]( c:C )( name:String, projection:c.Expr[_] ) = {
import c.universe._
+ import treeBuild._
val element_type = implicitly[c.WeakTypeTag[S]].tpe
val foo = c.Expr[ru.Expr[Queryable[S]]](
- c.reifyTree( c.runtimeUniverse, EmptyTree, c.typeCheck(
+ c.reifyTree( mkRuntimeUniverseRef, EmptyTree, c.typeCheck(
Utils[c.type](c).removeDoubleReify(
Apply(Select(c.prefix.tree, newTermName( name )), List( projection.tree ))
).asInstanceOf[Tree]
diff --git a/test/files/run/macro-reify-nested-b/Impls_Macros_1.scala b/test/files/run/macro-reify-nested-b/Impls_Macros_1.scala
index ae2def2d3e..b4351c2c53 100644
--- a/test/files/run/macro-reify-nested-b/Impls_Macros_1.scala
+++ b/test/files/run/macro-reify-nested-b/Impls_Macros_1.scala
@@ -23,9 +23,10 @@ case class Utils[C <: Context]( c:C ) {
object QueryableMacros{
def _helper[C <: Context,S:c.WeakTypeTag]( c:C )( name:String, projection:c.Expr[_] ) = {
import c.universe._
+ import treeBuild._
val element_type = implicitly[c.WeakTypeTag[S]].tpe
val foo = c.Expr[ru.Expr[Queryable[S]]](
- c.reifyTree( c.runtimeUniverse, EmptyTree, c.typeCheck(
+ c.reifyTree( mkRuntimeUniverseRef, EmptyTree, c.typeCheck(
Utils[c.type](c).removeDoubleReify(
Apply(Select(c.prefix.tree, newTermName( name )), List( projection.tree ))
).asInstanceOf[Tree]
diff --git a/test/files/run/macro-reify-splice-outside-reify/Impls_Macros_1.scala b/test/files/run/macro-reify-splice-outside-reify/Impls_Macros_1.scala
index b23a5c70e1..5330d0e32b 100644
--- a/test/files/run/macro-reify-splice-outside-reify/Impls_Macros_1.scala
+++ b/test/files/run/macro-reify-splice-outside-reify/Impls_Macros_1.scala
@@ -4,18 +4,7 @@ object Impls {
def foo(c: Ctx)(x: c.Expr[Int]) = {
val x1 = c.Expr[Int](c.resetAllAttrs(x.tree))
// was: c.literal(x1.splice)
- c.literal(eval(c)(x1))
- }
-
- private def eval[T](c: Ctx)(x: c.Expr[T]): T = {
- import scala.reflect.runtime.{universe => ru}
- val mirror = ru.runtimeMirror(c.libraryClassLoader)
- import scala.tools.reflect.ToolBox
- val toolBox = mirror.mkToolBox()
- val importer = ru.mkImporter(c.universe).asInstanceOf[ru.Importer { val from: c.universe.type }]
- val tree = c.resetAllAttrs(x.tree.duplicate)
- val imported = importer.importTree(tree)
- toolBox.eval(imported).asInstanceOf[T]
+ c.literal(c.eval(x1))
}
}
diff --git a/test/files/run/macro-reify-unreify/Macros_1.scala b/test/files/run/macro-reify-unreify/Macros_1.scala
index 620a929210..9f04c13014 100644
--- a/test/files/run/macro-reify-unreify/Macros_1.scala
+++ b/test/files/run/macro-reify-unreify/Macros_1.scala
@@ -6,9 +6,10 @@ object Macros {
object Impls {
def foo(c: Ctx)(s: c.Expr[String]) = {
import c.universe._
+ import treeBuild._
- val world = c.reifyTree(c.runtimeUniverse, EmptyTree, s.tree)
- val greeting = c.reifyTree(c.runtimeUniverse, EmptyTree, c.typeCheck(Apply(Select(Literal(Constant("hello ")), newTermName("$plus")), List(c.unreifyTree(world)))))
+ val world = c.reifyTree(mkRuntimeUniverseRef, EmptyTree, s.tree)
+ val greeting = c.reifyTree(mkRuntimeUniverseRef, EmptyTree, c.typeCheck(Apply(Select(Literal(Constant("hello ")), newTermName("$plus")), List(c.unreifyTree(world)))))
val typedGreeting = c.Expr[String](greeting)
c.universe.reify {
diff --git a/test/files/run/macro-sip19-revised/Impls_Macros_1.scala b/test/files/run/macro-sip19-revised/Impls_Macros_1.scala
index 0793696fd4..5f3f61ca3f 100644
--- a/test/files/run/macro-sip19-revised/Impls_Macros_1.scala
+++ b/test/files/run/macro-sip19-revised/Impls_Macros_1.scala
@@ -8,7 +8,7 @@ object Macros {
val outer = c.Expr[SourceLocation](if (!inscope.isEmpty) inscope else Literal(Constant(null)))
val Apply(fun, args) = c.enclosingImplicits(0)._2
- val fileName = fun.pos.fileInfo.getName
+ val fileName = fun.pos.source.file.file.getName
val line = fun.pos.line
val charOffset = fun.pos.point
c.universe.reify { SourceLocation1(outer.splice, c.literal(fileName).splice, c.literal(line).splice, c.literal(charOffset).splice) }
diff --git a/test/files/run/macro-sip19/Impls_Macros_1.scala b/test/files/run/macro-sip19/Impls_Macros_1.scala
index f89e51f560..535ec2ccf0 100644
--- a/test/files/run/macro-sip19/Impls_Macros_1.scala
+++ b/test/files/run/macro-sip19/Impls_Macros_1.scala
@@ -4,7 +4,7 @@ object Macros {
def impl(c: Context) = {
import c.universe._
val Apply(fun, args) = c.enclosingImplicits(0)._2
- val fileName = fun.pos.fileInfo.getName
+ val fileName = fun.pos.source.file.file.getName
val line = fun.pos.line
val charOffset = fun.pos.point
c.universe.reify { SourceLocation(c.literal(fileName).splice, c.literal(line).splice, c.literal(charOffset).splice) }
diff --git a/test/files/run/macro-typecheck-macrosdisabled.check b/test/files/run/macro-typecheck-macrosdisabled.check
index 719c6a2ef2..29a881f8b1 100644
--- a/test/files/run/macro-typecheck-macrosdisabled.check
+++ b/test/files/run/macro-typecheck-macrosdisabled.check
@@ -7,7 +7,7 @@
$treecreator1.super.<init>();
()
};
- def apply[U >: Nothing <: scala.reflect.api.Universe with Singleton]($m$untyped: scala.reflect.api.MirrorOf[U]): U#Tree = {
+ def apply[U >: Nothing <: scala.reflect.api.Universe with Singleton]($m$untyped: scala.reflect.api.Mirror[U]): U#Tree = {
val $u: U = $m$untyped.universe;
val $m: $u.Mirror = $m$untyped.asInstanceOf[$u.Mirror];
$u.Literal.apply($u.Constant.apply(2))
@@ -20,7 +20,7 @@
$typecreator2.super.<init>();
()
};
- def apply[U >: Nothing <: scala.reflect.api.Universe with Singleton]($m$untyped: scala.reflect.api.MirrorOf[U]): U#Type = {
+ def apply[U >: Nothing <: scala.reflect.api.Universe with Singleton]($m$untyped: scala.reflect.api.Mirror[U]): U#Type = {
val $u: U = $m$untyped.universe;
val $m: $u.Mirror = $m$untyped.asInstanceOf[$u.Mirror];
$u.ConstantType.apply($u.Constant.apply(2))
diff --git a/test/files/run/macro-typecheck-macrosdisabled2.check b/test/files/run/macro-typecheck-macrosdisabled2.check
index 1fd422083c..7bdd1d6a3a 100644
--- a/test/files/run/macro-typecheck-macrosdisabled2.check
+++ b/test/files/run/macro-typecheck-macrosdisabled2.check
@@ -7,7 +7,7 @@
$treecreator1.super.<init>();
()
};
- def apply[U >: Nothing <: scala.reflect.api.Universe with Singleton]($m$untyped: scala.reflect.api.MirrorOf[U]): U#Tree = {
+ def apply[U >: Nothing <: scala.reflect.api.Universe with Singleton]($m$untyped: scala.reflect.api.Mirror[U]): U#Tree = {
val $u: U = $m$untyped.universe;
val $m: $u.Mirror = $m$untyped.asInstanceOf[$u.Mirror];
$u.Apply.apply($u.Select.apply($u.Select.apply($u.build.Ident($m.staticPackage("scala")), $u.newTermName("Array")), $u.newTermName("apply")), scala.collection.immutable.List.apply[$u.Literal]($u.Literal.apply($u.Constant.apply(2))))
@@ -20,7 +20,7 @@
$typecreator2.super.<init>();
()
};
- def apply[U >: Nothing <: scala.reflect.api.Universe with Singleton]($m$untyped: scala.reflect.api.MirrorOf[U]): U#Type = {
+ def apply[U >: Nothing <: scala.reflect.api.Universe with Singleton]($m$untyped: scala.reflect.api.Mirror[U]): U#Type = {
val $u: U = $m$untyped.universe;
val $m: $u.Mirror = $m$untyped.asInstanceOf[$u.Mirror];
$u.TypeRef.apply($u.ThisType.apply($m.staticPackage("scala").asModule.moduleClass), $m.staticClass("scala.Array"), scala.collection.immutable.List.apply[$u.Type]($m.staticClass("scala.Int").asType.toTypeConstructor))
diff --git a/test/files/run/reflection-java-annotations.scala b/test/files/run/reflection-java-annotations.scala
index 0b16c0d103..2e3fed48ce 100644
--- a/test/files/run/reflection-java-annotations.scala
+++ b/test/files/run/reflection-java-annotations.scala
@@ -2,6 +2,6 @@ object Test extends App {
import scala.reflect.runtime.universe._
val sym = typeOf[JavaAnnottee].typeSymbol
sym.typeSignature
- sym.getAnnotations foreach (_.javaArgs)
- println(sym.getAnnotations)
+ sym.annotations foreach (_.javaArgs)
+ println(sym.annotations)
} \ No newline at end of file
diff --git a/test/files/run/reflection-magicsymbols-invoke.check b/test/files/run/reflection-magicsymbols-invoke.check
index 520dc2bfbe..f5258efeb7 100644
--- a/test/files/run/reflection-magicsymbols-invoke.check
+++ b/test/files/run/reflection-magicsymbols-invoke.check
@@ -90,7 +90,7 @@ method $asInstanceOf: [T0]()T0
method $isInstanceOf: [T0]()Boolean
method ==: (x$1: Any)Boolean
method ==: (x$1: AnyRef)Boolean
-method apply: (i: <?>)T
+method apply: (i: Int)T
method asInstanceOf: [T0]=> T0
method clone: ()Array[T]
method eq: (x$1: AnyRef)Boolean
@@ -105,7 +105,7 @@ method notify: ()Unit
method notifyAll: ()Unit
method synchronized: [T0](x$1: T0)T0
method toString: ()java.lang.String
-method update: (i: <?>, x: <?>)Unit
+method update: (i: Int, x: T)Unit
method wait: ()Unit
method wait: (x$1: Long)Unit
method wait: (x$1: Long, x$2: Int)Unit
diff --git a/test/files/run/reflection-mem-typecheck.scala b/test/files/run/reflection-mem-typecheck.scala
new file mode 100644
index 0000000000..a312c2c893
--- /dev/null
+++ b/test/files/run/reflection-mem-typecheck.scala
@@ -0,0 +1,26 @@
+import scala.tools.partest.MemoryTest
+
+trait A { type T <: A }
+trait B { type T <: B }
+
+object Test extends MemoryTest {
+ lazy val tb = {
+ import scala.reflect.runtime.universe._
+ import scala.reflect.runtime.{currentMirror => cm}
+ import scala.tools.reflect.ToolBox
+ cm.mkToolBox()
+ }
+
+ override def maxDelta = 10
+ override def calcsPerIter = 8
+ override def calc() {
+ var snippet = """
+ trait A { type T <: A }
+ trait B { type T <: B }
+ def foo[T](x: List[T]) = x
+ foo(List(new A {}, new B {}))
+ """.trim
+ snippet = snippet + "\n" + (List.fill(50)(snippet.split("\n").last) mkString "\n")
+ tb.typeCheck(tb.parse(snippet))
+ }
+} \ No newline at end of file
diff --git a/test/files/run/reify_ann1a.scala b/test/files/run/reify_ann1a.scala
index 88b4191195..c23048e463 100644
--- a/test/files/run/reify_ann1a.scala
+++ b/test/files/run/reify_ann1a.scala
@@ -21,7 +21,6 @@ object Test extends App {
// test 2: import and typecheck
val toolbox = cm.mkToolBox()
val ttree = toolbox.typeCheck(tree)
- ttree.foreach(sub => if (sub.hasSymbol) sub.symbol.typeSignature)
println(ttree.toString)
// test 3: import and compile
diff --git a/test/files/run/reify_ann1b.scala b/test/files/run/reify_ann1b.scala
index a8fb876023..29ce6021a2 100644
--- a/test/files/run/reify_ann1b.scala
+++ b/test/files/run/reify_ann1b.scala
@@ -21,7 +21,6 @@ object Test extends App {
// test 2: import and typecheck
val toolbox = cm.mkToolBox()
val ttree = toolbox.typeCheck(tree)
- ttree.foreach(sub => if (sub.hasSymbol) sub.symbol.typeSignature)
println(ttree.toString)
// test 3: import and compile
diff --git a/test/files/run/reify_ann2a.scala b/test/files/run/reify_ann2a.scala
index b7e5833584..53423e12c3 100644
--- a/test/files/run/reify_ann2a.scala
+++ b/test/files/run/reify_ann2a.scala
@@ -21,7 +21,6 @@ object Test extends App {
// test 2: import and typecheck
val toolbox = cm.mkToolBox()
val ttree = toolbox.typeCheck(tree)
- ttree.foreach(sub => if (sub.hasSymbol) sub.symbol.typeSignature)
println(ttree.toString)
// test 3: import and compile
diff --git a/test/files/run/reify_ann3.scala b/test/files/run/reify_ann3.scala
index 662d58aaf3..4162fa532f 100644
--- a/test/files/run/reify_ann3.scala
+++ b/test/files/run/reify_ann3.scala
@@ -15,7 +15,6 @@ object Test extends App {
// test 2: import and typecheck
val toolbox = cm.mkToolBox()
val ttree = toolbox.typeCheck(tree)
- ttree.foreach(sub => if (sub.hasSymbol) sub.symbol.typeSignature)
println(ttree.toString)
// test 3: import and compile
diff --git a/test/files/run/reify_ann4.scala b/test/files/run/reify_ann4.scala
index a85e5e3625..0aedb77b5e 100644
--- a/test/files/run/reify_ann4.scala
+++ b/test/files/run/reify_ann4.scala
@@ -19,7 +19,6 @@ object Test extends App {
// test 2: import and typecheck
val toolbox = cm.mkToolBox()
val ttree = toolbox.typeCheck(tree)
- ttree.foreach(sub => if (sub.hasSymbol) sub.symbol.typeSignature)
println(ttree.toString)
// test 3: import and compile
diff --git a/test/files/run/reify_ann5.scala b/test/files/run/reify_ann5.scala
index 877360180c..d27be3b6d5 100644
--- a/test/files/run/reify_ann5.scala
+++ b/test/files/run/reify_ann5.scala
@@ -16,7 +16,6 @@ object Test extends App {
// test 2: import and typecheck
val toolbox = cm.mkToolBox()
val ttree = toolbox.typeCheck(tree)
- ttree.foreach(sub => if (sub.hasSymbol) sub.symbol.typeSignature)
println(ttree.toString)
// test 3: import and compile
diff --git a/test/files/run/t5423.scala b/test/files/run/t5423.scala
index 9b8ba090fa..c1632126b2 100644
--- a/test/files/run/t5423.scala
+++ b/test/files/run/t5423.scala
@@ -7,5 +7,5 @@ final class table extends annotation.StaticAnnotation
object Test extends App {
val s = cm.classSymbol(classOf[A])
- println(s.getAnnotations)
+ println(s.annotations)
} \ No newline at end of file
diff --git a/test/files/run/t576.scala b/test/files/run/t576.scala
index dc09d8dc98..756a241572 100644
--- a/test/files/run/t576.scala
+++ b/test/files/run/t576.scala
@@ -12,7 +12,7 @@ object Dingus {
object Test {
val x1 = new A
val x2 = new A
-
+
val x3 = new { self =>
override def equals(other : Any) = other match {
case that: self.type => true
@@ -20,7 +20,7 @@ object Test {
}
}
val x4 = new { self =>
- def f(x: Any) = x match {
+ def f(x: Any): Int = x match {
case _: x1.type => 1
case _: x2.type => 2
case _: x3.type => 3
@@ -35,11 +35,11 @@ object Test {
assert(x1 != x2)
assert(x1 != ())
assert(x2 != x1)
-
+
assert(x3 == x3)
assert(x3 != x2)
assert(x2 != x3)
-
+
List(x1, x2, x3, x4, Dingus) map x4.f foreach println
}
-} \ No newline at end of file
+}
diff --git a/test/files/run/t6277.check b/test/files/run/t6277.check
new file mode 100644
index 0000000000..f32a5804e2
--- /dev/null
+++ b/test/files/run/t6277.check
@@ -0,0 +1 @@
+true \ No newline at end of file
diff --git a/test/files/run/t6277.scala b/test/files/run/t6277.scala
new file mode 100644
index 0000000000..41feee8a8a
--- /dev/null
+++ b/test/files/run/t6277.scala
@@ -0,0 +1,9 @@
+import scala.reflect.runtime.universe._
+
+object Test extends App {
+ locally {
+ val sym = typeOf[List[_]].typeSymbol.asClass
+ val q = sym.isSealed
+ println(q)
+ }
+} \ No newline at end of file
diff --git a/test/files/run/t6344.check b/test/files/run/t6344.check
new file mode 100644
index 0000000000..5ac04d0320
--- /dev/null
+++ b/test/files/run/t6344.check
@@ -0,0 +1,132 @@
+C0
+public int C0.v1(int)
+public <A> int C0.v1(int)
+public int C0.v3()
+public <A> int C0.v3()
+public int C0.v4(int,scala.collection.immutable.List)
+public <A> int C0.v4(int,scala.collection.immutable.List<Val<A>>)
+public scala.collection.immutable.List C0.v2()
+public <A> scala.collection.immutable.List<Val<A>> C0.v2()
+
+C1
+public java.lang.Object C1.v1(java.lang.Object)
+public <A> java.lang.Object C1.v1(java.lang.Object)
+public java.lang.Object C1.v3()
+public <A> java.lang.Object C1.v3()
+public java.lang.Object C1.v4(java.lang.Object,scala.collection.immutable.List)
+public <A> java.lang.Object C1.v4(java.lang.Object,scala.collection.immutable.List<java.lang.Object>)
+public scala.collection.immutable.List C1.v2()
+public <A> scala.collection.immutable.List<java.lang.Object> C1.v2()
+
+C2
+public java.lang.String C2.v1(java.lang.String)
+public <A> java.lang.String C2.v1(java.lang.String)
+public java.lang.String C2.v3()
+public <A> java.lang.String C2.v3()
+public java.lang.String C2.v4(java.lang.String,scala.collection.immutable.List)
+public <A> java.lang.String C2.v4(java.lang.String,scala.collection.immutable.List<java.lang.String>)
+public scala.collection.immutable.List C2.v2()
+public <A> scala.collection.immutable.List<java.lang.String> C2.v2()
+
+C3
+public java.lang.Object C3.v1(java.lang.Object)
+public A C3.v1(A)
+public java.lang.Object C3.v3()
+public A C3.v3()
+public java.lang.Object C3.v4(java.lang.Object,scala.collection.immutable.List)
+public A C3.v4(A,scala.collection.immutable.List<A>)
+public java.lang.Object C3.x()
+public A C3.x()
+public scala.collection.immutable.List C3.v2()
+public scala.collection.immutable.List<A> C3.v2()
+
+C4
+public java.lang.Integer C4.v1(java.lang.Integer)
+public int C4.v1(int)
+public java.lang.Integer C4.v3()
+public int C4.v3()
+public java.lang.Integer C4.v4(java.lang.Integer,scala.collection.immutable.List)
+public int C4.v4(int,scala.collection.immutable.List<ValA<java.lang.Object>>)
+public scala.collection.immutable.List C4.v2()
+public scala.collection.immutable.List<ValA<java.lang.Object>> C4.v2()
+
+C4B
+public java.lang.String C4B.v1(java.lang.String)
+public java.lang.String C4B.v1(java.lang.String)
+public java.lang.String C4B.v3()
+public java.lang.String C4B.v3()
+public java.lang.String C4B.v4(java.lang.String,scala.collection.immutable.List)
+public java.lang.String C4B.v4(java.lang.String,scala.collection.immutable.List<java.lang.String>)
+public scala.collection.immutable.List C4B.v2()
+public scala.collection.immutable.List<java.lang.String> C4B.v2()
+
+C5
+public double C5.f2(int,java.lang.Object,java.lang.String,double)
+public double C5.f2(int,java.lang.Object,java.lang.String,double)
+public int C5.f3(java.lang.Integer)
+public int C5.f3(int)
+public int C5.f4(java.lang.Integer)
+public int C5.f4(int)
+public int C5.f5(java.lang.Integer)
+public int C5.f5(int)
+public java.lang.Object C5.f1(int,java.lang.Object,java.lang.String,java.lang.Object)
+public <A> A C5.f1(int,java.lang.Object,java.lang.String,A)
+
+C6
+public java.lang.Object C6.f1(int,java.lang.Object,java.lang.String,java.lang.Object)
+public A C6.f1(int,java.lang.Object,java.lang.String,A)
+
+C7
+public java.lang.Integer C7.f1(int,java.lang.Object,java.lang.String,java.lang.Integer)
+public int C7.f1(int,java.lang.Object,java.lang.String,int)
+public java.lang.Object C7.f1(int,java.lang.Object,java.lang.String,java.lang.Object)
+public java.lang.Object C7.f1(int,java.lang.Object,java.lang.String,java.lang.Object)
+
+Gen
+public abstract Gen Gen.plus(Gen,Gen)
+public abstract Gen<A> Gen.plus(Gen<A>,Gen<A>)
+public abstract java.lang.Object Gen.x()
+public abstract A Gen.x()
+
+ValueInt
+public Gen ValueInt.plus(Gen,Gen)
+public Gen<java.lang.Object> ValueInt.plus(Gen<java.lang.Object>,Gen<java.lang.Object>)
+public boolean ValueInt.equals(java.lang.Object)
+public boolean ValueInt.equals(java.lang.Object)
+public int ValueInt.hashCode()
+public int ValueInt.hashCode()
+public int ValueInt.iplus(int,int)
+public int ValueInt.iplus(int,int)
+public int ValueInt.x()
+public int ValueInt.x()
+public java.lang.Object ValueInt.x()
+public java.lang.Object ValueInt.x()
+public static Gen ValueInt.extension$plus(int,Gen,Gen)
+public static Gen<java.lang.Object> ValueInt.extension$plus(int,Gen<java.lang.Object>,Gen<java.lang.Object>)
+public static boolean ValueInt.extension$equals(int,java.lang.Object)
+public static boolean ValueInt.extension$equals(int,java.lang.Object)
+public static int ValueInt.extension$hashCode(int)
+public static int ValueInt.extension$hashCode(int)
+public static int ValueInt.extension$iplus(int,int,int)
+public static int ValueInt.extension$iplus(int,int,int)
+
+RefInt
+public Gen RefInt.plus(Gen,Gen)
+public Gen<java.lang.Object> RefInt.plus(Gen<java.lang.Object>,Gen<java.lang.Object>)
+public RefInt RefInt.rplus(RefInt,RefInt)
+public RefInt RefInt.rplus(RefInt,RefInt)
+public int RefInt.x()
+public int RefInt.x()
+public java.lang.Object RefInt.x()
+public java.lang.Object RefInt.x()
+
+RefInteger
+public Gen RefInteger.plus(Gen,Gen)
+public Gen<java.lang.Integer> RefInteger.plus(Gen<java.lang.Integer>,Gen<java.lang.Integer>)
+public RefInteger RefInteger.bplus(RefInteger,RefInteger)
+public RefInteger RefInteger.bplus(RefInteger,RefInteger)
+public java.lang.Integer RefInteger.x()
+public java.lang.Integer RefInteger.x()
+public java.lang.Object RefInteger.x()
+public java.lang.Object RefInteger.x()
+
diff --git a/test/files/run/t6344.scala b/test/files/run/t6344.scala
new file mode 100644
index 0000000000..6f82e4ba51
--- /dev/null
+++ b/test/files/run/t6344.scala
@@ -0,0 +1,106 @@
+import scala.reflect.{ClassTag, classTag}
+import java.lang.Integer
+
+trait Gen[A] extends Any {
+ def x: A
+ def plus(x1: Gen[A], x2: Gen[A]): Gen[A]
+}
+class ValueInt(val x: Int) extends AnyVal with Gen[Int] {
+ // Gen<java.lang.Object> ValueInt.extension$plus(int,Gen<java.lang.Object>,Gen<java.lang.Object>)
+ def plus(x1: Gen[Int], x2: Gen[Int]): Gen[Int] = new ValueInt(x + x1.x + x2.x)
+ // int ValueInt.extension$iplus(int,int,int)
+ def iplus(x1: ValueInt, x2: ValueInt): ValueInt = new ValueInt(x + x1.x + x2.x)
+}
+class RefInt(val x: Int) extends AnyRef with Gen[Int] {
+ def plus(x1: Gen[Int], x2: Gen[Int]): Gen[Int] = new RefInt(x + x1.x + x2.x)
+ def rplus(x1: RefInt, x2: RefInt): RefInt = new RefInt(x + x1.x + x2.x)
+}
+class RefInteger(val x: java.lang.Integer) extends AnyRef with Gen[Integer] {
+ def plus(x1: Gen[Integer], x2: Gen[Integer]): Gen[Integer] = new RefInteger(x + x1.x + x2.x)
+ def bplus(x1: RefInteger, x2: RefInteger): RefInteger = new RefInteger(x + x1.x + x2.x)
+}
+
+class Val[Q](val value: Int) extends AnyVal
+class ValAny[Q](val value: Any) extends AnyVal
+class ValStr[Q](val value: String) extends AnyVal
+class ValA[Q](val value: Q) extends AnyVal {
+ def f: Q = ???
+}
+class ValB[Q, Q0 <: Q](val value: Q) extends AnyVal {
+ def f: Q0 = ???
+}
+
+class C0 {
+ def v1[A](in: Val[A]) = in
+ def v2[A]: List[Val[A]] = Nil
+ def v3[A]: Val[A] = new Val[A](0)
+ def v4[A <: String](x: Val[A], ys: List[Val[A]]) = ys.head
+}
+class C1 {
+ def v1[A](in: ValAny[A]) = in
+ def v2[A]: List[ValAny[A]] = Nil
+ def v3[A]: ValAny[A] = new ValAny[A]("")
+ def v4[A <: String](x: ValAny[A], ys: List[ValAny[A]]) = ys.head
+}
+class C2 {
+ def v1[A](in: ValStr[A]) = in
+ def v2[A]: List[ValStr[A]] = Nil
+ def v3[A]: ValStr[A] = new ValStr[A]("")
+ def v4[A <: String](x: ValStr[A], ys: List[ValStr[A]]) = ys.head
+}
+class C3[A](val x: A) {
+ def v1(in: ValA[A]) = in
+ def v2: List[ValA[A]] = Nil
+ def v3: ValA[A] = new ValA[A](x)
+ def v4(x: ValA[A], ys: List[ValA[A]]) = ys.head
+}
+class C4 {
+ def v1(in: ValA[Int]) = in
+ def v2: List[ValA[Int]] = Nil
+ def v3: ValA[Int] = new ValA(1)
+ def v4(x: ValA[Int], ys: List[ValA[Int]]) = ys.head
+}
+class C4B {
+ def v1(in: ValA[String]) = in
+ def v2: List[ValA[String]] = Nil
+ def v3: ValA[String] = new ValA("")
+ def v4(x: ValA[String], ys: List[ValA[String]]) = ys.head
+}
+class C5 {
+ def f1[A](x1: Val[A], x2: ValAny[A], x3: ValStr[A], x4: ValA[A]) = x4
+ def f2(x1: Int, x2: Any, x3: String, x4: Double) = x4
+ def f3(x: ValA[Int]) = x.f
+ def f4(x: ValB[Int, Int]) = x.f
+ def f5(x: ValB[Int, _ <: Int]) = x.f
+}
+class C6[A] {
+ def f1(x1: Val[A], x2: ValAny[A], x3: ValStr[A], x4: ValA[A]) = x4
+}
+class C7 extends C6[Int] {
+ override def f1(x1: Val[Int], x2: ValAny[Int], x3: ValStr[Int], x4: ValA[Int]) =
+ super.f1(x1, x2, x3, x4)
+}
+
+object Test {
+ def show[A: ClassTag] = {
+ println(classTag[A].runtimeClass.getName)
+ classTag[A].runtimeClass.getDeclaredMethods.toList.sortBy(_.toString).flatMap(m => List(m.toString, m.toGenericString)) foreach println
+ println("")
+ }
+
+ def main(args: Array[String]): Unit = {
+ show[C0]
+ show[C1]
+ show[C2]
+ show[C3[_]]
+ show[C4]
+ show[C4B]
+ show[C5]
+ show[C6[_]]
+ show[C7]
+ show[Gen[_]]
+ show[ValueInt]
+ show[RefInt]
+ show[RefInteger]
+ }
+}
diff --git a/test/files/run/t6380.check b/test/files/run/t6380.check
new file mode 100644
index 0000000000..912525ed66
--- /dev/null
+++ b/test/files/run/t6380.check
@@ -0,0 +1,7 @@
+List(class java.lang.Exception)
+List(class java.lang.Throwable)
+List(class java.lang.RuntimeException)
+List(class java.lang.IllegalArgumentException, class java.util.NoSuchElementException)
+List(class java.lang.IndexOutOfBoundsException, class java.lang.IndexOutOfBoundsException)
+List(class java.lang.IllegalStateException, class java.lang.IllegalStateException)
+List(class java.lang.NullPointerException, class java.lang.NullPointerException)
diff --git a/test/files/run/t6380.scala b/test/files/run/t6380.scala
new file mode 100644
index 0000000000..0e264d9175
--- /dev/null
+++ b/test/files/run/t6380.scala
@@ -0,0 +1,20 @@
+object Test extends App {
+ classOf[Foo].getDeclaredMethods().sortBy(_.getName).map(_.getExceptionTypes.sortBy(_.getName).toList).toList.foreach(println)
+}
+
+class Foo {
+ @throws[Exception]
+ def bar1 = ???
+ @throws[Throwable]("always")
+ def bar2 = ???
+ @throws(classOf[RuntimeException])
+ def bar3 = ???
+ @throws[IllegalArgumentException] @throws[NoSuchElementException]
+ def bar4 = ???
+ @throws(classOf[IndexOutOfBoundsException]) @throws(classOf[IndexOutOfBoundsException])
+ def bar5 = ???
+ @throws[IllegalStateException]("Cause") @throws[IllegalStateException]
+ def bar6 = ???
+ @throws[NullPointerException]("Cause A") @throws[NullPointerException]("Cause B")
+ def bar7 = ???
+} \ No newline at end of file
diff --git a/test/files/run/t6410.check b/test/files/run/t6410.check
new file mode 100644
index 0000000000..051fe4995a
--- /dev/null
+++ b/test/files/run/t6410.check
@@ -0,0 +1,2 @@
+ParMap(0 -> 4, 1 -> 5)
+ParMap(0 -> 4, 1 -> 5) \ No newline at end of file
diff --git a/test/files/run/t6410.scala b/test/files/run/t6410.scala
new file mode 100644
index 0000000000..2a001b47ab
--- /dev/null
+++ b/test/files/run/t6410.scala
@@ -0,0 +1,9 @@
+
+
+
+object Test extends App {
+ val x = collection.parallel.mutable.ParArray.range(1,10) groupBy { _ % 2 } mapValues { _.size }
+ println(x)
+ val y = collection.parallel.immutable.ParVector.range(1,10) groupBy { _ % 2 } mapValues { _.size }
+ println(y)
+} \ No newline at end of file
diff --git a/test/files/run/toolbox_console_reporter.check b/test/files/run/toolbox_console_reporter.check
index e69de29bb2..1395c68740 100644
--- a/test/files/run/toolbox_console_reporter.check
+++ b/test/files/run/toolbox_console_reporter.check
@@ -0,0 +1,8 @@
+hello
+============compiler console=============
+warning: method foo in object Utils is deprecated: test
+
+=========================================
+============compiler messages============
+Info(NoPosition,method foo in object Utils is deprecated: test,WARNING)
+=========================================
diff --git a/test/files/run/toolbox_console_reporter.scala b/test/files/run/toolbox_console_reporter.scala
index a57dea38a8..d672ccb9cb 100644
--- a/test/files/run/toolbox_console_reporter.scala
+++ b/test/files/run/toolbox_console_reporter.scala
@@ -1,16 +1,29 @@
import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{universe => ru}
+import scala.reflect.runtime.{currentMirror => cm}
+import scala.tools.reflect.{ToolBox, mkConsoleFrontEnd}
object Test extends App {
- // todo. cannot test this unfortunately, because ConsoleFrontEnd grabs Console.out too early
- // todo. and isn't affected by Console.setOut employed by partest to intercept output
+ val oldErr = Console.err;
+ val baos = new java.io.ByteArrayOutputStream();
+ Console.setErr(new java.io.PrintStream(baos));
+ try {
+ val toolbox = cm.mkToolBox(frontEnd = mkConsoleFrontEnd(), options = "-deprecation")
+ toolbox.eval(reify{
+ object Utils {
+ @deprecated("test", "2.10.0")
+ def foo { println("hello") }
+ }
- //val toolbox = mkToolBox(frontEnd = mkConsoleFrontEnd(), options = "-deprecation")
- //toolbox.eval(reify{
- // object Utils {
- // @deprecated("test", "2.10.0")
- // def foo { println("hello") }
- // }
- //
- // Utils.foo
- //})
+ Utils.foo
+ }.tree)
+ println("============compiler console=============")
+ println(baos.toString);
+ println("=========================================")
+ println("============compiler messages============")
+ toolbox.frontEnd.infos.foreach(println(_))
+ println("=========================================")
+ } finally {
+ Console.setErr(oldErr);
+ }
} \ No newline at end of file
diff --git a/test/files/run/toolbox_silent_reporter.scala b/test/files/run/toolbox_silent_reporter.scala
index 15f559d605..03b1d6defa 100644
--- a/test/files/run/toolbox_silent_reporter.scala
+++ b/test/files/run/toolbox_silent_reporter.scala
@@ -1,10 +1,10 @@
import scala.reflect.runtime.universe._
import scala.reflect.runtime.{universe => ru}
import scala.reflect.runtime.{currentMirror => cm}
-import scala.tools.reflect.ToolBox
+import scala.tools.reflect.{ToolBox, mkSilentFrontEnd}
object Test extends App {
- val toolbox = cm.mkToolBox(options = "-deprecation")
+ val toolbox = cm.mkToolBox(options = "-deprecation", frontEnd = mkSilentFrontEnd())
toolbox.eval(reify{
object Utils {
@deprecated("test", "2.10.0")
diff --git a/test/files/run/toolbox_typecheck_macrosdisabled.check b/test/files/run/toolbox_typecheck_macrosdisabled.check
index 9e997dafed..688f37927c 100644
--- a/test/files/run/toolbox_typecheck_macrosdisabled.check
+++ b/test/files/run/toolbox_typecheck_macrosdisabled.check
@@ -16,7 +16,7 @@
$treecreator1.super.<init>();
()
};
- def apply[U <: scala.reflect.api.Universe with Singleton]($m$untyped: scala.reflect.api.MirrorOf[U]): U#Tree = {
+ def apply[U <: scala.reflect.api.Universe with Singleton]($m$untyped: scala.reflect.api.Mirror[U]): U#Tree = {
val $u: U = $m$untyped.universe;
val $m: $u.Mirror = $m$untyped.asInstanceOf[$u.Mirror];
$u.Literal.apply($u.Constant.apply(2))
@@ -29,7 +29,7 @@
$typecreator2.super.<init>();
()
};
- def apply[U <: scala.reflect.api.Universe with Singleton]($m$untyped: scala.reflect.api.MirrorOf[U]): U#Type = {
+ def apply[U <: scala.reflect.api.Universe with Singleton]($m$untyped: scala.reflect.api.Mirror[U]): U#Type = {
val $u: U = $m$untyped.universe;
val $m: $u.Mirror = $m$untyped.asInstanceOf[$u.Mirror];
$u.ConstantType.apply($u.Constant.apply(2))
diff --git a/test/files/run/toolbox_typecheck_macrosdisabled2.check b/test/files/run/toolbox_typecheck_macrosdisabled2.check
index 16c8d6c397..f5c9b6eeab 100644
--- a/test/files/run/toolbox_typecheck_macrosdisabled2.check
+++ b/test/files/run/toolbox_typecheck_macrosdisabled2.check
@@ -16,7 +16,7 @@
$treecreator1.super.<init>();
()
};
- def apply[U <: scala.reflect.api.Universe with Singleton]($m$untyped: scala.reflect.api.MirrorOf[U]): U#Tree = {
+ def apply[U <: scala.reflect.api.Universe with Singleton]($m$untyped: scala.reflect.api.Mirror[U]): U#Tree = {
val $u: U = $m$untyped.universe;
val $m: $u.Mirror = $m$untyped.asInstanceOf[$u.Mirror];
$u.Apply.apply($u.Select.apply($u.Select.apply($u.build.Ident($m.staticPackage("scala")), $u.newTermName("Array")), $u.newTermName("apply")), scala.collection.immutable.List.apply[$u.Literal]($u.Literal.apply($u.Constant.apply(2))))
@@ -29,7 +29,7 @@
$typecreator2.super.<init>();
()
};
- def apply[U <: scala.reflect.api.Universe with Singleton]($m$untyped: scala.reflect.api.MirrorOf[U]): U#Type = {
+ def apply[U <: scala.reflect.api.Universe with Singleton]($m$untyped: scala.reflect.api.Mirror[U]): U#Type = {
val $u: U = $m$untyped.universe;
val $m: $u.Mirror = $m$untyped.asInstanceOf[$u.Mirror];
$u.TypeRef.apply($u.ThisType.apply($m.staticPackage("scala").asModule.moduleClass), $m.staticClass("scala.Array"), scala.collection.immutable.List.apply[$u.Type]($m.staticClass("scala.Int").asType.toTypeConstructor))
diff --git a/test/files/run/typetags_without_scala_reflect_manifest_lookup.scala b/test/files/run/typetags_without_scala_reflect_manifest_lookup.scala
index 37047e7884..6fd3d2dc2b 100644
--- a/test/files/run/typetags_without_scala_reflect_manifest_lookup.scala
+++ b/test/files/run/typetags_without_scala_reflect_manifest_lookup.scala
@@ -2,7 +2,7 @@ import scala.tools.partest._
import scala.tools.nsc.Settings
object Test extends DirectTest {
- override def extraSettings = "-cp " + sys.props("partest.lib")
+ override def extraSettings = "-cp " + sys.props("partest.lib") + " -d \"" + testOutput.path + "\""
def code = """
object Test extends App {
diff --git a/test/osgi/src/BasicLibrary.scala b/test/osgi/src/BasicLibrary.scala
index 38dea69e99..6618f02102 100644
--- a/test/osgi/src/BasicLibrary.scala
+++ b/test/osgi/src/BasicLibrary.scala
@@ -29,7 +29,7 @@ class BasicLibraryTest extends ScalaOsgiHelper {
def everythingLoads(): Unit = {
// Note - This tests sun.misc usage.
import scala.concurrent._
- import scala.concurrent.util.Duration.Inf
+ import scala.concurrent.duration.Duration.Inf
import ExecutionContext.Implicits._
val x = Future(2) map (_ + 1)
assertEquals(3, Await.result(x, Inf))
diff --git a/test/pending/pos/exhaust_2.scala b/test/pending/pos/exhaust_2.scala
new file mode 100644
index 0000000000..4f4e47c43b
--- /dev/null
+++ b/test/pending/pos/exhaust_2.scala
@@ -0,0 +1,54 @@
+object ExhaustivityWarnBugReportMinimal {
+ //sealed is needed for the warning
+ sealed trait FoundNode[T]/*presence of parameters is irrelevant*/
+ // This also causes a warning:
+ // sealed abstract class FoundNode[T]/*presence of parameters is irrelevant*/
+ case class FoundFilter[T](/*presence of parameters is irrelevant*/) extends FoundNode[T]
+ case class FoundTypeCase[T](/*presence of parameters is irrelevant*/) extends FoundNode[T]
+ val f: Some[_] = ???
+ f match {
+ case x: Some[t] => //no warning
+ }
+ //With these variants, no warnings:
+ //val v: (Some[Int], FoundNode[_]) = (???, ???)
+ //val v: (Some[AnyRef], FoundNode[_]) = (???, ???)
+ //val v: (Some[String], FoundNode[_]) = (???, ???)
+
+ val v: (Some[_], FoundNode[_]) = (???, ???)
+ //Warning here:
+ v match {
+ case (x: Some[t], _: FoundNode[_]) =>
+ }
+ v match {
+ case (x: Some[t], _) =>
+ }
+
+ v match {
+ case (x: Some[_], _) =>
+ }
+ case class Foo[T]()
+
+ val vp: (Foo[_], FoundNode[_]) = (???, ???)
+ vp match {
+ case (x: Foo[_], _) =>
+ }
+
+ //No warning here:
+ v match {
+ case (Some(y), _) =>
+ }
+
+ v match {
+ case (x, _) =>
+ }
+
+ val v2: (Some[_], Int) = (???, ???)
+ v2 match {
+ case (x: Some[t], _) =>
+ }
+
+ val v3: (Option[_], FoundNode[_]) = (???, ???)
+ v match {
+ case (x: Option[_], _) =>
+ }
+}
diff --git a/test/pending/run/reflection-mem-eval.scala b/test/pending/run/reflection-mem-eval.scala
new file mode 100644
index 0000000000..9045c44cd6
--- /dev/null
+++ b/test/pending/run/reflection-mem-eval.scala
@@ -0,0 +1,26 @@
+import scala.tools.partest.MemoryTest
+
+trait A { type T <: A }
+trait B { type T <: B }
+
+object Test extends MemoryTest {
+ lazy val tb = {
+ import scala.reflect.runtime.universe._
+ import scala.reflect.runtime.{currentMirror => cm}
+ import scala.tools.reflect.ToolBox
+ cm.mkToolBox()
+ }
+
+ override def maxDelta = 10
+ override def calcsPerIter = 3
+ override def calc() {
+ var snippet = """
+ trait A { type T <: A }
+ trait B { type T <: B }
+ def foo[T](x: List[T]) = x
+ foo(List(new A {}, new B {}))
+ """.trim
+ snippet = snippet + "\n" + (List.fill(50)(snippet.split("\n").last) mkString "\n")
+ tb.eval(tb.parse(snippet))
+ }
+} \ No newline at end of file
diff --git a/test/scaladoc/resources/links.scala b/test/scaladoc/resources/links.scala
index 679d0b0dce..09a52a4334 100644
--- a/test/scaladoc/resources/links.scala
+++ b/test/scaladoc/resources/links.scala
@@ -34,24 +34,29 @@ package scala.test.scaladoc.links {
/**
* Links to the trait:
- * - [[scala.test.scaladoc.links.Target!.T trait Target -> type T]]
- * - [[test.scaladoc.links.Target!.S trait Target -> type S]]
- * - [[scaladoc.links.Target!.foo(Int)* trait Target -> def foo]]
- * - [[links.Target!.bar trait Target -> def bar]]
- * - [[[[Target!.foo[A[_[_]]]* trait Target -> def foo with 3 nested tparams]]]] (should exercise nested parens)
- * - [[Target$.T object Target -> type T]]
- * - [[Target$.S object Target -> type S]]
- * - [[Target$.foo(Str* object Target -> def foo]]
- * - [[Target$.bar object Target -> def bar]]
- * - [[[[Target$.foo[A[_[_]]]* trait Target -> def foo with 3 nested tparams]]]] (should exercise nested parens)
- * - [[Target.onlyInObject object Target -> def foo]] (should find the object)
- * - [[Target$.C object Target -> class C]] (should link directly to C, not as a member)
- * - [[Target!.C trait Target -> class C]] (should link directly to C, not as a member)
- * - [[Target$.baz(links\.C)* object Target -> def baz]] (should use dots in prefix)
- * - [[Target!.baz(links\.C)* trait Target -> def baz]] (should use dots in prefix)
- * - [[localMethod object TEST -> localMethod]] (should use the current template to resolve link instead of inTpl, that's the package)
+ * - [[scala.test.scaladoc.links.Target$ object Test]]
+ * - [[scala.test package scala.test]]
+ * - [[scala.test.scaladoc.links.Target!.T trait Target -> type T]]
+ * - [[test.scaladoc.links.Target!.S trait Target -> type S]]
+ * - [[scaladoc.links.Target!.foo(i:Int)* trait Target -> def foo]]
+ * - [[links.Target!.bar trait Target -> def bar]]
+ * - [[[[Target!.foo[A[_[_]]]* trait Target -> def foo with 3 nested tparams]]]] (should exercise nested parens)
+ * - [[Target$.T object Target -> type T]]
+ * - [[Target$.S object Target -> type S]]
+ * - [[Target$.foo(z:Str* object Target -> def foo]]
+ * - [[Target$.bar object Target -> def bar]]
+ * - [[[[Target$.foo[A[_[_]]]* trait Target -> def foo with 3 nested tparams]]]] (should exercise nested parens)
+ * - [[Target.onlyInObject object Target -> def foo]] (should find the object)
+ * - [[Target$.C object Target -> class C]] (should link directly to C, not as a member)
+ * - [[Target!.C trait Target -> class C]] (should link directly to C, not as a member)
+ * - [[Target$.baz(c:scala\.test\.scaladoc\.links\.C)* object Target -> def baz]] (should use dots in prefix)
+ * - [[Target!.baz(c:scala\.test\.scaladoc\.links\.C)* trait Target -> def baz]] (should use dots in prefix)
+ * - [[localMethod object TEST -> localMethod]] (should use the current template to resolve link instead of inTpl, that's the package)
+ * - [[#localMethod object TEST -> localMethod]] (should exercise Java-style links to empty members)
+ * - [[ImOutside class ImOutside (check correct lookup in EmptyPackage)]]
*/
object TEST {
def localMethod = 3
}
}
+class ImOutside \ No newline at end of file
diff --git a/test/scaladoc/run/links.scala b/test/scaladoc/run/links.scala
index 40ce6368ce..de359539cf 100644
--- a/test/scaladoc/run/links.scala
+++ b/test/scaladoc/run/links.scala
@@ -22,7 +22,7 @@ object Test extends ScaladocModelTest {
val memberLinks = countLinks(TEST.comment.get, _.link.isInstanceOf[LinkToMember])
val templateLinks = countLinks(TEST.comment.get, _.link.isInstanceOf[LinkToTpl])
- assert(memberLinks == 14, memberLinks + " == 14 (the member links in object TEST)")
- assert(templateLinks == 2, templateLinks + " == 2 (the template links in object TEST)")
+ assert(memberLinks == 15, memberLinks + " == 15 (the member links in object TEST)")
+ assert(templateLinks == 5, templateLinks + " == 5 (the template links in object TEST)")
}
} \ No newline at end of file