summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/disabled/run/t8946.scala29
-rw-r--r--test/files/jvm/innerClassAttribute/Test.scala6
-rw-r--r--test/files/jvm/javaReflection.check4
-rw-r--r--test/files/neg/literals.check40
-rw-r--r--test/files/neg/literals.scala36
-rw-r--r--test/files/neg/sammy_error_exist_no_crash.check6
-rw-r--r--test/files/neg/sammy_error_exist_no_crash.flags1
-rw-r--r--test/files/neg/sammy_error_exist_no_crash.scala6
-rw-r--r--test/files/neg/sammy_restrictions.scala28
-rw-r--r--test/files/neg/t2866.check17
-rw-r--r--test/files/neg/t2866.scala59
-rw-r--r--test/files/neg/t5091.check9
-rw-r--r--test/files/neg/t5091.scala (renamed from test/pending/pos/t5091.scala)0
-rw-r--r--test/files/neg/t5148.check7
-rw-r--r--test/files/neg/t5639b.check4
-rw-r--r--test/files/neg/t5639b/A_1.scala17
-rw-r--r--test/files/neg/t5639b/A_2.scala11
-rw-r--r--test/files/neg/t7602.check5
-rw-r--r--test/files/neg/t7602.scala26
-rw-r--r--test/files/neg/t7636.check2
-rw-r--r--test/files/neg/t8534.check4
-rw-r--r--test/files/neg/t8534.scala7
-rw-r--r--test/files/neg/t8534b.check4
-rw-r--r--test/files/neg/t8534b.scala4
-rw-r--r--test/files/neg/t8597.check21
-rw-r--r--test/files/neg/t8597.flags1
-rw-r--r--test/files/neg/t8597.scala27
-rw-r--r--test/files/neg/t8597b.check6
-rw-r--r--test/files/neg/t8597b.flags1
-rw-r--r--test/files/neg/t8597b.scala21
-rw-r--r--test/files/neg/t9008.check4
-rw-r--r--test/files/neg/t9008.scala3
-rw-r--r--test/files/neg/t9008b.check4
-rw-r--r--test/files/neg/t9008b.scala3
-rw-r--r--test/files/neg/t963.check8
-rw-r--r--test/files/neg/unchecked-abstract.check14
-rw-r--r--test/files/pos/sammy_exist.flags1
-rw-r--r--test/files/pos/sammy_exist.scala17
-rw-r--r--test/files/pos/sammy_overload.flags1
-rw-r--r--test/files/pos/sammy_overload.scala9
-rw-r--r--test/files/pos/sammy_override.flags1
-rw-r--r--test/files/pos/sammy_override.scala8
-rw-r--r--test/files/pos/t3439.scala26
-rw-r--r--test/files/pos/t5217.scala17
-rw-r--r--test/files/pos/t5413.scala9
-rw-r--r--test/files/pos/t5454.scala10
-rw-r--r--test/files/pos/t5639.flags1
-rw-r--r--test/files/pos/t5639/A_1.scala17
-rw-r--r--test/files/pos/t5639/A_2.scala11
-rw-r--r--test/files/pos/t5639/Bar.scala7
-rw-r--r--test/files/pos/t5639/Foo.scala7
-rw-r--r--test/files/pos/t6051.scala19
-rw-r--r--test/files/pos/t7596/A_1.scala10
-rw-r--r--test/files/pos/t7596/B_2.scala19
-rw-r--r--test/files/pos/t7596b/A.scala10
-rw-r--r--test/files/pos/t7596b/B.scala6
-rw-r--r--test/files/pos/t7596c/A_1.scala11
-rw-r--r--test/files/pos/t7596c/B_2.scala9
-rw-r--r--test/files/pos/t7683-stop-after-parser/ThePlugin.scala31
-rw-r--r--test/files/pos/t7683-stop-after-parser/sample_2.flags1
-rw-r--r--test/files/pos/t7683-stop-after-parser/sample_2.scala6
-rw-r--r--test/files/pos/t7683-stop-after-parser/scalac-plugin.xml5
-rw-r--r--test/files/pos/t7750.flags1
-rw-r--r--test/files/pos/t7750.scala8
-rw-r--r--test/files/pos/t8310.flags1
-rw-r--r--test/files/pos/t8310.scala22
-rw-r--r--test/files/pos/t8893.scala129
-rw-r--r--test/files/pos/t8934a/A_1.scala18
-rw-r--r--test/files/pos/t8934a/Test_2.flags1
-rw-r--r--test/files/pos/t8934a/Test_2.scala12
-rw-r--r--test/files/pos/t8947/Client_2.scala1
-rw-r--r--test/files/pos/t8947/Macro_1.scala41
-rw-r--r--test/files/pos/t8954.flags1
-rw-r--r--test/files/pos/t8954/t1.scala13
-rw-r--r--test/files/pos/t8954/t2.scala39
-rw-r--r--test/files/pos/t8962.scala31
-rw-r--r--test/files/pos/t8965.flags1
-rw-r--r--test/files/pos/t8965.scala7
-rw-r--r--test/files/pos/t9008.scala5
-rw-r--r--test/files/pos/t9018.scala16
-rw-r--r--test/files/presentation/private-case-class-members.check1
-rw-r--r--test/files/presentation/private-case-class-members/Test.scala34
-rw-r--r--test/files/presentation/private-case-class-members/src/State.scala5
-rw-r--r--test/files/presentation/quasiquotes.flags0
-rw-r--r--test/files/presentation/t8934.check2
-rw-r--r--test/files/presentation/t8934/Runner.scala27
-rw-r--r--test/files/presentation/t8934/src/Source.scala10
-rw-r--r--test/files/presentation/t8941.check7
-rw-r--r--test/files/presentation/t8941/Runner.scala11
-rw-r--r--test/files/presentation/t8941/src/Source.scala8
-rw-r--r--test/files/presentation/t8941b/IdempotencyTest.scala73
-rw-r--r--test/files/presentation/t8941b/Test.scala53
-rw-r--r--test/files/res/t6613.check5
-rw-r--r--test/files/res/t6613.res3
-rw-r--r--test/files/res/t6613/Broken.scala1
-rw-r--r--test/files/res/t6613/Enummy.java1
-rw-r--r--test/files/res/t8871.check5
-rw-r--r--test/files/res/t8871.res4
-rw-r--r--test/files/res/t8871/tag.scala3
-rw-r--r--test/files/res/t8871/usetag.scala6
-rw-r--r--test/files/run/delambdafy_uncurry_byname_inline.check2
-rw-r--r--test/files/run/delambdafy_uncurry_inline.check2
-rw-r--r--test/files/run/global-showdef.check8
-rw-r--r--test/files/run/global-showdef.scala52
-rw-r--r--test/files/run/iterator-concat.check4
-rw-r--r--test/files/run/iterator-concat.scala15
-rw-r--r--test/files/run/iterator-iterate-lazy.scala5
-rw-r--r--test/files/run/iterators.check13
-rw-r--r--test/files/run/iterators.scala136
-rw-r--r--test/files/run/literals.check69
-rw-r--r--test/files/run/literals.flags1
-rw-r--r--test/files/run/literals.scala39
-rw-r--r--test/files/run/priorityQueue.scala373
-rw-r--r--test/files/run/repl-javap-lambdas.scala23
-rw-r--r--test/files/run/repl-javap-memfun.scala4
-rw-r--r--test/files/run/repl-javap-outdir-funs.flags1
-rw-r--r--test/files/run/repl-javap-outdir-funs/run-repl_7.scala5
-rw-r--r--test/files/run/sammy_repeated.check1
-rw-r--r--test/files/run/sammy_repeated.flags1
-rw-r--r--test/files/run/sammy_repeated.scala8
-rw-r--r--test/files/run/t1994.scala20
-rw-r--r--test/files/run/t2866.check3
-rw-r--r--test/files/run/t2866.scala44
-rw-r--r--test/files/run/t3516.check3
-rw-r--r--test/files/run/t3516.scala13
-rw-r--r--test/files/run/t4950.check9
-rw-r--r--test/files/run/t4950.scala12
-rw-r--r--test/files/run/t5665.scala13
-rw-r--r--test/files/run/t5938.scala35
-rw-r--r--test/files/run/t6028.check4
-rw-r--r--test/files/run/t6260c.check4
-rw-r--r--test/files/run/t6440.check9
-rw-r--r--test/files/run/t6440.scala2
-rw-r--r--test/files/run/t6502.check8
-rw-r--r--test/files/run/t6502.scala116
-rw-r--r--test/files/run/t6541-option.scala19
-rw-r--r--test/files/run/t6541.flags1
-rw-r--r--test/files/run/t6541.scala25
-rw-r--r--test/files/run/t6555.check2
-rw-r--r--test/files/run/t6669.scala7
-rw-r--r--test/files/run/t7019.scala10
-rw-r--r--test/files/run/t7407.flags2
-rw-r--r--test/files/run/t8253.check40
-rw-r--r--test/files/run/t8253.scala14
-rw-r--r--test/files/run/t8502.scala41
-rw-r--r--test/files/run/t8549.scala5
-rw-r--r--test/files/run/t8601-closure-elim.flags2
-rw-r--r--test/files/run/t8893.scala40
-rw-r--r--test/files/run/t8893b.scala15
-rw-r--r--test/files/run/t8925.check2
-rw-r--r--test/files/run/t8925.flags1
-rw-r--r--test/files/run/t8925.scala31
-rw-r--r--test/files/run/t8931.check1
-rw-r--r--test/files/run/t8931.scala15
-rw-r--r--test/files/run/t8933.check1
-rw-r--r--test/files/run/t8933/A_1.scala6
-rw-r--r--test/files/run/t8933/Test_2.scala10
-rw-r--r--test/files/run/t8933b/A.scala4
-rw-r--r--test/files/run/t8933b/Test.scala9
-rw-r--r--test/files/run/t8933c.scala14
-rw-r--r--test/files/run/t8960.scala72
-rw-r--r--test/files/run/t9003.flags1
-rw-r--r--test/files/run/t9003.scala71
-rw-r--r--test/files/run/t9027.check19
-rw-r--r--test/files/run/t9027.scala15
-rw-r--r--test/files/run/various-flat-classpath-types.check12
-rw-r--r--test/files/run/various-flat-classpath-types.scala214
-rw-r--r--test/files/run/xMigration.check49
-rw-r--r--test/files/run/xMigration.scala19
-rw-r--r--test/files/t8449/Client.scala3
-rw-r--r--test/files/t8449/Test.java10
-rw-r--r--test/junit/scala/collection/IndexedSeqOptimizedTest.scala13
-rw-r--r--test/junit/scala/collection/IterableViewLikeTest.scala20
-rw-r--r--test/junit/scala/collection/IteratorTest.scala133
-rw-r--r--test/junit/scala/collection/immutable/ListTest.scala49
-rw-r--r--test/junit/scala/collection/immutable/PagedSeqTest.scala18
-rw-r--r--test/junit/scala/collection/immutable/TreeMapTest.scala20
-rw-r--r--test/junit/scala/collection/immutable/TreeSetTest.scala20
-rw-r--r--test/junit/scala/collection/mutable/BitSetTest.scala22
-rw-r--r--test/junit/scala/math/BigDecimalTest.scala6
-rw-r--r--test/junit/scala/reflect/internal/PrintersTest.scala7
-rw-r--r--test/junit/scala/tools/nsc/SampleTest.scala2
-rw-r--r--test/junit/scala/tools/nsc/backend/jvm/CodeGenTools.scala21
-rw-r--r--test/junit/scala/tools/nsc/backend/jvm/DirectCompileTest.scala50
-rw-r--r--test/junit/scala/tools/nsc/backend/jvm/opt/CompactLocalVariablesTest.scala80
-rw-r--r--test/junit/scala/tools/nsc/backend/jvm/opt/EmptyExceptionHandlersTest.scala8
-rw-r--r--test/junit/scala/tools/nsc/backend/jvm/opt/EmptyLabelsAndLineNumbersTest.scala99
-rw-r--r--test/junit/scala/tools/nsc/backend/jvm/opt/MethodLevelOpts.scala83
-rw-r--r--test/junit/scala/tools/nsc/backend/jvm/opt/SimplifyJumpsTest.scala221
-rw-r--r--test/junit/scala/tools/nsc/backend/jvm/opt/UnreachableCodeTest.scala60
-rw-r--r--test/junit/scala/tools/nsc/classpath/AggregateFlatClassPathTest.scala208
-rw-r--r--test/junit/scala/tools/nsc/classpath/FlatClassPathResolverTest.scala159
-rw-r--r--test/junit/scala/tools/nsc/settings/ScalaVersionTest.scala18
-rw-r--r--test/junit/scala/tools/nsc/settings/SettingsTest.scala16
-rw-r--r--test/junit/scala/tools/nsc/symtab/CannotHaveAttrsTest.scala12
-rw-r--r--test/junit/scala/tools/nsc/symtab/SymbolTableForUnitTesting.scala31
-rw-r--r--test/junit/scala/tools/nsc/util/ClassPathImplComparator.scala143
-rw-r--r--test/junit/scala/tools/testing/AssertUtil.scala20
-rw-r--r--test/osgi/src/BasicLibrary.scala15
-rw-r--r--test/osgi/src/BasicReflection.scala15
-rw-r--r--test/osgi/src/BasicTest.scala15
-rw-r--r--test/osgi/src/ReflectionToolboxTest.scala15
-rw-r--r--test/osgi/src/ScalaOsgiHelper.scala6
-rw-r--r--test/pending/pos/t3439.scala2
-rw-r--r--test/scaladoc/run/t5730.check1
-rw-r--r--test/scaladoc/run/t5730.scala36
-rw-r--r--test/scaladoc/run/t6626.check7
-rw-r--r--test/scaladoc/run/t6626.scala42
-rwxr-xr-xtest/script-tests/README7
209 files changed, 4020 insertions, 859 deletions
diff --git a/test/disabled/run/t8946.scala b/test/disabled/run/t8946.scala
new file mode 100644
index 0000000000..a248a20501
--- /dev/null
+++ b/test/disabled/run/t8946.scala
@@ -0,0 +1,29 @@
+// Tests to assert that references to threads are not strongly held when scala-reflection is used inside of them.
+object Test {
+ import scala.ref.WeakReference
+
+ def forceGc() = {
+ var obj = new Object
+ val ref = new WeakReference(obj)
+ obj = null;
+ while(ref.get.nonEmpty)
+ Array.ofDim[Byte](16 * 1024 * 1024)
+ }
+
+ def main(args: Array[String]): Unit = {
+ val threads = for (i <- (1 to 16)) yield {
+ val t = new Thread {
+ override def run(): Unit = {
+ import reflect.runtime.universe._
+ typeOf[List[String]] <:< typeOf[Seq[_]]
+ }
+ }
+ t.start()
+ t.join()
+ WeakReference(t)
+ }
+ forceGc()
+ val nonGCdThreads = threads.filter(_.get.nonEmpty).length
+ assert(nonGCdThreads == 0, s"${nonGCdThreads} threads were retained; expected 0.")
+ }
+}
diff --git a/test/files/jvm/innerClassAttribute/Test.scala b/test/files/jvm/innerClassAttribute/Test.scala
index 882edbcdd7..1c1a0522e4 100644
--- a/test/files/jvm/innerClassAttribute/Test.scala
+++ b/test/files/jvm/innerClassAttribute/Test.scala
@@ -256,9 +256,9 @@ object Test extends BytecodeTest {
printInnerClassNodes("A20")
val fun1 = lambdaClass("A20$$anonfun$4", "A20$lambda$1")
- val fun2 = lambdaClass("A20$$anonfun$4$$anonfun$apply$1", "A20$lambda$$$anonfun$5$1")
- val fun3 = lambdaClass("A20$$anonfun$4$$anonfun$apply$3", "A20$lambda$$$anonfun$5$2")
- val fun4 = lambdaClass("A20$$anonfun$4$$anonfun$apply$3$$anonfun$apply$2", "A20$lambda$$$anonfun$7$1")
+ val fun2 = lambdaClass("A20$$anonfun$4$$anonfun$apply$1", "A20$lambda$$$nestedInAnonfun$5$1")
+ val fun3 = lambdaClass("A20$$anonfun$4$$anonfun$apply$3", "A20$lambda$$$nestedInAnonfun$5$2")
+ val fun4 = lambdaClass("A20$$anonfun$4$$anonfun$apply$3$$anonfun$apply$2", "A20$lambda$$$nestedInAnonfun$7$1")
println("fun1: attribute for itself and the two child closures `() => ()` and `() => () => 1`")
printInnerClassNodes(fun1)
diff --git a/test/files/jvm/javaReflection.check b/test/files/jvm/javaReflection.check
index aeb894f741..d40599507d 100644
--- a/test/files/jvm/javaReflection.check
+++ b/test/files/jvm/javaReflection.check
@@ -44,11 +44,11 @@ A$D$lambda$1 / A$D$lambda$1 (canon) / A$D$lambda$1 (simple)
- declared cls: List()
- enclosing : null (declaring cls) / null (cls) / null (constr) / null (meth)
- properties : false (local) / false (member)
-A$lambda$$$anonfun$7$1 / A$lambda$$$anonfun$7$1 (canon) / A$lambda$$$anonfun$7$1 (simple)
+A$lambda$$$lessinit$greater$1 / A$lambda$$$lessinit$greater$1 (canon) / A$lambda$$$lessinit$greater$1 (simple)
- declared cls: List()
- enclosing : null (declaring cls) / null (cls) / null (constr) / null (meth)
- properties : false (local) / false (member)
-A$lambda$$$lessinit$greater$1 / A$lambda$$$lessinit$greater$1 (canon) / A$lambda$$$lessinit$greater$1 (simple)
+A$lambda$$$nestedInAnonfun$7$1 / A$lambda$$$nestedInAnonfun$7$1 (canon) / A$lambda$$$nestedInAnonfun$7$1 (simple)
- declared cls: List()
- enclosing : null (declaring cls) / null (cls) / null (constr) / null (meth)
- properties : false (local) / false (member)
diff --git a/test/files/neg/literals.check b/test/files/neg/literals.check
new file mode 100644
index 0000000000..148a9346c5
--- /dev/null
+++ b/test/files/neg/literals.check
@@ -0,0 +1,40 @@
+literals.scala:6: error: missing integer number
+ def missingHex: Int = { 0x } // line 4: was: not reported, taken as zero
+ ^
+literals.scala:8: error: Decimal integer literals may not have a leading zero. (Octal syntax is obsolete.)
+ def leadingZeros: Int = { 01 } // line 6: no leading zero
+ ^
+literals.scala:10: error: Decimal integer literals may not have a leading zero. (Octal syntax is obsolete.)
+ def tooManyZeros: Int = { 00 } // line 8: no leading zero
+ ^
+literals.scala:12: error: Decimal integer literals may not have a leading zero. (Octal syntax is obsolete.)
+ def zeroOfNine: Int = { 09 } // line 10: no leading zero
+ ^
+literals.scala:16: error: Decimal integer literals may not have a leading zero. (Octal syntax is obsolete.)
+ def zeroOfNineDot: Int = { 09. } // line 14: malformed integer, ident expected
+ ^
+literals.scala:23: error: missing integer number
+ def missingHex: Int = 0x // line 22: was: not reported, taken as zero
+ ^
+literals.scala:27: error: Decimal integer literals may not have a leading zero. (Octal syntax is obsolete.)
+ def tooManyZeros: Int = 00 // line 26: no leading zero
+ ^
+literals.scala:14: error: identifier expected but '}' found.
+ def orphanDot: Int = { 9. } // line 12: ident expected
+ ^
+literals.scala:16: error: identifier expected but '}' found.
+ def zeroOfNineDot: Int = { 09. } // line 14: malformed integer, ident expected
+ ^
+literals.scala:18: error: ';' expected but double literal found.
+ def noHexFloat: Double = { 0x1.2 } // line 16: ';' expected but double literal found.
+ ^
+literals.scala:25: error: ';' expected but 'def' found.
+ def leadingZeros: Int = 01 // line 24: no leading zero
+ ^
+literals.scala:29: error: ';' expected but 'def' found.
+ def zeroOfNine: Int = 09 // line 28: no leading zero
+ ^
+literals.scala:33: error: identifier expected but 'def' found.
+ def zeroOfNineDot: Int = 09. // line 32: malformed integer, ident expected
+ ^
+13 errors found
diff --git a/test/files/neg/literals.scala b/test/files/neg/literals.scala
new file mode 100644
index 0000000000..3df7f0b408
--- /dev/null
+++ b/test/files/neg/literals.scala
@@ -0,0 +1,36 @@
+
+/* This took me literally all day.
+*/
+trait RejectedLiterals {
+
+ def missingHex: Int = { 0x } // line 4: was: not reported, taken as zero
+
+ def leadingZeros: Int = { 01 } // line 6: no leading zero
+
+ def tooManyZeros: Int = { 00 } // line 8: no leading zero
+
+ def zeroOfNine: Int = { 09 } // line 10: no leading zero
+
+ def orphanDot: Int = { 9. } // line 12: ident expected
+
+ def zeroOfNineDot: Int = { 09. } // line 14: malformed integer, ident expected
+
+ def noHexFloat: Double = { 0x1.2 } // line 16: ';' expected but double literal found.
+}
+
+trait Braceless {
+
+ def missingHex: Int = 0x // line 22: was: not reported, taken as zero
+
+ def leadingZeros: Int = 01 // line 24: no leading zero
+
+ def tooManyZeros: Int = 00 // line 26: no leading zero
+
+ def zeroOfNine: Int = 09 // line 28: no leading zero
+
+ def orphanDot: Int = 9. // line 30: ident expected
+
+ def zeroOfNineDot: Int = 09. // line 32: malformed integer, ident expected
+
+ def noHexFloat: Double = 0x1.2 // line 34: ';' expected but double literal found.
+}
diff --git a/test/files/neg/sammy_error_exist_no_crash.check b/test/files/neg/sammy_error_exist_no_crash.check
new file mode 100644
index 0000000000..a0d2237ce0
--- /dev/null
+++ b/test/files/neg/sammy_error_exist_no_crash.check
@@ -0,0 +1,6 @@
+sammy_error_exist_no_crash.scala:5: error: Could not derive subclass of F[? >: String]
+ (with SAM `def method apply(s: String)Int`)
+ based on: ((x$1: String) => x$1.<parseInt: error>).
+ bar(_.parseInt)
+ ^
+one error found
diff --git a/test/files/neg/sammy_error_exist_no_crash.flags b/test/files/neg/sammy_error_exist_no_crash.flags
new file mode 100644
index 0000000000..e1b37447c9
--- /dev/null
+++ b/test/files/neg/sammy_error_exist_no_crash.flags
@@ -0,0 +1 @@
+-Xexperimental \ No newline at end of file
diff --git a/test/files/neg/sammy_error_exist_no_crash.scala b/test/files/neg/sammy_error_exist_no_crash.scala
new file mode 100644
index 0000000000..da7e47206f
--- /dev/null
+++ b/test/files/neg/sammy_error_exist_no_crash.scala
@@ -0,0 +1,6 @@
+abstract class F[T] { def apply(s: T): Int }
+
+object NeedsNiceError {
+ def bar(x: F[_ >: String]) = ???
+ bar(_.parseInt)
+} \ No newline at end of file
diff --git a/test/files/neg/sammy_restrictions.scala b/test/files/neg/sammy_restrictions.scala
index 5f1a04cd20..d003cfaf36 100644
--- a/test/files/neg/sammy_restrictions.scala
+++ b/test/files/neg/sammy_restrictions.scala
@@ -1,28 +1,28 @@
-class NoAbstract
+abstract class NoAbstract
-class TwoAbstract { def ap(a: Int): Int; def pa(a: Int): Int }
+abstract class TwoAbstract { def ap(a: Int): Int; def pa(a: Int): Int }
-class Base // check that the super class constructor isn't considered.
-class NoEmptyConstructor(a: Int) extends Base { def this(a: String) = this(0); def ap(a: Int): Int }
+abstract class Base // check that the super class constructor isn't considered.
+abstract class NoEmptyConstructor(a: Int) extends Base { def this(a: String) = this(0); def ap(a: Int): Int }
-class OneEmptyConstructor() { def this(a: Int) = this(); def ap(a: Int): Int }
+abstract class OneEmptyConstructor() { def this(a: Int) = this(); def ap(a: Int): Int }
-class OneEmptySecondaryConstructor(a: Int) { def this() = this(0); def ap(a: Int): Int }
+abstract class OneEmptySecondaryConstructor(a: Int) { def this() = this(0); def ap(a: Int): Int }
-class MultipleConstructorLists()() { def ap(a: Int): Int }
+abstract class MultipleConstructorLists()() { def ap(a: Int): Int }
-class MultipleMethodLists()() { def ap(a: Int)(): Int }
+abstract class MultipleMethodLists()() { def ap(a: Int)(): Int }
-class ImplicitConstructorParam()(implicit a: String) { def ap(a: Int): Int }
+abstract class ImplicitConstructorParam()(implicit a: String) { def ap(a: Int): Int }
-class ImplicitMethodParam() { def ap(a: Int)(implicit b: String): Int }
+abstract class ImplicitMethodParam() { def ap(a: Int)(implicit b: String): Int }
-class PolyClass[T] { def ap(a: T): T }
+abstract class PolyClass[T] { def ap(a: T): T }
-class PolyMethod { def ap[T](a: T): T }
+abstract class PolyMethod { def ap[T](a: T): T }
-class OneAbstract { def ap(a: Any): Any }
-class DerivedOneAbstract extends OneAbstract
+abstract class OneAbstract { def ap(a: Int): Any }
+abstract class DerivedOneAbstract extends OneAbstract
object Test {
implicit val s: String = ""
diff --git a/test/files/neg/t2866.check b/test/files/neg/t2866.check
new file mode 100644
index 0000000000..340fb8da22
--- /dev/null
+++ b/test/files/neg/t2866.check
@@ -0,0 +1,17 @@
+t2866.scala:30: warning: imported `one' is permanently hidden by definition of value one
+ import A.one // warning: imported `one' is permanently hidden by definition of value one.
+ ^
+t2866.scala:42: error: ambiguous implicit values:
+ both value two of type Int
+ and value one in object A of type => Int
+ match expected type Int
+ assert(implicitly[Int] == 2) // !!! Not ambiguous in 2.8.0. Ambigous in 2.7.6
+ ^
+t2866.scala:50: error: ambiguous implicit values:
+ both value two of type Int
+ and value one in object A of type => Int
+ match expected type Int
+ assert(implicitly[Int] == 2) // !!! Not ambiguous in 2.8.0. Ambiguous in 2.7.6
+ ^
+one warning found
+two errors found
diff --git a/test/files/neg/t2866.scala b/test/files/neg/t2866.scala
new file mode 100644
index 0000000000..55ebff9710
--- /dev/null
+++ b/test/files/neg/t2866.scala
@@ -0,0 +1,59 @@
+// for 2.7.x compatibility
+
+object A {
+ implicit val one = 1
+}
+
+object Test {
+
+ locally {
+ import A._
+ locally {
+ // assert(implicitly[Int] == 1) // error: could not find implicit value for parameter e: Int.
+ // !!! Why one A.one?
+ // (I assume you mean: why _not_ A.one? A.one is shadowed by local one.
+ // but the local one cannot be used yet because it does not have an explicit type.
+ implicit val one = 2
+ assert(implicitly[Int] == 2)
+ assert(one == 2)
+ }
+ }
+
+ locally {
+ import A._
+ implicit val one: Int = 2
+ assert(implicitly[Int] == 2)
+ assert(one == 2)
+ }
+
+ locally {
+ import A.one // warning: imported `one' is permanently hidden by definition of value one.
+ // !!! Really?
+ //assert(implicitly[Int] == 1)
+ implicit val one = 2
+ assert(implicitly[Int] == 2) // !!! why not 2?
+ assert(one == 2)
+ }
+
+ locally {
+ import A.one
+ assert(implicitly[Int] == 1)
+ implicit val two = 2
+ assert(implicitly[Int] == 2) // !!! Not ambiguous in 2.8.0. Ambigous in 2.7.6
+ }
+
+ locally {
+ import A._
+ assert(implicitly[Int] == 1)
+ implicit val two = 2
+ import A.{one => _}
+ assert(implicitly[Int] == 2) // !!! Not ambiguous in 2.8.0. Ambiguous in 2.7.6
+ }
+
+ locally {
+ import A.{one => _, _}
+ implicit val two = 2
+ assert(implicitly[Int] == 2) // not ambiguous in 2.8.0 nor im ambiguous in 2.7.6
+ }
+
+}
diff --git a/test/files/neg/t5091.check b/test/files/neg/t5091.check
new file mode 100644
index 0000000000..abd24e3145
--- /dev/null
+++ b/test/files/neg/t5091.check
@@ -0,0 +1,9 @@
+t5091.scala:8: error: recursive value xxx needs type
+ val param = bar(xxx)
+ ^
+t5091.scala:7: warning: type-checking the invocation of method foo checks if the named argument expression 'param = ...' is a valid assignment
+in the current scope. The resulting type inference error (see above) can be fixed by providing an explicit type in the local definition for param.
+ val xxx = foo(param = null)
+ ^
+one warning found
+one error found
diff --git a/test/pending/pos/t5091.scala b/test/files/neg/t5091.scala
index 217e83f66d..217e83f66d 100644
--- a/test/pending/pos/t5091.scala
+++ b/test/files/neg/t5091.scala
diff --git a/test/files/neg/t5148.check b/test/files/neg/t5148.check
index 0de4fe2d4c..286ed9e04a 100644
--- a/test/files/neg/t5148.check
+++ b/test/files/neg/t5148.check
@@ -1,6 +1,11 @@
error: missing or invalid dependency detected while loading class file 'Imports.class'.
+Could not access type Wrapper in class scala.tools.nsc.interpreter.IMain.Request,
+because it (or its dependencies) are missing. Check your build definition for
+missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.)
+A full rebuild may help if 'Imports.class' was compiled against an incompatible version of scala.tools.nsc.interpreter.IMain.Request.
+error: missing or invalid dependency detected while loading class file 'Imports.class'.
Could not access type Request in class scala.tools.nsc.interpreter.IMain,
because it (or its dependencies) are missing. Check your build definition for
missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.)
A full rebuild may help if 'Imports.class' was compiled against an incompatible version of scala.tools.nsc.interpreter.IMain.
-one error found
+two errors found
diff --git a/test/files/neg/t5639b.check b/test/files/neg/t5639b.check
new file mode 100644
index 0000000000..faa1766660
--- /dev/null
+++ b/test/files/neg/t5639b.check
@@ -0,0 +1,4 @@
+A_2.scala:6: error: could not find implicit value for parameter e: Int
+ implicitly[Int]
+ ^
+one error found
diff --git a/test/files/neg/t5639b/A_1.scala b/test/files/neg/t5639b/A_1.scala
new file mode 100644
index 0000000000..c5da10eae4
--- /dev/null
+++ b/test/files/neg/t5639b/A_1.scala
@@ -0,0 +1,17 @@
+import Implicits._
+
+class Baz
+
+object Test {
+ implicitly[Int]
+}
+
+object Implicits {
+ implicit val Baz: Int = 0
+ // This implicit was being ignored by `isQualifyingImplicit`
+ // if the classpath contained a class file for `class Baz`.
+ // This is because the package scope contains a speculative
+ // symbol for `object Baz` which is entered by `SymbolLoaders`
+ // before looking inside the class file. (A Java originated
+ // classfile results in the class/module symbol pair.)
+}
diff --git a/test/files/neg/t5639b/A_2.scala b/test/files/neg/t5639b/A_2.scala
new file mode 100644
index 0000000000..2bb36273e0
--- /dev/null
+++ b/test/files/neg/t5639b/A_2.scala
@@ -0,0 +1,11 @@
+import Implicits._
+
+class Baz
+
+object Test {
+ implicitly[Int]
+}
+
+object Implicits {
+ implicit val Baz: Int = 0
+}
diff --git a/test/files/neg/t7602.check b/test/files/neg/t7602.check
new file mode 100644
index 0000000000..5bb1450d7d
--- /dev/null
+++ b/test/files/neg/t7602.check
@@ -0,0 +1,5 @@
+t7602.scala:16: error: method foo is defined twice
+ conflicting symbols both originated in file 't7602.scala'
+ def foo : Device
+ ^
+one error found
diff --git a/test/files/neg/t7602.scala b/test/files/neg/t7602.scala
new file mode 100644
index 0000000000..5a9444a1ab
--- /dev/null
+++ b/test/files/neg/t7602.scala
@@ -0,0 +1,26 @@
+trait Table[T]{
+ def foo : T
+}
+trait Computer
+trait Device
+
+object schema{
+ def lub[T]( a:T, b:T ) = ???
+ lub(null:Computers,null:Devices)
+}
+trait Computers extends Table[Computer]{
+ def foo : Computer
+}
+trait Devices extends Table[Device]{
+ def foo : Device
+ def foo : Device
+}
+/* Was:
+Exception in thread "main" java.lang.AssertionError: assertion failed: List(method foo, method foo)
+ at scala.Predef$.assert(Predef.scala:165)
+ at scala.reflect.internal.Symbols$Symbol.suchThat(Symbols.scala:1916)
+ at scala.reflect.internal.tpe.GlbLubs$$anonfun$23.apply(GlbLubs.scala:350)
+ at scala.reflect.internal.tpe.GlbLubs$$anonfun$23.apply(GlbLubs.scala:349)
+ at scala.collection.immutable.List.map(List.scala:272)
+ at scala.reflect.internal.tpe.GlbLubs$class.lubsym$1(GlbLubs.scala:349)
+*/ \ No newline at end of file
diff --git a/test/files/neg/t7636.check b/test/files/neg/t7636.check
index f70d50bee3..12391cccc8 100644
--- a/test/files/neg/t7636.check
+++ b/test/files/neg/t7636.check
@@ -4,7 +4,7 @@ t7636.scala:3: error: illegal inheritance;
^
t7636.scala:3: error: type mismatch;
found : Either[_$2,_$3(in constructor C)] where type _$3(in constructor C), type _$2
- required: Either[_, _$3(in object Main)] where type _$3(in object Main)
+ required: Either[_, _$3(in value <local Main>)] where type _$3(in value <local Main>)
class C extends ResultTable(Left(5):Either[_,_])(5)
^
two errors found
diff --git a/test/files/neg/t8534.check b/test/files/neg/t8534.check
new file mode 100644
index 0000000000..297e7c1beb
--- /dev/null
+++ b/test/files/neg/t8534.check
@@ -0,0 +1,4 @@
+t8534.scala:6: error: MyTrait is not an enclosing class
+ class BugTest {def isTheBugHere(in: MyTrait.this.type#SomeData) = false}
+ ^
+one error found
diff --git a/test/files/neg/t8534.scala b/test/files/neg/t8534.scala
new file mode 100644
index 0000000000..f118d22b82
--- /dev/null
+++ b/test/files/neg/t8534.scala
@@ -0,0 +1,7 @@
+object line1 {
+ trait MyTrait
+}
+object line2 {
+ import line2._
+ class BugTest {def isTheBugHere(in: MyTrait.this.type#SomeData) = false}
+}
diff --git a/test/files/neg/t8534b.check b/test/files/neg/t8534b.check
new file mode 100644
index 0000000000..39ffa41194
--- /dev/null
+++ b/test/files/neg/t8534b.check
@@ -0,0 +1,4 @@
+t8534b.scala:3: error: stable identifier required, but foo.type found.
+ type T = foo.type#Foo
+ ^
+one error found
diff --git a/test/files/neg/t8534b.scala b/test/files/neg/t8534b.scala
new file mode 100644
index 0000000000..73b6703a9c
--- /dev/null
+++ b/test/files/neg/t8534b.scala
@@ -0,0 +1,4 @@
+object Test {
+ def foo = ""
+ type T = foo.type#Foo
+}
diff --git a/test/files/neg/t8597.check b/test/files/neg/t8597.check
new file mode 100644
index 0000000000..bc945f9191
--- /dev/null
+++ b/test/files/neg/t8597.check
@@ -0,0 +1,21 @@
+t8597.scala:2: warning: abstract type T in type pattern Some[T] is unchecked since it is eliminated by erasure
+ def nowarn[T] = (null: Any) match { case _: Some[T] => } // warn (did not warn due to SI-8597)
+ ^
+t8597.scala:5: warning: abstract type pattern T is unchecked since it is eliminated by erasure
+ def warn1[T] = (null: Any) match { case _: T => } // warn
+ ^
+t8597.scala:6: warning: non-variable type argument String in type pattern Some[String] is unchecked since it is eliminated by erasure
+ def warn2 = (null: Any) match { case _: Some[String] => } // warn
+ ^
+t8597.scala:7: warning: non-variable type argument Unchecked.this.C in type pattern Some[Unchecked.this.C] is unchecked since it is eliminated by erasure
+ (null: Any) match { case _: Some[C] => } // warn
+ ^
+t8597.scala:18: warning: abstract type T in type pattern Array[T] is unchecked since it is eliminated by erasure
+ def warnArray[T] = (null: Any) match { case _: Array[T] => } // warn (did not warn due to SI-8597)
+ ^
+t8597.scala:26: warning: non-variable type argument String in type pattern Array[Array[List[String]]] is unchecked since it is eliminated by erasure
+ def warnArrayErasure2 = (null: Any) match {case Some(_: Array[Array[List[String]]]) => } // warn
+ ^
+error: No warnings can be incurred under -Xfatal-warnings.
+6 warnings found
+one error found
diff --git a/test/files/neg/t8597.flags b/test/files/neg/t8597.flags
new file mode 100644
index 0000000000..85d8eb2ba2
--- /dev/null
+++ b/test/files/neg/t8597.flags
@@ -0,0 +1 @@
+-Xfatal-warnings
diff --git a/test/files/neg/t8597.scala b/test/files/neg/t8597.scala
new file mode 100644
index 0000000000..068e87d91a
--- /dev/null
+++ b/test/files/neg/t8597.scala
@@ -0,0 +1,27 @@
+class Unchecked[C] {
+ def nowarn[T] = (null: Any) match { case _: Some[T] => } // warn (did not warn due to SI-8597)
+
+ // These warned before.
+ def warn1[T] = (null: Any) match { case _: T => } // warn
+ def warn2 = (null: Any) match { case _: Some[String] => } // warn
+ (null: Any) match { case _: Some[C] => } // warn
+
+ // These must remain without warnings. These are excerpts from
+ // related tests that are more exhauative.
+ class C; class D extends C
+ def okay = (List(new D) : Seq[D]) match { case _: List[C] => case _ => } // nowarn
+ class B2[A, B]
+ class A2[X] extends B2[X, String]
+ def okay2(x: A2[Int]) = x match { case _: B2[Int, _] => true } // nowarn
+ def okay3(x: A2[Int]) = x match { case _: B2[Int, typeVar] => true } // nowarn
+
+ def warnArray[T] = (null: Any) match { case _: Array[T] => } // warn (did not warn due to SI-8597)
+ def nowarnArrayC = (null: Any) match { case _: Array[C] => } // nowarn
+
+ def nowarnArrayTypeVar[T] = (null: Any) match { case _: Array[t] => } // nowarn
+
+ def noWarnArrayErasure1 = (null: Any) match {case Some(_: Array[String]) => } // nowarn
+ def noWarnArrayErasure2 = (null: Any) match {case Some(_: Array[List[_]]) => } // nowarn
+ def noWarnArrayErasure3 = (null: Any) match {case Some(_: Array[Array[List[_]]]) => } // nowarn
+ def warnArrayErasure2 = (null: Any) match {case Some(_: Array[Array[List[String]]]) => } // warn
+}
diff --git a/test/files/neg/t8597b.check b/test/files/neg/t8597b.check
new file mode 100644
index 0000000000..3c45a31337
--- /dev/null
+++ b/test/files/neg/t8597b.check
@@ -0,0 +1,6 @@
+t8597b.scala:18: warning: non-variable type argument T in type pattern Some[T] is unchecked since it is eliminated by erasure
+ case _: Some[T] => // warn
+ ^
+error: No warnings can be incurred under -Xfatal-warnings.
+one warning found
+one error found
diff --git a/test/files/neg/t8597b.flags b/test/files/neg/t8597b.flags
new file mode 100644
index 0000000000..85d8eb2ba2
--- /dev/null
+++ b/test/files/neg/t8597b.flags
@@ -0,0 +1 @@
+-Xfatal-warnings
diff --git a/test/files/neg/t8597b.scala b/test/files/neg/t8597b.scala
new file mode 100644
index 0000000000..b29d591cb1
--- /dev/null
+++ b/test/files/neg/t8597b.scala
@@ -0,0 +1,21 @@
+object Unchecked {
+ (null: Any) match {
+ case _: Some[t] =>
+
+ // t is a fresh pattern type variable, despite our attempts to
+ // backtick our way to the enclosing `t`. Under this interpretation,
+ // the absense of an unchecked warning is expected.
+ (null: Any) match {
+ case _: Some[t] => // no warn
+ }
+ (null: Any) match {
+ case _: Some[`t`] => // no warn
+ }
+
+ // here we correctly issue an unchecked warning
+ type T = t
+ (null: Any) match {
+ case _: Some[T] => // warn
+ }
+ }
+}
diff --git a/test/files/neg/t9008.check b/test/files/neg/t9008.check
new file mode 100644
index 0000000000..c32bc41baf
--- /dev/null
+++ b/test/files/neg/t9008.check
@@ -0,0 +1,4 @@
+t9008.scala:2: error: type M takes type parameters
+ def x: List[M forSome { type M[_] }] = ???
+ ^
+one error found
diff --git a/test/files/neg/t9008.scala b/test/files/neg/t9008.scala
new file mode 100644
index 0000000000..c6a5389e42
--- /dev/null
+++ b/test/files/neg/t9008.scala
@@ -0,0 +1,3 @@
+object Test {
+ def x: List[M forSome { type M[_] }] = ???
+}
diff --git a/test/files/neg/t9008b.check b/test/files/neg/t9008b.check
new file mode 100644
index 0000000000..5e911fc138
--- /dev/null
+++ b/test/files/neg/t9008b.check
@@ -0,0 +1,4 @@
+t9008b.scala:2: error: type M takes type parameters
+ type T = M forSome { type M[_] }
+ ^
+one error found
diff --git a/test/files/neg/t9008b.scala b/test/files/neg/t9008b.scala
new file mode 100644
index 0000000000..58f9d0e8de
--- /dev/null
+++ b/test/files/neg/t9008b.scala
@@ -0,0 +1,3 @@
+object Test {
+ type T = M forSome { type M[_] }
+}
diff --git a/test/files/neg/t963.check b/test/files/neg/t963.check
index 4dc202c7bd..483e53c77d 100644
--- a/test/files/neg/t963.check
+++ b/test/files/neg/t963.check
@@ -1,9 +1,9 @@
-t963.scala:14: error: stable identifier required, but Test.this.y3.x found.
+t963.scala:14: error: stable identifier required, but y3.x.type found.
val w3 : y3.x.type = y3.x
- ^
-t963.scala:17: error: stable identifier required, but Test.this.y4.x found.
+ ^
+t963.scala:17: error: stable identifier required, but y4.x.type found.
val w4 : y4.x.type = y4.x
- ^
+ ^
t963.scala:10: error: type mismatch;
found : AnyRef{def x: Integer}
required: AnyRef{val x: Integer}
diff --git a/test/files/neg/unchecked-abstract.check b/test/files/neg/unchecked-abstract.check
index 72019082ac..703929dca8 100644
--- a/test/files/neg/unchecked-abstract.check
+++ b/test/files/neg/unchecked-abstract.check
@@ -4,6 +4,9 @@ unchecked-abstract.scala:16: warning: abstract type H in type Contravariant[M.th
unchecked-abstract.scala:21: warning: abstract type H in type Contravariant[M.this.H] is unchecked since it is eliminated by erasure
/* warn */ println(x.isInstanceOf[Contravariant[H]])
^
+unchecked-abstract.scala:22: warning: abstract type T in type Contravariant[M.this.T] is unchecked since it is eliminated by erasure
+ /* warn */ println(x.isInstanceOf[Contravariant[T]])
+ ^
unchecked-abstract.scala:27: warning: abstract type T in type Invariant[M.this.T] is unchecked since it is eliminated by erasure
/* warn */ println(x.isInstanceOf[Invariant[T]])
^
@@ -22,6 +25,15 @@ unchecked-abstract.scala:36: warning: abstract type H in type Invariant[M.this.H
unchecked-abstract.scala:37: warning: abstract type T in type Invariant[M.this.T] is unchecked since it is eliminated by erasure
/* warn */ println(x.isInstanceOf[Invariant[T]])
^
+unchecked-abstract.scala:42: warning: abstract type T in type Covariant[M.this.T] is unchecked since it is eliminated by erasure
+ /* warn */ println(x.isInstanceOf[Covariant[T]])
+ ^
+unchecked-abstract.scala:43: warning: abstract type L in type Covariant[M.this.L] is unchecked since it is eliminated by erasure
+ /* warn */ println(x.isInstanceOf[Covariant[L]])
+ ^
+unchecked-abstract.scala:48: warning: abstract type L in type Covariant[M.this.L] is unchecked since it is eliminated by erasure
+ /* warn */ println(x.isInstanceOf[Covariant[L]])
+ ^
error: No warnings can be incurred under -Xfatal-warnings.
-8 warnings found
+12 warnings found
one error found
diff --git a/test/files/pos/sammy_exist.flags b/test/files/pos/sammy_exist.flags
new file mode 100644
index 0000000000..48fd867160
--- /dev/null
+++ b/test/files/pos/sammy_exist.flags
@@ -0,0 +1 @@
+-Xexperimental
diff --git a/test/files/pos/sammy_exist.scala b/test/files/pos/sammy_exist.scala
new file mode 100644
index 0000000000..f05ae20463
--- /dev/null
+++ b/test/files/pos/sammy_exist.scala
@@ -0,0 +1,17 @@
+// scala> typeOf[java.util.stream.Stream[_]].nonPrivateMember(TermName("map")).info
+// [R](x$1: java.util.function.Function[_ >: T, _ <: R])java.util.stream.Stream[R]
+
+// java.util.function.Function
+trait Fun[A, B] { def apply(x: A): B }
+
+// java.util.stream.Stream
+class S[T](x: T) { def map[R](f: Fun[_ >: T, _ <: R]): R = f(x) }
+
+class Bla { def foo: Bla = this }
+
+// NOTE: inferred types show unmoored skolems, should pack them to display properly as bounded wildcards
+object T {
+ val aBlaSAM = (new S(new Bla)).map(_.foo)
+ val fun: Fun[Bla, Bla] = (x: Bla) => x
+ val aBlaSAMX = (new S(new Bla)).map(fun)
+}
diff --git a/test/files/pos/sammy_overload.flags b/test/files/pos/sammy_overload.flags
new file mode 100644
index 0000000000..48fd867160
--- /dev/null
+++ b/test/files/pos/sammy_overload.flags
@@ -0,0 +1 @@
+-Xexperimental
diff --git a/test/files/pos/sammy_overload.scala b/test/files/pos/sammy_overload.scala
new file mode 100644
index 0000000000..5472248f4d
--- /dev/null
+++ b/test/files/pos/sammy_overload.scala
@@ -0,0 +1,9 @@
+trait Consumer[T] {
+ def consume(x: T): Unit
+}
+
+object Test {
+ def foo(x: String): Unit = ???
+ def foo(): Unit = ???
+ val f: Consumer[_ >: String] = foo
+} \ No newline at end of file
diff --git a/test/files/pos/sammy_override.flags b/test/files/pos/sammy_override.flags
new file mode 100644
index 0000000000..48fd867160
--- /dev/null
+++ b/test/files/pos/sammy_override.flags
@@ -0,0 +1 @@
+-Xexperimental
diff --git a/test/files/pos/sammy_override.scala b/test/files/pos/sammy_override.scala
new file mode 100644
index 0000000000..a1d0651c39
--- /dev/null
+++ b/test/files/pos/sammy_override.scala
@@ -0,0 +1,8 @@
+trait IntConsumer {
+ def consume(x: Int): Unit
+}
+
+object Test {
+ def anyConsumer(x: Any): Unit = ???
+ val f: IntConsumer = anyConsumer
+} \ No newline at end of file
diff --git a/test/files/pos/t3439.scala b/test/files/pos/t3439.scala
new file mode 100644
index 0000000000..ccc75cc4cf
--- /dev/null
+++ b/test/files/pos/t3439.scala
@@ -0,0 +1,26 @@
+class Base[M](i: Int)
+
+// was "implicit modifier not allowed on top level objects"
+class D1()(implicit i: Int) extends Base({println(i); 0})
+
+// what "no implicit value of type Int found"
+class D2()(implicit i: Int) extends Base(implicitly[Int])
+
+
+abstract class ParametricMessage[M: Manifest](msg: M) { def message = msg }
+case class ParametricMessage1[M: Manifest](msg: M, p1: Class[_]) extends ParametricMessage(msg)
+
+
+class Wrap {
+ class Base[M](i: Int)
+
+ // was "implicit modifier not allowed on top level objects"
+ class D1()(implicit i: Int) extends Base({println(i); 0})
+
+ // what "no implicit value of type Int found"
+ class D2()(implicit i: Int) extends Base(implicitly[Int])
+
+
+ abstract class ParametricMessage[M: Manifest](msg: M) { def message = msg }
+ case class ParametricMessage1[M: Manifest](msg: M, p1: Class[_]) extends ParametricMessage(msg)
+}
diff --git a/test/files/pos/t5217.scala b/test/files/pos/t5217.scala
new file mode 100644
index 0000000000..1fe3f5696f
--- /dev/null
+++ b/test/files/pos/t5217.scala
@@ -0,0 +1,17 @@
+// private types and terms of companion module are
+// available in scope of ctor params.
+// before 2.10.1, class B in object A cannot be accessed in object A
+object A {
+ private class B
+ private val b: B = new B
+ private type C = Int
+ def apply(): A = new A()
+}
+// if not private, then default arg results in:
+// private class B escapes its defining scope as part of type A.B
+class A private (b: A.B = A.b, c: A.C = 42)
+
+object C {
+ private class B
+}
+class C(b: C.B)
diff --git a/test/files/pos/t5413.scala b/test/files/pos/t5413.scala
new file mode 100644
index 0000000000..47af514a14
--- /dev/null
+++ b/test/files/pos/t5413.scala
@@ -0,0 +1,9 @@
+object Fail {
+ def nom (guard : => Boolean) (something : => Unit) { }
+ def main(args: Array[String]) {
+ nom {
+ val i = 0
+ (i != 3)
+ }()
+ }
+}
diff --git a/test/files/pos/t5454.scala b/test/files/pos/t5454.scala
new file mode 100644
index 0000000000..4045f3b57b
--- /dev/null
+++ b/test/files/pos/t5454.scala
@@ -0,0 +1,10 @@
+object IllegalInheritance {
+ trait A
+ implicit def a = new A {} // def => val
+ //val r = implicitly[A] // uncomment
+
+ class B[T](t : T)(implicit a : A) // remove implicit param block
+
+ class C extends B/*[Int]*/(23) // uncomment
+ val c = new C // comment
+}
diff --git a/test/files/pos/t5639.flags b/test/files/pos/t5639.flags
new file mode 100644
index 0000000000..0acce1e7ce
--- /dev/null
+++ b/test/files/pos/t5639.flags
@@ -0,0 +1 @@
+-Xsource:2.12
diff --git a/test/files/pos/t5639/A_1.scala b/test/files/pos/t5639/A_1.scala
new file mode 100644
index 0000000000..c5da10eae4
--- /dev/null
+++ b/test/files/pos/t5639/A_1.scala
@@ -0,0 +1,17 @@
+import Implicits._
+
+class Baz
+
+object Test {
+ implicitly[Int]
+}
+
+object Implicits {
+ implicit val Baz: Int = 0
+ // This implicit was being ignored by `isQualifyingImplicit`
+ // if the classpath contained a class file for `class Baz`.
+ // This is because the package scope contains a speculative
+ // symbol for `object Baz` which is entered by `SymbolLoaders`
+ // before looking inside the class file. (A Java originated
+ // classfile results in the class/module symbol pair.)
+}
diff --git a/test/files/pos/t5639/A_2.scala b/test/files/pos/t5639/A_2.scala
new file mode 100644
index 0000000000..2bb36273e0
--- /dev/null
+++ b/test/files/pos/t5639/A_2.scala
@@ -0,0 +1,11 @@
+import Implicits._
+
+class Baz
+
+object Test {
+ implicitly[Int]
+}
+
+object Implicits {
+ implicit val Baz: Int = 0
+}
diff --git a/test/files/pos/t5639/Bar.scala b/test/files/pos/t5639/Bar.scala
deleted file mode 100644
index f577500acd..0000000000
--- a/test/files/pos/t5639/Bar.scala
+++ /dev/null
@@ -1,7 +0,0 @@
-package pack.age
-
-import pack.age.Implicits._
-
-object Quux {
- def baz : Baz = 1
-}
diff --git a/test/files/pos/t5639/Foo.scala b/test/files/pos/t5639/Foo.scala
deleted file mode 100644
index 1a07734a8e..0000000000
--- a/test/files/pos/t5639/Foo.scala
+++ /dev/null
@@ -1,7 +0,0 @@
-package pack.age
-
-class Baz
-
-object Implicits {
- implicit def Baz(n: Int): Baz = new Baz
-}
diff --git a/test/files/pos/t6051.scala b/test/files/pos/t6051.scala
new file mode 100644
index 0000000000..854524feb9
--- /dev/null
+++ b/test/files/pos/t6051.scala
@@ -0,0 +1,19 @@
+object Foo1 {
+ def foo(x: Int, y: Int = 10) = x*y
+ lazy val y = foo(x = 20)
+}
+
+object Foo2 {
+ def foo(x: Int, y: Int = 10) = x*y
+ val y = foo(x = 20)
+}
+
+object Foo3 {
+ def foo(x: Int, y: Int = 10) = x*y
+ def y = foo(x = 20)
+}
+
+object Foo4 {
+ def foo(x: Int, y: Int = 10) = x*y
+ var y = foo(x = 20)
+}
diff --git a/test/files/pos/t7596/A_1.scala b/test/files/pos/t7596/A_1.scala
new file mode 100644
index 0000000000..6303c6d132
--- /dev/null
+++ b/test/files/pos/t7596/A_1.scala
@@ -0,0 +1,10 @@
+trait Driver {
+ abstract class Table
+}
+
+object Config {
+ val driver : Driver = ???
+ def driver(a: Any) = ???
+}
+
+object Sites extends Config.driver.Table
diff --git a/test/files/pos/t7596/B_2.scala b/test/files/pos/t7596/B_2.scala
new file mode 100644
index 0000000000..977e5c8bd1
--- /dev/null
+++ b/test/files/pos/t7596/B_2.scala
@@ -0,0 +1,19 @@
+object Test {
+ locally {
+ Sites: Config.driver.Table
+ }
+}
+
+// Under separate compilation, the pickler is foiled by the
+// overloaded term `Config.driver`, and results in:
+
+// qbin/scalac test/files/pos/t7596/A_1.scala && qbin/scalac -explaintypes test/files/pos/t7596/B_2.scala
+// test/files/pos/t7596/B_2.scala:3: error: type mismatch;
+// found : Sites.type
+// required: Config.driver.Table
+// Sites: Config.driver.Table
+// ^
+// Sites.type <: Config.driver.Table?
+// Driver.this.type = Config.driver.type?
+// false
+// false \ No newline at end of file
diff --git a/test/files/pos/t7596b/A.scala b/test/files/pos/t7596b/A.scala
new file mode 100644
index 0000000000..65c1bc56ef
--- /dev/null
+++ b/test/files/pos/t7596b/A.scala
@@ -0,0 +1,10 @@
+trait H2Driver{
+ abstract class Table[T]
+}
+
+object Config {
+ val driver : H2Driver = ???
+ def driver(app: Any): H2Driver = ???
+}
+
+class Sites extends Config.driver.Table[String]
diff --git a/test/files/pos/t7596b/B.scala b/test/files/pos/t7596b/B.scala
new file mode 100644
index 0000000000..cbcf149c23
--- /dev/null
+++ b/test/files/pos/t7596b/B.scala
@@ -0,0 +1,6 @@
+class DAOBase[E]{
+ type TableType <: Config.driver.Table[E]
+}
+class SitesDAO extends DAOBase[String]{
+ type TableType = Sites
+}
diff --git a/test/files/pos/t7596c/A_1.scala b/test/files/pos/t7596c/A_1.scala
new file mode 100644
index 0000000000..3e366df477
--- /dev/null
+++ b/test/files/pos/t7596c/A_1.scala
@@ -0,0 +1,11 @@
+trait Driver {
+ abstract class Table
+}
+
+object Config {
+ val driver : Driver = ???
+ val driverUniqueName: driver.type = driver
+ def driver(a: Any) = ???
+}
+
+object Sites extends Config.driver.Table
diff --git a/test/files/pos/t7596c/B_2.scala b/test/files/pos/t7596c/B_2.scala
new file mode 100644
index 0000000000..33da68c1ff
--- /dev/null
+++ b/test/files/pos/t7596c/B_2.scala
@@ -0,0 +1,9 @@
+object Test {
+ locally {
+ Sites: Config.driver.Table
+ }
+}
+
+// This variation worked by avoiding referring to the
+// overloaded term `Config.driver` in the parent type of
+// Sites \ No newline at end of file
diff --git a/test/files/pos/t7683-stop-after-parser/ThePlugin.scala b/test/files/pos/t7683-stop-after-parser/ThePlugin.scala
new file mode 100644
index 0000000000..cd800781dc
--- /dev/null
+++ b/test/files/pos/t7683-stop-after-parser/ThePlugin.scala
@@ -0,0 +1,31 @@
+package scala.test.plugins
+
+import scala.tools.nsc
+import nsc.Global
+import nsc.Phase
+import nsc.plugins.Plugin
+import nsc.plugins.PluginComponent
+
+class ThePlugin(val global: Global) extends Plugin {
+ import global._
+
+ val name = "timebomb"
+ val description = "Explodes if run. Maybe I haven't implemented it yet."
+ val components = List[PluginComponent](thePhase1)
+
+ private object thePhase1 extends PluginComponent {
+ val global = ThePlugin.this.global
+
+ val runsAfter = List[String]("parser")
+ override val runsBefore = List[String]("namer")
+ val phaseName = ThePlugin.this.name
+
+ def newPhase(prev: Phase) = new ThePhase(prev)
+ }
+
+ private class ThePhase(prev: Phase) extends Phase(prev) {
+ override def name = ThePlugin.this.name
+ override def run = ???
+ }
+}
+
diff --git a/test/files/pos/t7683-stop-after-parser/sample_2.flags b/test/files/pos/t7683-stop-after-parser/sample_2.flags
new file mode 100644
index 0000000000..99672cdfd3
--- /dev/null
+++ b/test/files/pos/t7683-stop-after-parser/sample_2.flags
@@ -0,0 +1 @@
+-Xplugin:. -Xplugin-require:timebomb -Ystop-after:parser
diff --git a/test/files/pos/t7683-stop-after-parser/sample_2.scala b/test/files/pos/t7683-stop-after-parser/sample_2.scala
new file mode 100644
index 0000000000..7eb11b8204
--- /dev/null
+++ b/test/files/pos/t7683-stop-after-parser/sample_2.scala
@@ -0,0 +1,6 @@
+
+package sample
+
+// just a sample that is compiled with the explosive plugin disabled
+object Sample extends App {
+}
diff --git a/test/files/pos/t7683-stop-after-parser/scalac-plugin.xml b/test/files/pos/t7683-stop-after-parser/scalac-plugin.xml
new file mode 100644
index 0000000000..2558d6fd03
--- /dev/null
+++ b/test/files/pos/t7683-stop-after-parser/scalac-plugin.xml
@@ -0,0 +1,5 @@
+<plugin>
+ <name>ignored</name>
+ <classname>scala.test.plugins.ThePlugin</classname>
+</plugin>
+
diff --git a/test/files/pos/t7750.flags b/test/files/pos/t7750.flags
new file mode 100644
index 0000000000..b216e74c97
--- /dev/null
+++ b/test/files/pos/t7750.flags
@@ -0,0 +1 @@
+-Xfatal-warnings -feature
diff --git a/test/files/pos/t7750.scala b/test/files/pos/t7750.scala
new file mode 100644
index 0000000000..befec76949
--- /dev/null
+++ b/test/files/pos/t7750.scala
@@ -0,0 +1,8 @@
+trait LazyCombiner[Elem, +To, Buff <: Growable[Elem] with Sizing]
+trait Growable[T]
+trait Sizing
+
+
+object Test {
+ null.isInstanceOf[LazyCombiner[_, _, _]] // issued an existential feature warning
+}
diff --git a/test/files/pos/t8310.flags b/test/files/pos/t8310.flags
new file mode 100644
index 0000000000..48fd867160
--- /dev/null
+++ b/test/files/pos/t8310.flags
@@ -0,0 +1 @@
+-Xexperimental
diff --git a/test/files/pos/t8310.scala b/test/files/pos/t8310.scala
new file mode 100644
index 0000000000..874caf4d3b
--- /dev/null
+++ b/test/files/pos/t8310.scala
@@ -0,0 +1,22 @@
+trait Comparinator[T] { def compare(a: T, b: T): Int }
+
+object TestOkay {
+ def sort(x: Comparinator[_ >: String]) = ()
+ sort((a: String, b: String) => a.compareToIgnoreCase(b))
+}
+
+object TestOkay2 {
+ def sort[T](x: Comparinator[_ >: T]) = ()
+ sort((a: String, b: String) => a.compareToIgnoreCase(b))
+}
+
+object TestOkay3 {
+ def sort[T](xs: Option[T], x: Comparinator[_ >: T]) = ()
+ sort(Some(""), (a: String, b: String) => a.compareToIgnoreCase(b))
+}
+
+object TestKoOverloaded {
+ def sort[T](xs: Option[T]) = ()
+ def sort[T](xs: Option[T], x: Comparinator[_ >: T]) = ()
+ sort(Some(""), (a: String, b: String) => a.compareToIgnoreCase(b))
+}
diff --git a/test/files/pos/t8893.scala b/test/files/pos/t8893.scala
new file mode 100644
index 0000000000..b87c8bdd3c
--- /dev/null
+++ b/test/files/pos/t8893.scala
@@ -0,0 +1,129 @@
+// Took > 10 minutes to run the tail call phase.
+object Test {
+ def a(): Option[String] = Some("a")
+
+ def main(args: Array[String]) {
+ a() match {
+ case Some(b1) =>
+ a() match {
+ case Some(b2) =>
+ a() match {
+ case Some(b3) =>
+ a() match {
+ case Some(b4) =>
+ a() match {
+ case Some(b5) =>
+ a() match {
+ case Some(b6) =>
+ a() match {
+ case Some(b7) =>
+ a() match {
+ case Some(b8) =>
+ a() match {
+ case Some(b9) =>
+ a() match {
+ case Some(b10) =>
+ a() match {
+ case Some(b11) =>
+ a() match {
+ case Some(b12) =>
+ a() match {
+ case Some(b13) =>
+ a() match {
+ case Some(b14) =>
+ a() match {
+ case Some(b15) =>
+ a() match {
+ case Some(b16) =>
+ a() match {
+ case Some(b17) =>
+ a() match {
+ case Some(b18) =>
+ a() match {
+ case Some(b19) =>
+ a() match {
+ case Some(b20) =>
+ a() match {
+ case Some(b21) =>
+ a() match {
+ case Some(b22) =>
+ a() match {
+ case Some(b23) =>
+ a() match {
+ case Some(b24) =>
+ a() match {
+ case Some(b25) =>
+ a() match {
+ case Some(b26) =>
+ a() match {
+ case Some(b27) =>
+ a() match {
+ case Some(b28) =>
+ a() match {
+ case Some(b29) =>
+ a() match {
+ case Some(b30) =>
+ println("yay")
+ case None => None
+ }
+ case None => None
+ }
+ case None => None
+ }
+ case None => None
+ }
+ case None => None
+ }
+ case None => None
+ }
+ case None => None
+ }
+ case None => None
+ }
+ case None => None
+ }
+ case None => None
+ }
+ case None => None
+ }
+ case None => None
+ }
+ case None => None
+ }
+ case None => None
+ }
+ case None => None
+ }
+ case None => None
+ }
+ case None => None
+ }
+ case None => None
+ }
+ case None => None
+ }
+ case None => None
+ }
+ case None => None
+ }
+ case None => None
+ }
+ case None => None
+ }
+ case None => None
+ }
+ case None => None
+ }
+ case None => None
+ }
+ case None => None
+ }
+ case None => None
+ }
+ case None => None
+ }
+ case None => None
+ }
+ }
+}
+
diff --git a/test/files/pos/t8934a/A_1.scala b/test/files/pos/t8934a/A_1.scala
new file mode 100644
index 0000000000..6c1f29d030
--- /dev/null
+++ b/test/files/pos/t8934a/A_1.scala
@@ -0,0 +1,18 @@
+import language.experimental.macros
+import reflect.macros.whitebox.Context
+
+object Unapply {
+ def impl1(c: Context)(a: c.Tree): c.Tree = {
+ import c.universe._
+ q"(new { def unapply[T](a: String): Option[(Int, String)] = ??? }).unapply($a)"
+ }
+ def unapply(a: Any): Any = macro impl1
+}
+
+object UnapplySeq {
+ def impl1(c: Context)(a: c.Tree): c.Tree = {
+ import c.universe._
+ q"(new { def unapplySeq[T](a: String): Option[(Int, Seq[String])] = ??? }).unapplySeq($a)"
+ }
+ def unapplySeq(a: Any): Any = macro impl1
+}
diff --git a/test/files/pos/t8934a/Test_2.flags b/test/files/pos/t8934a/Test_2.flags
new file mode 100644
index 0000000000..618dfe2b75
--- /dev/null
+++ b/test/files/pos/t8934a/Test_2.flags
@@ -0,0 +1 @@
+-Ystop-after:typer -Ymacro-expand:discard -nowarn
diff --git a/test/files/pos/t8934a/Test_2.scala b/test/files/pos/t8934a/Test_2.scala
new file mode 100644
index 0000000000..e1792ed3c5
--- /dev/null
+++ b/test/files/pos/t8934a/Test_2.scala
@@ -0,0 +1,12 @@
+object Test {
+ "" match {
+ case Unapply(a, b) =>
+ a: Int
+ b: String
+ case UnapplySeq(a, b1, b2) =>
+ a: Int
+ b1: String
+ b2: String
+ }
+}
+// These used to fail `too many patterns` under -Ymacro-expand:discard
diff --git a/test/files/pos/t8947/Client_2.scala b/test/files/pos/t8947/Client_2.scala
new file mode 100644
index 0000000000..1a5082a2f9
--- /dev/null
+++ b/test/files/pos/t8947/Client_2.scala
@@ -0,0 +1 @@
+object Test { X.extractor } \ No newline at end of file
diff --git a/test/files/pos/t8947/Macro_1.scala b/test/files/pos/t8947/Macro_1.scala
new file mode 100644
index 0000000000..4a5de3decb
--- /dev/null
+++ b/test/files/pos/t8947/Macro_1.scala
@@ -0,0 +1,41 @@
+import language.experimental.macros
+import scala.reflect.macros._
+import blackbox.Context
+
+object X {
+
+ def classTagOrNull[T](implicit t: reflect.ClassTag[T] = null) = t
+ // the failed search for ClassTag[T] does not issue a visible
+ // error as we fall back to the default argument. But, the
+ // macro engine things we have expanded the macro `materializeClassTag[D]()`
+ // to `EmptyTree`, and then attaches a backreference from the expansion
+ // to the expandee. This is the `MacroExpansionAttachment` tree attachment.
+ def foo[D] = classTagOrNull[D]
+
+ def extractor: Any = macro X.extractorMacro
+ def extractorMacro(c: Context): c.Expr[Any] = {
+ // Later, in reify, an unrelated use of `EmptyTree` in the AST representing
+ // the argument is now treated as a macro expansion which should be rolled
+ // back in the tree we reify! This ends up generating a call to `implicitly`
+ // which leads to an ambiguous error.
+ //
+ // Any macro call that expands to EmptyTree could have triggered this problem.
+ c.universe.reify(new { def something(data: Any) = ??? })
+ }
+
+ // Workarounds:
+ //
+ // 1. Use quasiquotes rather than `reify`. (But, beware to fully qualify all references, e.g. `_root_.scala.Predef.???`)
+ // 2. Avoid failed ClassTag lookups (e.g. in the original bug report, annotate the type argument to `map`)
+ // 3. In the macro implementation, just before calling the `reify` macro, you could call another macro
+ //
+ // def prepareReify = macro prepareReifyImpl
+ // def prepareReifyImpl(c: Context) = {
+ // val symtab = c.universe.asInstanceOf[reflect.internal.SymbolTable]
+ // symtab.EmptyTree.setAttachments(symtab.NoPosition)
+ // }
+ //
+ // To make this visible to the macro implementaiton, it will need to be compiled in an earlier stage,
+ // e.g a separate SBT sub-project.
+
+}
diff --git a/test/files/pos/t8954.flags b/test/files/pos/t8954.flags
new file mode 100644
index 0000000000..7de3c0f3ee
--- /dev/null
+++ b/test/files/pos/t8954.flags
@@ -0,0 +1 @@
+-Xfatal-warnings -deprecation
diff --git a/test/files/pos/t8954/t1.scala b/test/files/pos/t8954/t1.scala
new file mode 100644
index 0000000000..3986d9f3b5
--- /dev/null
+++ b/test/files/pos/t8954/t1.scala
@@ -0,0 +1,13 @@
+package scala.foo
+
+// 1. a class about to be made final
+@deprecatedInheritance class A {
+ def foo(): Unit = ???
+}
+
+// 1.1:
+// - no inheritance warning because same file
+// - no "override non-deprecated member" because @deprecatedInheritance
+class B2 extends A {
+ @deprecated("","") override def foo(): Unit = ???
+}
diff --git a/test/files/pos/t8954/t2.scala b/test/files/pos/t8954/t2.scala
new file mode 100644
index 0000000000..4def127832
--- /dev/null
+++ b/test/files/pos/t8954/t2.scala
@@ -0,0 +1,39 @@
+package scala.foo
+
+// 1.2 deprecated children should be fine...
+@deprecated("", "") class B extends A {
+
+ // 1.3 and shouldn't trigger the
+ // "overriding non-deprecated parent" warning
+ override def foo(): Unit = ???
+}
+
+@deprecated("","") class F {
+ // 1.4 a class inside a deprecated class should work too
+ class G extends A
+}
+
+// 2. a method about to be made final
+class C {
+ @deprecatedOverriding def foo(): Unit = ???
+}
+
+// 2.1 overriding with a deprecated def should be fine
+// and also shoudln't trigger the "deprecation is useless"
+// warning
+class D extends C {
+ @deprecated("","") override def foo(): Unit = ???
+}
+
+// 2.2 overriding from a deprecated class should be fine
+@deprecated("","") class E extends C {
+ override def foo(): Unit = ???
+}
+
+// 2.3 overriding from deeper inside a deprecated class
+// should work too
+@deprecated("","") class H {
+ class I extends C {
+ override def foo(): Unit = ???
+ }
+}
diff --git a/test/files/pos/t8962.scala b/test/files/pos/t8962.scala
new file mode 100644
index 0000000000..4331c154ba
--- /dev/null
+++ b/test/files/pos/t8962.scala
@@ -0,0 +1,31 @@
+package test.nestedcov
+
+sealed abstract class Outer[+A]
+case class Let[+A](expr: Outer[Inner[A]]) extends Outer[A]
+
+sealed abstract class Inner[+A]
+
+sealed abstract class Outer2[+A, +B]
+case class Let2[+A](expr: Outer2[Inner2[A], A]) extends Outer2[A, A]
+
+sealed abstract class Inner2[+A]
+
+sealed abstract class Outer3[+A, +B]
+case class Let3[+A](expr: Outer3[A, A]) extends Outer3[A, A]
+
+object NestedCov {
+ def run[A](nc: Outer[A]) = nc match {
+ case Let(expr) =>
+ expr : Outer[Inner[A]]
+ }
+
+ def run2[A](nc: Outer2[A, A]) = nc match {
+ case Let2(expr) =>
+ expr : Outer2[Inner2[A], A]
+ }
+
+ def run3[A](nc: Outer3[A, A]) = nc match {
+ case Let3(expr) =>
+ expr : Outer3[A, A]
+ }
+}
diff --git a/test/files/pos/t8965.flags b/test/files/pos/t8965.flags
new file mode 100644
index 0000000000..85d8eb2ba2
--- /dev/null
+++ b/test/files/pos/t8965.flags
@@ -0,0 +1 @@
+-Xfatal-warnings
diff --git a/test/files/pos/t8965.scala b/test/files/pos/t8965.scala
new file mode 100644
index 0000000000..4f39330f4e
--- /dev/null
+++ b/test/files/pos/t8965.scala
@@ -0,0 +1,7 @@
+class A {
+ def f(x: Any with AnyRef, y: Any with AnyRef) = x eq y
+ // a.scala:2: warning: Any and Any are unrelated: they will most likely never compare equal
+ // def f(x: Any with AnyRef, y: Any with AnyRef) = x eq y
+ // ^
+ // one warning found
+}
diff --git a/test/files/pos/t9008.scala b/test/files/pos/t9008.scala
new file mode 100644
index 0000000000..d11b8604f2
--- /dev/null
+++ b/test/files/pos/t9008.scala
@@ -0,0 +1,5 @@
+trait Monad[M[_]]
+
+object Test {
+ def x: Monad[M forSome { type M[_] }] = ???
+}
diff --git a/test/files/pos/t9018.scala b/test/files/pos/t9018.scala
new file mode 100644
index 0000000000..7fb4cf21b3
--- /dev/null
+++ b/test/files/pos/t9018.scala
@@ -0,0 +1,16 @@
+object TestObject {
+
+ def m(i: Int): AnyRef = i match {
+ case 0 => new C()
+ case 1 => Some(E.A).getOrElse("")
+ }
+
+ class C extends Ordered[C] {
+ def compare(that: C): Int = ???
+ }
+
+ object E extends Enumeration {
+ type CharacterClass = Value
+ val A = Value
+ }
+}
diff --git a/test/files/presentation/private-case-class-members.check b/test/files/presentation/private-case-class-members.check
new file mode 100644
index 0000000000..678f9a34e6
--- /dev/null
+++ b/test/files/presentation/private-case-class-members.check
@@ -0,0 +1 @@
+Test OK
diff --git a/test/files/presentation/private-case-class-members/Test.scala b/test/files/presentation/private-case-class-members/Test.scala
new file mode 100644
index 0000000000..e64c8238ea
--- /dev/null
+++ b/test/files/presentation/private-case-class-members/Test.scala
@@ -0,0 +1,34 @@
+import scala.tools.nsc.interactive.tests.InteractiveTest
+import scala.reflect.internal.util.SourceFile
+import scala.tools.nsc.interactive.Response
+
+object Test extends InteractiveTest {
+ override def execute(): Unit = {
+ val source = loadSourceAndWaitUntilTypechecked("State.scala")
+ checkErrors(source)
+ }
+
+ private def loadSourceAndWaitUntilTypechecked(sourceName: String): SourceFile = {
+ val sourceFile = sourceFiles.find(_.file.name == sourceName).head
+ compiler.askToDoFirst(sourceFile)
+ val res = new Response[Unit]
+ compiler.askReload(List(sourceFile), res)
+ res.get
+ askLoadedTyped(sourceFile).get
+ // the second round of type-checking makes it fail
+ compiler.askReload(List(sourceFile), res)
+ res.get
+ askLoadedTyped(sourceFile).get
+
+ sourceFile
+ }
+
+ private def checkErrors(source: SourceFile): Unit = compiler.getUnitOf(source) match {
+ case Some(unit) =>
+ val problems = unit.problems.toList
+ if(problems.isEmpty) reporter.println("Test OK")
+ else problems.foreach(problem => reporter.println(problem.msg))
+
+ case None => reporter.println("No compilation unit found for " + source.file.name)
+ }
+}
diff --git a/test/files/presentation/private-case-class-members/src/State.scala b/test/files/presentation/private-case-class-members/src/State.scala
new file mode 100644
index 0000000000..c31817076c
--- /dev/null
+++ b/test/files/presentation/private-case-class-members/src/State.scala
@@ -0,0 +1,5 @@
+object State
+case class State(private val foo: Int)
+
+case class State2(private val foo: Int)
+object State2
diff --git a/test/files/presentation/quasiquotes.flags b/test/files/presentation/quasiquotes.flags
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/test/files/presentation/quasiquotes.flags
diff --git a/test/files/presentation/t8934.check b/test/files/presentation/t8934.check
new file mode 100644
index 0000000000..0ece87f808
--- /dev/null
+++ b/test/files/presentation/t8934.check
@@ -0,0 +1,2 @@
+reload: Source.scala
+Test OK
diff --git a/test/files/presentation/t8934/Runner.scala b/test/files/presentation/t8934/Runner.scala
new file mode 100644
index 0000000000..944f458391
--- /dev/null
+++ b/test/files/presentation/t8934/Runner.scala
@@ -0,0 +1,27 @@
+import scala.tools.nsc.interactive.tests.InteractiveTest
+import scala.reflect.internal.util.SourceFile
+import scala.tools.nsc.interactive.Response
+
+object Test extends InteractiveTest {
+
+ override def execute(): Unit = {
+ val src = loadSourceAndWaitUntilTypechecked("Source.scala")
+ checkErrors(src)
+ }
+
+ private def loadSourceAndWaitUntilTypechecked(sourceName: String): SourceFile = {
+ val sourceFile = sourceFiles.find(_.file.name == sourceName).head
+ askReload(List(sourceFile)).get
+ askLoadedTyped(sourceFile).get
+ sourceFile
+ }
+
+ private def checkErrors(source: SourceFile): Unit = compiler.getUnitOf(source) match {
+ case Some(unit) =>
+ val problems = unit.problems.toList
+ if(problems.isEmpty) reporter.println("Test OK")
+ else problems.foreach(problem => reporter.println(problem.msg))
+
+ case None => reporter.println("No compilation unit found for " + source.file.name)
+ }
+}
diff --git a/test/files/presentation/t8934/src/Source.scala b/test/files/presentation/t8934/src/Source.scala
new file mode 100644
index 0000000000..769c8fd38b
--- /dev/null
+++ b/test/files/presentation/t8934/src/Source.scala
@@ -0,0 +1,10 @@
+class Quasi {
+ import reflect.runtime.universe._
+
+ def test: Unit = {
+ (null: Any) match {
+ case q"$foo($bar)" =>
+ }
+ ()
+ }
+}
diff --git a/test/files/presentation/t8941.check b/test/files/presentation/t8941.check
new file mode 100644
index 0000000000..341804903a
--- /dev/null
+++ b/test/files/presentation/t8941.check
@@ -0,0 +1,7 @@
+reload: Source.scala
+
+askType at Source.scala(6,7)
+================================================================================
+[response] askTypeAt (6,7)
+scala.this.Predef.???
+================================================================================
diff --git a/test/files/presentation/t8941/Runner.scala b/test/files/presentation/t8941/Runner.scala
new file mode 100644
index 0000000000..0a8923a583
--- /dev/null
+++ b/test/files/presentation/t8941/Runner.scala
@@ -0,0 +1,11 @@
+import scala.tools.nsc.interactive.tests.InteractiveTest
+
+object Test extends InteractiveTest {
+ override def runDefaultTests() {
+ // make sure typer is done.. the virtual pattern matcher might translate
+ // some trees and mess up positions. But we'll catch it red handed!
+ // sourceFiles foreach (src => askLoadedTyped(src).get)
+ super.runDefaultTests()
+ }
+
+}
diff --git a/test/files/presentation/t8941/src/Source.scala b/test/files/presentation/t8941/src/Source.scala
new file mode 100644
index 0000000000..7438cccb03
--- /dev/null
+++ b/test/files/presentation/t8941/src/Source.scala
@@ -0,0 +1,8 @@
+object Foo {
+ implicit class MatCreator(val ctx: StringContext) extends AnyVal {
+ def m(args: Any*): Unit = {
+ ctx.checkLengths(args)
+ }
+ ???/*?*/
+ }
+}
diff --git a/test/files/presentation/t8941b/IdempotencyTest.scala b/test/files/presentation/t8941b/IdempotencyTest.scala
new file mode 100644
index 0000000000..af01b36898
--- /dev/null
+++ b/test/files/presentation/t8941b/IdempotencyTest.scala
@@ -0,0 +1,73 @@
+package scala.tools.nsc
+package interactive
+package tests.core
+
+import reporters.{Reporter => CompilerReporter}
+import scala.tools.nsc.interactive.InteractiveReporter
+import scala.reflect.internal.util.SourceFile
+
+/** Determistically interrupts typechecking of `code` when a defintion named
+ * `MagicInterruptionMarker` is typechecked, and then performs a targetted
+ * typecheck of the tree at the specal comment marker marker
+ */
+abstract class IdempotencyTest { self =>
+ private val settings = new Settings
+ settings.usejavacp.value = true
+
+ private object Break extends scala.util.control.ControlThrowable
+
+ private val compilerReporter: CompilerReporter = new InteractiveReporter {
+ override def compiler = self.compiler
+ }
+
+ object compiler extends Global(settings, compilerReporter) {
+ override def checkForMoreWork(pos: Position) {
+ }
+ override def signalDone(context: Context, old: Tree, result: Tree) {
+ // println("signalDone: " + old.toString.take(50).replaceAll("\n", "\\n"))
+ if (!interrupted && analyzer.lockedCount == 0 && interruptsEnabled && shouldInterrupt(result)) {
+ interrupted = true
+ val typed = typedTreeAt(markerPosition)
+ checkTypedTree(typed)
+ throw Break
+ }
+ super.signalDone(context, old, result)
+ }
+
+ // we're driving manually using our own thread, disable the check here.
+ override def assertCorrectThread() {}
+ }
+
+ import compiler._
+
+ private var interrupted = false
+
+ // Extension points
+ protected def code: String
+ protected def shouldInterrupt(tree: Tree): Boolean = {
+ tree.symbol != null && tree.symbol.name.toString == "MagicInterruptionMarker"
+ }
+ protected def checkTypedTree(tree: Tree): Unit = {}
+
+
+ private val source: SourceFile = newSourceFile(code)
+ private def markerPosition: Position = source.position(code.indexOf("/*?*/"))
+
+ def assertNoProblems() {
+ val problems = getUnit(source).get.problems
+ assert(problems.isEmpty, problems.mkString("\n"))
+ }
+
+ def show() {
+ reloadSource(source)
+ try {
+ typedTree(source, true)
+ assert(false, "Expected to break out of typechecking.")
+ } catch {
+ case Break => // expected
+ }
+ assertNoProblems()
+ }
+
+ def main(args: Array[String]) { show() }
+}
diff --git a/test/files/presentation/t8941b/Test.scala b/test/files/presentation/t8941b/Test.scala
new file mode 100644
index 0000000000..7269a14286
--- /dev/null
+++ b/test/files/presentation/t8941b/Test.scala
@@ -0,0 +1,53 @@
+import scala.tools.nsc.interactive.tests.core.IdempotencyTest
+
+// At the time of writing this test, removing any part of `enterExistingSym`
+// leads to a failure.
+object Test {
+ def main(args: Array[String]) {
+ test("""
+ object Foo {
+ def term {
+ def foo(c: String = "") = c
+ class MagicInterruptionMarker
+ foo()/*?*/
+ }
+ }
+ """)
+
+ test("""
+ object Foo {
+ def term {
+ def foo = 42
+ class MagicInterruptionMarker
+ foo/*?*/
+ }
+ }
+ """)
+
+ test("""
+ object Foo {
+ def term {
+ lazy val foo = 42
+ class MagicInterruptionMarker
+ foo/*?*/
+ }
+ }
+ """)
+
+ test("""
+ object Foo {
+ implicit class C(val a: String) extends AnyVal
+ class MagicInterruptionMarker
+ ""/*?*/
+ }
+ """)
+ }
+
+ def test(code0: String) {
+ val t = new IdempotencyTest {
+ def code = code0
+ }
+ t.show()
+ }
+}
+
diff --git a/test/files/res/t6613.check b/test/files/res/t6613.check
new file mode 100644
index 0000000000..bbd9331b16
--- /dev/null
+++ b/test/files/res/t6613.check
@@ -0,0 +1,5 @@
+
+nsc>
+nsc>
+nsc>
+nsc>
diff --git a/test/files/res/t6613.res b/test/files/res/t6613.res
new file mode 100644
index 0000000000..e3fa000fdd
--- /dev/null
+++ b/test/files/res/t6613.res
@@ -0,0 +1,3 @@
+t6613/Enummy.java
+t6613/Broken.scala
+t6613/Broken.scala
diff --git a/test/files/res/t6613/Broken.scala b/test/files/res/t6613/Broken.scala
new file mode 100644
index 0000000000..9bcd12dbe1
--- /dev/null
+++ b/test/files/res/t6613/Broken.scala
@@ -0,0 +1 @@
+class Broken() { def broken() = Enummy.Broke.CHIP }
diff --git a/test/files/res/t6613/Enummy.java b/test/files/res/t6613/Enummy.java
new file mode 100644
index 0000000000..1863ef1297
--- /dev/null
+++ b/test/files/res/t6613/Enummy.java
@@ -0,0 +1 @@
+public class Enummy { public enum Broke { SHARD, CHIP } }
diff --git a/test/files/res/t8871.check b/test/files/res/t8871.check
new file mode 100644
index 0000000000..bbd9331b16
--- /dev/null
+++ b/test/files/res/t8871.check
@@ -0,0 +1,5 @@
+
+nsc>
+nsc>
+nsc>
+nsc>
diff --git a/test/files/res/t8871.res b/test/files/res/t8871.res
new file mode 100644
index 0000000000..9b1a5fb57f
--- /dev/null
+++ b/test/files/res/t8871.res
@@ -0,0 +1,4 @@
+t8871/tag.scala
+t8871/usetag.scala
+t8871/usetag.scala
+
diff --git a/test/files/res/t8871/tag.scala b/test/files/res/t8871/tag.scala
new file mode 100644
index 0000000000..1a1803b77d
--- /dev/null
+++ b/test/files/res/t8871/tag.scala
@@ -0,0 +1,3 @@
+class Tag {
+ @inline def apply[@specialized A, T](a: A): A = a
+}
diff --git a/test/files/res/t8871/usetag.scala b/test/files/res/t8871/usetag.scala
new file mode 100644
index 0000000000..139d768552
--- /dev/null
+++ b/test/files/res/t8871/usetag.scala
@@ -0,0 +1,6 @@
+trait Foo
+
+object Test {
+ val y = new Tag().apply[Double, Foo](3.3)
+ // under FSC, this gave t8871/usetag.scala:4: error: wrong number of type parameters for method apply$mDc$sp: [T](a: Double)Double
+}
diff --git a/test/files/run/delambdafy_uncurry_byname_inline.check b/test/files/run/delambdafy_uncurry_byname_inline.check
index 0dc69b379a..d96a995f44 100644
--- a/test/files/run/delambdafy_uncurry_byname_inline.check
+++ b/test/files/run/delambdafy_uncurry_byname_inline.check
@@ -7,7 +7,7 @@ package <empty> {
};
def bar(x: () => Int): Int = x.apply();
def foo(): Int = Foo.this.bar({
- @SerialVersionUID(0) final <synthetic> class $anonfun extends scala.runtime.AbstractFunction0[Int] with Serializable {
+ @SerialVersionUID(value = 0) final <synthetic> class $anonfun extends scala.runtime.AbstractFunction0[Int] with Serializable {
def <init>(): <$anon: () => Int> = {
$anonfun.super.<init>();
()
diff --git a/test/files/run/delambdafy_uncurry_inline.check b/test/files/run/delambdafy_uncurry_inline.check
index e2b024b462..5521cc4a2c 100644
--- a/test/files/run/delambdafy_uncurry_inline.check
+++ b/test/files/run/delambdafy_uncurry_inline.check
@@ -7,7 +7,7 @@ package <empty> {
};
def bar(): Unit = {
val f: Int => Int = {
- @SerialVersionUID(0) final <synthetic> class $anonfun extends scala.runtime.AbstractFunction1[Int,Int] with Serializable {
+ @SerialVersionUID(value = 0) final <synthetic> class $anonfun extends scala.runtime.AbstractFunction1[Int,Int] with Serializable {
def <init>(): <$anon: Int => Int> = {
$anonfun.super.<init>();
()
diff --git a/test/files/run/global-showdef.check b/test/files/run/global-showdef.check
index 4c2fd41a1a..4ac96b4315 100644
--- a/test/files/run/global-showdef.check
+++ b/test/files/run/global-showdef.check
@@ -1,14 +1,14 @@
<<-- class foo.bar.Bippy after phase 'typer' -->>
def showdefTestMemberClass1: Int
+<<-- object foo.bar.Bippy after phase 'typer' -->>
+ def showdefTestMemberObject2: String
<<-- type foo.bar.Bippy.BippyType after phase 'typer' -->>
def showdefTestMemberType1: Unit
+<<-- object foo.bar.Bippy.Boppity.Boo after phase 'typer' -->>
+ def showdefTestMemberObject1: String
<<-- type foo.bar.Bippy.BippyType after phase 'typer' -->>
def showdefTestMemberType2: Unit
<<-- class foo.bar.Bippy.Boppity after phase 'typer' -->>
def showdefTestMemberClass2: Int
<<-- class foo.bar.Bippy.Boppity.Boo after phase 'typer' -->>
def showdefTestMemberClass3: Int
-<<-- object foo.bar.Bippy after phase 'typer' -->>
- def showdefTestMemberObject2: String
-<<-- object foo.bar.Bippy.Boppity.Boo after phase 'typer' -->>
- def showdefTestMemberObject1: String
diff --git a/test/files/run/global-showdef.scala b/test/files/run/global-showdef.scala
index 1d4891fd1f..276fcc1e7c 100644
--- a/test/files/run/global-showdef.scala
+++ b/test/files/run/global-showdef.scala
@@ -1,11 +1,10 @@
-import scala.tools.nsc._
-import scala.reflect.io.AbstractFile
+import scala.tools.partest.DirectTest
import scala.tools.nsc.util.stringFromStream
-import scala.reflect.internal.util.{ SourceFile, BatchSourceFile }
-import scala.tools.nsc.reporters.ConsoleReporter
-object Test {
- val src: SourceFile = new BatchSourceFile("src", """
+object Test extends DirectTest {
+ override def extraSettings: String = "-usejavacp -Yshow:typer -Ystop-after:typer"
+
+ override def code = """
package foo.bar
class Bippy {
@@ -32,39 +31,28 @@ object Bippy {
def showdefTestMemberObject2 = "abc"
}
- """)
+ """
+
+ override def show(): Unit = {
+ val classes = List("Bippy", "Bippy#BippyType", "Bippy.BippyType", "Bippy#Boppity", "Bippy#Boppity#Boo")
+ val objects = List("Bippy", "Bippy#Boppity#Boo")
+
+ def interesting(line: String) = (line contains "def showdefTestMember") || (line startsWith "<<-- ")
- def mkCompiler(args: String*) = {
- val settings = new Settings()
- val command = new CompilerCommand("-usejavacp" :: args.toList, settings)
+ def run(args: String*) = slurp(args: _*).lines filter interesting foreach println
- new Global(settings)
+ classes.zipAll(objects, "", "") foreach {
+ case (c, "") => run("-Xshow-class", c)
+ case (c, o) => run("-Xshow-class", c, "-Xshow-object", o)
+ }
}
- def slurp(body: => Unit): String = stringFromStream { stream =>
+ // slurp the compilation result
+ def slurp(args: String*): String = stringFromStream { stream =>
Console.withOut(stream) {
Console.withErr(stream) {
- body
+ compile(args: _*)
}
}
}
- def lines(args: String*): List[String] = {
- val output = slurp {
- val compiler = mkCompiler(args: _*)
- val run = new compiler.Run()
- run.compileSources(List(src))
- }
- output.lines.toList
- }
- def showClass(name: String) = lines("-Yshow:typer", "-Xshow-class", name)
- def showObject(name: String) = lines("-Yshow:typer", "-Xshow-object", name)
-
- def show(xs: List[String]) = {
- xs filter (x => (x contains "def showdefTestMember") || (x startsWith "<<-- ")) foreach println
- }
-
- def main(args: Array[String]) {
- show(List("Bippy", "Bippy#BippyType", "Bippy.BippyType", "Bippy#Boppity", "Bippy#Boppity#Boo") flatMap showClass)
- show(List("Bippy", "Bippy#Boppity#Boo") flatMap showObject)
- }
}
diff --git a/test/files/run/iterator-concat.check b/test/files/run/iterator-concat.check
deleted file mode 100644
index 23835b07ae..0000000000
--- a/test/files/run/iterator-concat.check
+++ /dev/null
@@ -1,4 +0,0 @@
-100
-1000
-10000
-100000
diff --git a/test/files/run/iterator-concat.scala b/test/files/run/iterator-concat.scala
deleted file mode 100644
index f11363410f..0000000000
--- a/test/files/run/iterator-concat.scala
+++ /dev/null
@@ -1,15 +0,0 @@
-object Test {
- // Create `size` Function0s, each of which evaluates to an Iterator
- // which produces 1. Then fold them over ++ to get a single iterator,
- // which should sum to "size".
- def mk(size: Int): Iterator[Int] = {
- val closures = (1 to size).toList.map(x => (() => Iterator(1)))
- closures.foldLeft(Iterator.empty: Iterator[Int])((res, f) => res ++ f())
- }
- def main(args: Array[String]): Unit = {
- println(mk(100).sum)
- println(mk(1000).sum)
- println(mk(10000).sum)
- println(mk(100000).sum)
- }
-}
diff --git a/test/files/run/iterator-iterate-lazy.scala b/test/files/run/iterator-iterate-lazy.scala
deleted file mode 100644
index 92b170062e..0000000000
--- a/test/files/run/iterator-iterate-lazy.scala
+++ /dev/null
@@ -1,5 +0,0 @@
-object Test {
- def main(args: Array[String]): Unit = {
- Iterator.iterate((1 to 5).toList)(_.tail).takeWhile(_.nonEmpty).map(_.head).toList
- }
-}
diff --git a/test/files/run/iterators.check b/test/files/run/iterators.check
deleted file mode 100644
index bb139c1610..0000000000
--- a/test/files/run/iterators.check
+++ /dev/null
@@ -1,13 +0,0 @@
-test check_from was successful
-test check_range was successful
-test check_range2 was successful
-test check_range3 was successful
-test check_take was successful
-test check_drop was successful
-test check_foreach was successful
-test check_forall was successful
-test check_fromArray was successful
-test check_toSeq was successful
-test check_indexOf was successful
-test check_findIndexOf was successful
-
diff --git a/test/files/run/iterators.scala b/test/files/run/iterators.scala
deleted file mode 100644
index 57e05d3472..0000000000
--- a/test/files/run/iterators.scala
+++ /dev/null
@@ -1,136 +0,0 @@
-//############################################################################
-// Iterators
-//############################################################################
-
-//############################################################################
-
-import scala.language.postfixOps
-
-object Test {
-
- def check_from: Int = {
- val it1 = Iterator.from(-1)
- val it2 = Iterator.from(0, -1)
- it1.next + it2.next
- }
-
- def check_range: Int = {
- val xs1 = Iterator.range(0, 10, 2) toList;
- val xs2 = Iterator.range(0, 10, -2) toList;
- val xs3 = Iterator.range(10, 0, -2) toList;
- val xs4 = Iterator.range(10, 0, 2) toList;
- val xs5 = Iterator.range(0, 10, 11) toList;
- xs1.length + xs2.length + xs3.length + xs4.length + xs5.length
- }
-
- def check_range2: Int = {
- val r1start = 0
- val r1end = 10
- val r1step = 1
- val r1 = Iterator.range(r1start, r1end, r1step) toList;
- val r2 = Iterator.range(r1start, r1end, r1step + 1) toList;
- val r3 = Iterator.range(r1end, r1start, -r1step) toList;
- val r4 = Iterator.range(0, 10, 11) toList;
- // 10 + 5 + 10 + 1
- r1.length + r2.length + r3.length + r4.length
- }
-
- def check_range3: Int = {
- def trues(xs: List[Boolean]) = xs.foldLeft(0)((a, b) => if (b) a+1 else a)
- val r1 = Iterator.range(0, 10)
- val xs1 = List(r1 contains 5, r1 contains 6)
- val r2a = Iterator.range(0, 10, 2)
- val r2b = Iterator.range(0, 10, 2)
- val xs2 = List(r2a contains 5, r2b contains 6)
- val r3 = Iterator.range(0, 10, 11)
- val xs3 = List(r3 contains 5, r3 contains 6)
- // 2 + 1 + 0
- trues(xs1) + trues(xs2) + trues(xs3)
- }
-
- def check_take: Int = {
- val it1 = Iterator.from(0)
- val xs1 = it1 take 10 toList;
- xs1.length
- }
-
- def check_drop: Int = {
- val it1 = Iterator.from(0)
- val it2 = it1 map { 2 * _ }
- val n1 = it1 drop 2 next
- val n2 = it2 drop 2 next;
- n1 + n2
- }
-
- def check_foreach: Int = {
- val it1 = Iterator.from(0) take 20
- var n = 0
- it1 foreach { n += _ }
- n
- }
-
- def check_forall: Int = {
- val it1 = Iterator.from(0)
- val it2 = Iterator.from(1)
- 0
- }
-
- def check_fromArray: Int = { // ticket #429
- val a = List(1, 2, 3, 4).toArray
- var xs0 = a.iterator.toList;
- var xs1 = a.slice(0, 1).iterator.toList;
- var xs2 = a.slice(0, 2).iterator.toList;
- var xs3 = a.slice(0, 3).iterator.toList;
- var xs4 = a.slice(0, 4).iterator.toList;
- xs0.length + xs1.length + xs2.length + xs3.length + xs4.length
- }
-
- def check_toSeq: String =
- List(1, 2, 3, 4, 5).iterator.toSeq.mkString("x")
-
- def check_indexOf: String = {
- val i = List(1, 2, 3, 4, 5).indexOf(4)
- val j = List(1, 2, 3, 4, 5).indexOf(16)
- "" + i + "x" + j
- }
-
- def check_findIndexOf: String = {
- val i = List(1, 2, 3, 4, 5).indexWhere { x: Int => x >= 4 }
- val j = List(1, 2, 3, 4, 5).indexWhere { x: Int => x >= 16 }
- "" + i + "x" + j
- }
-
- def check_success[A](name: String, closure: => A, expected: A) {
- print("test " + name)
- try {
- val actual: A = closure
- if (actual == expected)
- print(" was successful")
- else
- print(" failed: expected "+ expected +", found "+ actual)
- }
- catch {
- case exception: Throwable =>
- print(" raised exception " + exception)
- }
- println()
- }
-
- def main(args: Array[String]) {
- check_success("check_from", check_from, -1)
- check_success("check_range", check_range, 11)
- check_success("check_range2", check_range2, 26)
- check_success("check_range3", check_range3, 3)
- check_success("check_take", check_take, 10)
- check_success("check_drop", check_drop, 12)
- check_success("check_foreach", check_foreach, 190)
- check_success("check_forall", check_forall, 0)
- check_success("check_fromArray",check_fromArray, 14)
- check_success("check_toSeq", check_toSeq, "1x2x3x4x5")
- check_success("check_indexOf", check_indexOf, "3x-1")
- check_success("check_findIndexOf", check_findIndexOf, "3x-1")
- println()
- }
-}
-
-//############################################################################
diff --git a/test/files/run/literals.check b/test/files/run/literals.check
index 62c5fd68ae..092340eead 100644
--- a/test/files/run/literals.check
+++ b/test/files/run/literals.check
@@ -1,57 +1,12 @@
-warning: there were 5 deprecation warnings; re-run with -deprecation for details
-test '\u0024' == '$' was successful
-test '\u005f' == '_' was successful
-test 65.asInstanceOf[Char] == 'A' was successful
-test "\141\142" == "ab" was successful
-test "\0x61\0x62".trim() == "x61\0x62" was successful
-
-test (65 : Byte) == 'A' was successful
-
-test 0X01 == 1 was successful
-test 0x01 == 1 was successful
-test 0x10 == 16 was successful
-test 0xa == 10 was successful
-test 0x0a == 10 was successful
-test +0x01 == 1 was successful
-test +0x10 == 16 was successful
-test +0xa == 10 was successful
-test +0x0a == 10 was successful
-test -0x01 == -1 was successful
-test -0x10 == -16 was successful
-test -0xa == -10 was successful
-test -0x0a == -10 was successful
-test 0x7fffffff == 2147483647 was successful
-test 0x80000000 == -2147483648 was successful
-test 0xffffffff == -1 was successful
-
-test 1l == 1L was successful
-test 1L == 1l was successful
-test 1.asInstanceOf[Long] == 1l was successful
-test 0x7fffffffffffffffL == 9223372036854775807L was successful
-test 0x8000000000000000L == -9223372036854775808L was successful
-test 0xffffffffffffffffL == -1L was successful
-
-test 1e1f == 10.0f was successful
-test .3f == 0.3f was successful
-test 0f == 0.0f was successful
-test 01.23f == 1.23f was successful
-test 3.14f == 3.14f was successful
-test 6.022e23f == 6.022e23f was successful
-test 09f == 9.0f was successful
-test 1.asInstanceOf[Float] == 1.0 was successful
-test 1l.asInstanceOf[Float] == 1.0 was successful
-
-test 1e1 == 10.0 was successful
-test .3 == 0.3 was successful
-test 0.0 == 0.0 was successful
-test 0d == 0.0 was successful
-test 01.23 == 1.23 was successful
-test 01.23d == 1.23d was successful
-test 3.14 == 3.14 was successful
-test 1e-9d == 1.0e-9 was successful
-test 1e137 == 1.0e137 was successful
-test 1.asInstanceOf[Double] == 1.0 was successful
-test 1l.asInstanceOf[Double] == 1.0 was successful
-
-test "".length() was successful
-test ggg == 3 was successful
+literals.scala:34: warning: Octal escape literals are deprecated, use \u0061 instead.
+ check_success("\"\\141\\142\" == \"ab\"", "\141\142", "ab")
+ ^
+literals.scala:34: warning: Octal escape literals are deprecated, use \u0062 instead.
+ check_success("\"\\141\\142\" == \"ab\"", "\141\142", "ab")
+ ^
+literals.scala:37: warning: Octal escape literals are deprecated, use \u0000 instead.
+ "\0x61\0x62".getBytes(io.Codec.UTF8.charSet) sameElements Array[Byte](0, 120, 54, 49, 0, 120, 54, 50),
+ ^
+literals.scala:37: warning: Octal escape literals are deprecated, use \u0000 instead.
+ "\0x61\0x62".getBytes(io.Codec.UTF8.charSet) sameElements Array[Byte](0, 120, 54, 49, 0, 120, 54, 50),
+ ^
diff --git a/test/files/run/literals.flags b/test/files/run/literals.flags
new file mode 100644
index 0000000000..dcc59ebe32
--- /dev/null
+++ b/test/files/run/literals.flags
@@ -0,0 +1 @@
+-deprecation
diff --git a/test/files/run/literals.scala b/test/files/run/literals.scala
index 5f23e6b492..13fda05876 100644
--- a/test/files/run/literals.scala
+++ b/test/files/run/literals.scala
@@ -14,21 +14,16 @@ object Test {
def \u03b1\u03b1(that: GGG) = i + that.i
}
- def check_success[a](name: String, closure: => a, expected: a) {
- print("test " + name)
- try {
- val actual: a = closure
- if (actual == expected) {
- print(" was successful");
- } else {
- print(" failed: expected "+ expected +", found "+ actual);
+ def check_success[A](name: String, closure: => A, expected: A) {
+ val res: Option[String] =
+ try {
+ val actual: A = closure
+ if (actual == expected) None //print(" was successful")
+ else Some(s" failed: expected $expected, found $actual")
+ } catch {
+ case exception: Throwable => Some(s" raised exception $exception")
}
- } catch {
- case exception: Throwable => {
- print(" raised exception " + exception);
- }
- }
- println
+ for (e <- res) println(s"test $name $e")
}
def main(args: Array[String]) {
@@ -37,15 +32,14 @@ object Test {
check_success("'\\u005f' == '_'", '\u005f', '_')
check_success("65.asInstanceOf[Char] == 'A'", 65.asInstanceOf[Char], 'A')
check_success("\"\\141\\142\" == \"ab\"", "\141\142", "ab")
- check_success("\"\\0x61\\0x62\".trim() == \"x61\\0x62\"", "\0x61\0x62".substring(1), "x61\0x62")
-
- println
+ //check_success("\"\\0x61\\0x62\".trim() == \"x61\\0x62\"", "\0x61\0x62".substring(1), "x61\0x62")
+ check_success(""""\0x61\0x62".getBytes == Array(0, 120, ...)""",
+ "\0x61\0x62".getBytes(io.Codec.UTF8.charSet) sameElements Array[Byte](0, 120, 54, 49, 0, 120, 54, 50),
+ true)
// boolean
check_success("(65 : Byte) == 'A'", (65: Byte) == 'A', true) // contrib #176
- println
-
// int
check_success("0X01 == 1", 0X01, 1)
check_success("0x01 == 1", 0x01, 1)
@@ -67,8 +61,6 @@ object Test {
check_success("0x80000000 == -2147483648", 0x80000000, -2147483648)
check_success("0xffffffff == -1", 0xffffffff, -1)
- println
-
// long
check_success("1l == 1L", 1l, 1L)
check_success("1L == 1l", 1L, 1l)
@@ -81,8 +73,6 @@ object Test {
check_success("0xffffffffffffffffL == -1L",
0xffffffffffffffffL, -1L)
- println
-
// see JLS at address:
// http://java.sun.com/docs/books/jls/second_edition/html/lexical.doc.html#230798
@@ -97,8 +87,6 @@ object Test {
check_success("1.asInstanceOf[Float] == 1.0", 1.asInstanceOf[Float], 1.0f)
check_success("1l.asInstanceOf[Float] == 1.0", 1l.asInstanceOf[Float], 1.0f)
- println
-
// double
check_success("1e1 == 10.0", 1e1, 10.0)
check_success(".3 == 0.3", .3, 0.3)
@@ -112,7 +100,6 @@ object Test {
check_success("1.asInstanceOf[Double] == 1.0", 1.asInstanceOf[Double], 1.0)
check_success("1l.asInstanceOf[Double] == 1.0", 1l.asInstanceOf[Double], 1.0)
- println
check_success("\"\".length()", "\u001a".length(), 1)
val ggg = GGG(1) \u03b1\u03b1 GGG(2)
diff --git a/test/files/run/priorityQueue.scala b/test/files/run/priorityQueue.scala
deleted file mode 100644
index 327d8bf137..0000000000
--- a/test/files/run/priorityQueue.scala
+++ /dev/null
@@ -1,373 +0,0 @@
-
-
-
-import scala.collection.mutable.PriorityQueue
-
-
-
-
-
-
-// populate a priority queue a few different ways and make sure they all seem equal
-object Test {
-
- def main(args: Array[String]) {
- // testInsertionsAndEqualities
- // testIntensiveEnqueueDequeue
- // testTails
- // testInits
- // testFilters
- // testDrops
- // testEquality
- // testMisc
- // testReverse
- // testToList
- // testForeach
- }
-
- // def testInsertionsAndEqualities {
- // import scala.util.Random.nextInt
- // val pq1 = new PriorityQueue[String]
- // val pq2 = new PriorityQueue[String]
- // val pq3 = new PriorityQueue[String]
- // val pq4 = new PriorityQueue[String]
-
- // val strings = (1 to 20).toList map (i => List.fill((Math.abs(nextInt % 20)) + 1)("x").mkString)
-
- // pq1 ++= strings
- // pq2 ++= strings.reverse
- // for (s <- strings) pq3 += s
- // for (s <- strings.reverse) pq4 += s
-
- // val pqs = List(pq1, pq2, pq3, pq4, pq1.clone, pq2.clone)
-
- // for (queue1 <- pqs ; queue2 <- pqs) {
- // val l1: List[String] = queue1.dequeueAll[String, List[String]]
- // val l2: List[String] = queue2.dequeueAll[String, List[String]]
- // assert(l1 == l2)
- // assert(queue1.max == queue2.max)
- // }
-
- // assertPriorityDestructive(pq1)
- // }
-
- // not a sequence anymore, Mildred
- // def testIndexing {
- // val pq = new PriorityQueue[Char]
- // "The quick brown fox jumps over the lazy dog".foreach(pq += _)
-
- // // val iter = pq.iterator
- // // while (iter.hasNext) println("`" + iter.next + "`")
- // assert(pq(0) == 'z')
- // assert(pq(1) == 'y')
- // assert(pq(2) == 'x')
- // assert(pq(3) == 'w')
- // assert(pq(4) == 'v')
- // assert(pq(5) == 'u')
- // assert(pq(7) == 't')
- // assert(pq(8) == 's')
- // assert(pq(9) == 'r')
- // assert(pq(10) == 'r')
-
- // pq.clear
- // "abcdefghijklmnopqrstuvwxyz".foreach(pq += _)
- // for (i <- 0 until 26) assert(pq(i) == ('z' - i))
-
- // val intpq = new PriorityQueue[Int]
- // val intlst = new collection.mutable.ArrayBuffer ++ (0 until 100)
- // val random = new util.Random(101)
- // while (intlst.nonEmpty) {
- // val idx = random.nextInt(intlst.size)
- // intpq += intlst(idx)
- // intlst.remove(idx)
- // }
- // for (i <- 0 until 100) assert(intpq(i) == (99 - i))
- // }
-
- // def testTails {
- // val pq = new PriorityQueue[Int]
- // for (i <- 0 until 10) pq += i * 4321 % 200
-
- // assert(pq.size == 10)
- // assert(pq.nonEmpty)
-
- // val tailpq = pq.tail
- // // pq.printstate
- // // tailpq.printstate
- // assert(tailpq.size == 9)
- // assert(tailpq.nonEmpty)
- // assertPriorityDestructive(tailpq)
- // }
-
- // def assertPriorityDestructive[A](pq: PriorityQueue[A])(implicit ord: Ordering[A]) {
- // import ord._
- // var prev: A = null.asInstanceOf[A]
- // while (pq.nonEmpty) {
- // val curr = pq.dequeue
- // if (prev != null) assert(curr <= prev)
- // prev = curr
- // }
- // }
-
- // def testInits {
- // val pq = new PriorityQueue[Long]
- // for (i <- 0 until 20) pq += (i + 313) * 111 % 300
-
- // assert(pq.size == 20)
-
- // val initpq = pq.init
- // assert(initpq.size == 19)
- // assertPriorityDestructive(initpq)
- // }
-
- // def testFilters {
- // val pq = new PriorityQueue[String]
- // for (i <- 0 until 100) pq += "Some " + (i * 312 % 200)
-
- // val filpq = pq.filter(_.indexOf('0') != -1)
- // assertPriorityDestructive(filpq)
- // }
-
- // def testIntensiveEnqueueDequeue {
- // val pq = new PriorityQueue[Int]
-
- // testIntensive(1000, pq)
- // pq.clear
- // testIntensive(200, pq)
- // }
-
- // def testIntensive(sz: Int, pq: PriorityQueue[Int]) {
- // val lst = new collection.mutable.ArrayBuffer[Int] ++ (0 until sz)
- // val rand = new util.Random(7)
- // while (lst.nonEmpty) {
- // val idx = rand.nextInt(lst.size)
- // pq.enqueue(lst(idx))
- // lst.remove(idx)
- // if (rand.nextDouble < 0.25 && pq.nonEmpty) pq.dequeue
- // assertPriority(pq)
- // }
- // }
-
- // def testDrops {
- // val pq = new PriorityQueue[Int]
- // pq ++= (0 until 100)
- // val droppq = pq.drop(50)
- // assertPriority(droppq)
-
- // pq.clear
- // pq ++= droppq
- // assertPriorityDestructive(droppq)
- // assertPriority(pq)
- // assertPriorityDestructive(pq)
- // }
-
- // // your sequence days have ended, foul priority queue
- // // def testUpdates {
- // // val pq = new PriorityQueue[Int]
- // // pq ++= (0 until 36)
- // // assertPriority(pq)
-
- // // pq(0) = 100
- // // assert(pq(0) == 100)
- // // assert(pq.dequeue == 100)
- // // assertPriority(pq)
-
- // // pq.clear
-
- // // pq ++= (1 to 100)
- // // pq(5) = 200
- // // assert(pq(0) == 200)
- // // assert(pq(1) == 100)
- // // assert(pq(2) == 99)
- // // assert(pq(3) == 98)
- // // assert(pq(4) == 97)
- // // assert(pq(5) == 96)
- // // assert(pq(6) == 94)
- // // assert(pq(7) == 93)
- // // assert(pq(98) == 2)
- // // assert(pq(99) == 1)
- // // assertPriority(pq)
-
- // // pq(99) = 450
- // // assert(pq(0) == 450)
- // // assert(pq(1) == 200)
- // // assert(pq(99) == 2)
- // // assertPriority(pq)
-
- // // pq(1) = 0
- // // assert(pq(1) == 100)
- // // assert(pq(99) == 0)
- // // assertPriority(pq)
- // // assertPriorityDestructive(pq)
- // // }
-
- // def testEquality {
- // val pq1 = new PriorityQueue[Int]
- // val pq2 = new PriorityQueue[Int]
-
- // pq1 ++= (0 until 50)
- // var i = 49
- // while (i >= 0) {
- // pq2 += i
- // i -= 1
- // }
- // assert(pq1 == pq2)
- // assertPriority(pq2)
-
- // pq1 += 100
- // assert(pq1 != pq2)
- // pq2 += 100
- // assert(pq1 == pq2)
- // pq2 += 200
- // assert(pq1 != pq2)
- // pq1 += 200
- // assert(pq1 == pq2)
- // assertPriorityDestructive(pq1)
- // assertPriorityDestructive(pq2)
- // }
-
- // def testMisc {
- // val pq = new PriorityQueue[Int]
- // pq ++= (0 until 100)
- // assert(pq.size == 100)
-
- // val (p1, p2) = pq.partition(_ < 50)
- // assertPriorityDestructive(p1)
- // assertPriorityDestructive(p2)
-
- // val spq = pq.slice(25, 75)
- // assertPriorityDestructive(spq)
-
- // pq.clear
- // pq ++= (0 until 10)
- // pq += 5
- // assert(pq.size == 11)
-
- // val ind = pq.lastIndexWhere(_ == 5)
- // assert(ind == 5)
- // assertPriorityDestructive(pq)
-
- // pq.clear
- // pq ++= (0 until 10)
- // assert(pq.lastIndexWhere(_ == 9) == 0)
- // assert(pq.lastIndexOf(8) == 1)
- // assert(pq.lastIndexOf(7) == 2)
-
- // pq += 5
- // pq += 9
- // assert(pq.lastIndexOf(9) == 1)
- // assert(pq.lastIndexWhere(_ % 2 == 1) == 10)
- // assert(pq.lastIndexOf(5) == 6)
-
- // val lst = pq.reverseIterator.toList
- // for (i <- 0 until 5) assert(lst(i) == i)
- // assert(lst(5) == 5)
- // assert(lst(6) == 5)
- // assert(lst(7) == 6)
- // assert(lst(8) == 7)
- // assert(lst(9) == 8)
- // assert(lst(10) == 9)
- // assert(lst(11) == 9)
-
- // pq.clear
- // assert(pq.reverseIterator.toList.isEmpty)
-
- // pq ++= (50 to 75)
- // assert(pq.lastIndexOf(70) == 5)
-
- // pq += 55
- // pq += 70
- // assert(pq.lastIndexOf(70) == 6)
- // assert(pq.lastIndexOf(55) == 22)
- // assert(pq.lastIndexOf(55, 21) == 21)
- // assert(pq.lastIndexWhere(_ > 54) == 22)
- // assert(pq.lastIndexWhere(_ > 54, 21) == 21)
- // assert(pq.lastIndexWhere(_ > 69, 5) == 5)
- // }
-
- // def testReverse {
- // val pq = new PriorityQueue[(Int, Int)]
- // pq ++= (for (i <- 0 until 10) yield (i, i * i % 10))
-
- // assert(pq.reverse.size == pq.reverseIterator.toList.size)
- // assert((pq.reverse zip pq.reverseIterator.toList).forall(p => p._1 == p._2))
- // assert(pq.reverse.sameElements(pq.reverseIterator.toSeq))
- // assert(pq.reverse(0)._1 == pq(9)._1)
- // assert(pq.reverse(1)._1 == pq(8)._1)
- // assert(pq.reverse(4)._1 == pq(5)._1)
- // assert(pq.reverse(9)._1 == pq(0)._1)
-
- // pq += ((7, 7))
- // pq += ((7, 9))
- // pq += ((7, 8))
- // assert(pq.reverse.reverse == pq)
- // assert(pq.reverse.lastIndexWhere(_._2 == 6) == 6)
- // assertPriorityDestructive(pq.reverse.reverse)
-
- // val iq = new PriorityQueue[Int]
- // iq ++= (0 until 50)
- // assert(iq.reverse == iq.reverseIterator.toSeq)
- // assert(iq.reverse.reverse == iq)
-
- // iq += 25
- // iq += 40
- // iq += 10
- // assert(iq.reverse == iq.reverseIterator.toList)
- // assert(iq.reverse.reverse == iq)
- // assert(iq.reverse.lastIndexWhere(_ == 10) == 11)
- // assertPriorityDestructive(iq.reverse.reverse)
- // }
-
- // def testToList {
- // val pq = new PriorityQueue[Int]
-
- // pq += 1
- // pq += 4
- // pq += 0
- // pq += 5
- // pq += 3
- // pq += 2
- // assert(pq.toList == pq)
- // assert(pq == List(5, 4, 3, 2, 1, 0))
- // assert(pq.reverse == List(0, 1, 2, 3, 4, 5))
-
- // pq.clear
- // for (i <- -50 until 50) pq += i
- // assert(pq.toList == pq)
- // assert(pq.toList == (-50 until 50).reverse)
- // }
-
- // def testForeach {
- // val pq = new PriorityQueue[Char]
-
- // pq += 't'
- // pq += 'o'
- // pq += 'b'
- // pq += 'y'
- // val sbf = new StringBuilder
- // val sbi = new StringBuilder
- // pq.foreach(sbf += _)
- // pq.iterator.foreach(sbi += _)
- // assert(sbf.toString == sbi.toString)
- // assert(sbf.toString == "ytob")
- // }
-
-}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/test/files/run/repl-javap-lambdas.scala b/test/files/run/repl-javap-lambdas.scala
new file mode 100644
index 0000000000..15e5bf6877
--- /dev/null
+++ b/test/files/run/repl-javap-lambdas.scala
@@ -0,0 +1,23 @@
+import scala.tools.partest.JavapTest
+import scala.tools.nsc.Settings
+
+// see repl-javap-memfun.java for the complementary version
+object Test extends JavapTest {
+ override def transformSettings(s: Settings) = { s.Ydelambdafy.value = "method" ; s }
+ def code = """
+ |object Betty {
+ | List(1,2,3) count (_ % 2 != 0)
+ | def f = List(1,2,3) filter (_ % 2 != 0) map (_ * 2)
+ | def g = List(1,2,3) filter (_ % 2 == 0) map (_ * 3) map (_ + 1)
+ |}
+ |:javap -fun Betty#g
+ """.stripMargin
+
+ // three anonfuns of Betty#g
+ override def yah(res: Seq[String]) = {
+ import PartialFunction.{ cond => when }
+ val r = """\s*private static final .* \$anonfun\$\d+\(.*""".r
+ def filtered = res filter (when(_) { case r(_*) => true })
+ 3 == filtered.size
+ }
+}
diff --git a/test/files/run/repl-javap-memfun.scala b/test/files/run/repl-javap-memfun.scala
index d2b4243c8b..d10ebcb399 100644
--- a/test/files/run/repl-javap-memfun.scala
+++ b/test/files/run/repl-javap-memfun.scala
@@ -1,6 +1,10 @@
import scala.tools.partest.JavapTest
+import scala.tools.nsc.Settings
+// see repl-javap-lambdas.scala for the complementary version
object Test extends JavapTest {
+ // asserting the default
+ override def transformSettings(s: Settings) = { s.Ydelambdafy.value = "inline" ; s }
def code = """
|object Betty {
| List(1,2,3) count (_ % 2 != 0)
diff --git a/test/files/run/repl-javap-outdir-funs.flags b/test/files/run/repl-javap-outdir-funs.flags
new file mode 100644
index 0000000000..ac96850b69
--- /dev/null
+++ b/test/files/run/repl-javap-outdir-funs.flags
@@ -0,0 +1 @@
+-Ydelambdafy:inline \ No newline at end of file
diff --git a/test/files/run/repl-javap-outdir-funs/run-repl_7.scala b/test/files/run/repl-javap-outdir-funs/run-repl_7.scala
index 6c6fe2d515..af9651a8a3 100644
--- a/test/files/run/repl-javap-outdir-funs/run-repl_7.scala
+++ b/test/files/run/repl-javap-outdir-funs/run-repl_7.scala
@@ -1,6 +1,8 @@
import scala.tools.partest.JavapTest
object Test extends JavapTest {
+ // note the '-fun': it makes :javap search for some anonfun.
+ // for that reason, this test has a flags file that forces delambdafy:inline (doesn't allow :method)
def code = """
|:javap -fun disktest/Foo.class
""".stripMargin
@@ -11,7 +13,8 @@ object Test extends JavapTest {
if (scala.tools.partest.utils.Properties.isAvian)
true
else {
- def filtered = res filter (_ contains "public final class disktest.Foo")
+ val r = "public final class disktest.Foo.*extends scala.runtime.AbstractFunction1".r
+ def filtered = res filter (r.findFirstIn(_).nonEmpty)
1 == filtered.size
}
}
diff --git a/test/files/run/sammy_repeated.check b/test/files/run/sammy_repeated.check
new file mode 100644
index 0000000000..1cff0f067c
--- /dev/null
+++ b/test/files/run/sammy_repeated.check
@@ -0,0 +1 @@
+WrappedArray(1)
diff --git a/test/files/run/sammy_repeated.flags b/test/files/run/sammy_repeated.flags
new file mode 100644
index 0000000000..e1b37447c9
--- /dev/null
+++ b/test/files/run/sammy_repeated.flags
@@ -0,0 +1 @@
+-Xexperimental \ No newline at end of file
diff --git a/test/files/run/sammy_repeated.scala b/test/files/run/sammy_repeated.scala
new file mode 100644
index 0000000000..c24dc41909
--- /dev/null
+++ b/test/files/run/sammy_repeated.scala
@@ -0,0 +1,8 @@
+trait RepeatedSink { def accept(a: Any*): Unit }
+
+object Test {
+ def main(args: Array[String]): Unit = {
+ val f: RepeatedSink = (a) => println(a)
+ f.accept(1)
+ }
+} \ No newline at end of file
diff --git a/test/files/run/t1994.scala b/test/files/run/t1994.scala
new file mode 100644
index 0000000000..0b463e3444
--- /dev/null
+++ b/test/files/run/t1994.scala
@@ -0,0 +1,20 @@
+class A {
+ protected def x = 0
+ protected[A] def y = 0
+}
+
+class B extends A {
+ override def x = 1
+ def superY = super[A].y
+ override def y = 1
+}
+
+
+object Test {
+ def main(args: Array[String]): Unit = {
+ val b = new B
+ assert(b.x == 1)
+ assert(b.y == 1)
+ assert(b.superY == 0)
+ }
+}
diff --git a/test/files/run/t2866.check b/test/files/run/t2866.check
new file mode 100644
index 0000000000..7f52da85fb
--- /dev/null
+++ b/test/files/run/t2866.check
@@ -0,0 +1,3 @@
+t2866.scala:30: warning: imported `one' is permanently hidden by definition of value one
+ import A.one // warning: imported `one' is permanently hidden by definition of value one.
+ ^
diff --git a/test/files/run/t2866.scala b/test/files/run/t2866.scala
new file mode 100644
index 0000000000..8059107583
--- /dev/null
+++ b/test/files/run/t2866.scala
@@ -0,0 +1,44 @@
+// for 2.7.x compatibility
+
+object A {
+ implicit val one = 1
+}
+
+object Test extends App {
+
+ locally {
+ import A._
+ locally {
+ // assert(implicitly[Int] == 1) // error: could not find implicit value for parameter e: Int.
+ // !!! Why one A.one?
+ // (I assume you mean: why _not_ A.one? A.one is shadowed by local one.
+ // but the local one cannot be used yet because it does not have an explicit type.
+ implicit val one = 2
+ assert(implicitly[Int] == 2)
+ assert(one == 2)
+ }
+ }
+
+ locally {
+ import A._
+ implicit val one: Int = 2
+ assert(implicitly[Int] == 2)
+ assert(one == 2)
+ }
+
+ locally {
+ import A.one // warning: imported `one' is permanently hidden by definition of value one.
+ // !!! Really?
+ //assert(implicitly[Int] == 1)
+ implicit val one = 2
+ assert(implicitly[Int] == 2) // !!! why not 2?
+ assert(one == 2)
+ }
+
+ locally {
+ import A.{one => _, _}
+ implicit val two = 2
+ assert(implicitly[Int] == 2) // not ambiguous in 2.8.0 nor im ambiguous in 2.7.6
+ }
+
+}
diff --git a/test/files/run/t3516.check b/test/files/run/t3516.check
deleted file mode 100644
index d0d10d82fa..0000000000
--- a/test/files/run/t3516.check
+++ /dev/null
@@ -1,3 +0,0 @@
-1
-1
-21
diff --git a/test/files/run/t3516.scala b/test/files/run/t3516.scala
deleted file mode 100644
index aa302ce85a..0000000000
--- a/test/files/run/t3516.scala
+++ /dev/null
@@ -1,13 +0,0 @@
-object Test {
- def mkIterator = (1 to 5).iterator map (x => { println(x) ; x })
- def mkInfinite = Iterator continually { println(1) ; 1 }
-
- def main(args: Array[String]): Unit = {
- // Stream is strict in its head so we should see 1 from each of them.
- val s1 = mkIterator.toStream
- val s2 = mkInfinite.toStream
- // back and forth without slipping into nontermination.
- println((Stream from 1).toIterator.drop(10).toStream.drop(10).toIterator.next)
- ()
- }
-}
diff --git a/test/files/run/t4950.check b/test/files/run/t4950.check
new file mode 100644
index 0000000000..3f3a302b62
--- /dev/null
+++ b/test/files/run/t4950.check
@@ -0,0 +1,9 @@
+Type in expressions to have them evaluated.
+Type :help for more information.
+
+scala> val 1 = 2
+scala.MatchError: 2 (of class java.lang.Integer)
+
+scala> val List(1) = List(1)
+
+scala> :quit
diff --git a/test/files/run/t4950.scala b/test/files/run/t4950.scala
new file mode 100644
index 0000000000..cef06027bf
--- /dev/null
+++ b/test/files/run/t4950.scala
@@ -0,0 +1,12 @@
+import scala.tools.partest.ReplTest
+
+object Test extends ReplTest {
+ // Filter out the abbreviated stacktrace "... X elided"
+ // because the number seems to differ between versions/platforms/...
+ override def show = eval() filterNot (_ contains "elided") foreach println
+ def code =
+"""
+val 1 = 2
+val List(1) = List(1)
+"""
+}
diff --git a/test/files/run/t5665.scala b/test/files/run/t5665.scala
new file mode 100644
index 0000000000..3ac498b5c0
--- /dev/null
+++ b/test/files/run/t5665.scala
@@ -0,0 +1,13 @@
+object O {
+ trait T {
+ private[this] val c: Int = 42
+ def f =
+ { x: Int => c }
+ }
+}
+
+object Test {
+ def main(args: Array[String]): Unit = {
+ assert(new O.T{}.f(0) == 42)
+ }
+}
diff --git a/test/files/run/t5938.scala b/test/files/run/t5938.scala
new file mode 100644
index 0000000000..59a95ac37f
--- /dev/null
+++ b/test/files/run/t5938.scala
@@ -0,0 +1,35 @@
+import scala.tools.partest.DirectTest
+
+object Test extends DirectTest {
+
+ override def extraSettings: String =
+ s"-usejavacp -d ${testOutput.path}"
+
+ override def code = """
+object O extends C {
+ def main(args: Array[String]): Unit = {
+ }
+ // Static forwarder for foo and setter_foo_= added more once in a multi-run compile.
+}
+ """.trim
+
+ override def show(): Unit = {
+ val global = newCompiler()
+ Console.withErr(System.out) {
+ compileString(global)(code)
+ compileString(global)(code)
+ loadClass // was "duplicate name and signature in class X"
+ }
+ }
+
+ def loadClass: Class[_] = {
+ val cl = new java.net.URLClassLoader(Array(testOutput.toFile.toURL));
+ cl.loadClass("O")
+ }
+}
+
+trait T {
+ val foo: String = ""
+}
+class C extends T
+
diff --git a/test/files/run/t6028.check b/test/files/run/t6028.check
index 55ff42d8d7..edc8b22d6d 100644
--- a/test/files/run/t6028.check
+++ b/test/files/run/t6028.check
@@ -24,7 +24,7 @@ package <empty> {
(new <$anon: Function0>(T.this, tryyParam, tryyLocal): Function0)
}
};
- @SerialVersionUID(0) final <synthetic> class $anonfun$foo$1 extends scala.runtime.AbstractFunction0$mcI$sp with Serializable {
+ @SerialVersionUID(value = 0) final <synthetic> class $anonfun$foo$1 extends scala.runtime.AbstractFunction0$mcI$sp with Serializable {
def <init>($outer: T, methodParam$1: Int, methodLocal$1: Int): <$anon: Function0> = {
$anonfun$foo$1.super.<init>();
()
@@ -60,7 +60,7 @@ package <empty> {
};
scala.this.Predef.print(scala.Int.box(barParam$1))
};
- @SerialVersionUID(0) final <synthetic> class $anonfun$tryy$1 extends scala.runtime.AbstractFunction0$mcV$sp with Serializable {
+ @SerialVersionUID(value = 0) final <synthetic> class $anonfun$tryy$1 extends scala.runtime.AbstractFunction0$mcV$sp with Serializable {
def <init>($outer: T, tryyParam$1: Int, tryyLocal$1: runtime.IntRef): <$anon: Function0> = {
$anonfun$tryy$1.super.<init>();
()
diff --git a/test/files/run/t6260c.check b/test/files/run/t6260c.check
index 1a57f2d741..78e9b27371 100644
--- a/test/files/run/t6260c.check
+++ b/test/files/run/t6260c.check
@@ -1,5 +1,9 @@
f(C@2e)
+#partest !-Ydelambdafy:method
Test$$anonfun$$apply
+#partest -Ydelambdafy:method
+Test$lambda$1$$apply
+#partest
apply
g(C@2e)
diff --git a/test/files/run/t6440.check b/test/files/run/t6440.check
index 2358f08fcc..4d8618182b 100644
--- a/test/files/run/t6440.check
+++ b/test/files/run/t6440.check
@@ -1,5 +1,4 @@
-pos: source-newSource1.scala,line-9,offset=109 missing or invalid dependency detected while loading class file 'U.class'.
-Could not access term pack1 in package <root>,
-because it (or its dependencies) are missing. Check your build definition for
-missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.)
-A full rebuild may help if 'U.class' was compiled against an incompatible version of <root>. ERROR
+pos: source-newSource1.scala,line-9,offset=109 reference to U is ambiguous;
+it is imported twice in the same scope by
+import pack2._
+and import X._ ERROR
diff --git a/test/files/run/t6440.scala b/test/files/run/t6440.scala
index 5a3a4150d9..94eda3642e 100644
--- a/test/files/run/t6440.scala
+++ b/test/files/run/t6440.scala
@@ -41,7 +41,7 @@ object Test extends StoreReporterDirectTest {
assert(tClass.delete())
assert(pack1.delete())
- // bad symbolic reference error expected (but no stack trace!)
+ // should report ambiguous import, despite the fact that a parent of pack2.U is absent
compileCode(app)
println(filteredInfos.mkString("\n"))
}
diff --git a/test/files/run/t6502.check b/test/files/run/t6502.check
new file mode 100644
index 0000000000..95d36ee221
--- /dev/null
+++ b/test/files/run/t6502.check
@@ -0,0 +1,8 @@
+test1 res1: true
+test1 res2: true
+test2 res1: true
+test2 res2: true
+test3 res1: true
+test3 res2: true
+test4 res1: true
+test4 res2: true
diff --git a/test/files/run/t6502.scala b/test/files/run/t6502.scala
new file mode 100644
index 0000000000..4ce034a482
--- /dev/null
+++ b/test/files/run/t6502.scala
@@ -0,0 +1,116 @@
+import scala.tools.nsc.Settings
+import scala.tools.nsc.interpreter.ILoop
+import scala.tools.nsc.settings.ClassPathRepresentationType
+import scala.tools.partest._
+
+object Test extends StoreReporterDirectTest {
+ def code = ???
+
+ def compileCode(code: String, jarFileName: String) = {
+ val classpath = List(sys.props("partest.lib"), testOutput.path) mkString sys.props("path.separator")
+ compileString(newCompiler("-cp", classpath, "-d", s"${testOutput.path}/$jarFileName"))(code)
+ }
+
+ // TODO flat classpath doesn't support the classpath invalidation yet so we force using the recursive one
+ // it's the only test which needed such a workaround
+ override def settings = {
+ val settings = new Settings
+ settings.YclasspathImpl.value = ClassPathRepresentationType.Recursive
+ settings
+ }
+
+ def app1 = """
+ package test
+
+ object Test extends App {
+ def test(): Unit = {
+ println("testing...")
+ }
+ }"""
+
+ def app2 = """
+ package test
+
+ object Test extends App {
+ def test(): Unit = {
+ println("testing differently...")
+ }
+ }"""
+
+ def app3 = """
+ package test
+
+ object Test3 extends App {
+ def test(): Unit = {
+ println("new object in existing package")
+ }
+ }"""
+
+ def test1(): Unit = {
+ val jar = "test1.jar"
+ compileCode(app1, jar)
+
+ val codeToRun = toCodeInSeparateLines(s":require ${testOutput.path}/$jar", "test.Test.test()")
+ val output = ILoop.run(codeToRun, settings)
+ val lines = output.split("\n")
+ val res1 = lines(4).contains("Added") && lines(4).contains("test1.jar")
+ val res2 = lines(lines.length-3).contains("testing...")
+
+ println(s"test1 res1: $res1")
+ println(s"test1 res2: $res2")
+ }
+
+ def test2(): Unit = {
+ // should reject jars with conflicting entries
+ val jar1 = "test1.jar"
+ val jar2 = "test2.jar"
+ compileCode(app2, jar2)
+
+ val codeToRun = toCodeInSeparateLines(s":require ${testOutput.path}/$jar1", s":require ${testOutput.path}/$jar2")
+ val output = ILoop.run(codeToRun, settings)
+ val lines = output.split("\n")
+ val res1 = lines(4).contains("Added") && lines(4).contains("test1.jar")
+ val res2 = lines(lines.length-3).contains("test2.jar") && lines(lines.length-3).contains("existing classpath entries conflict")
+
+ println(s"test2 res1: $res1")
+ println(s"test2 res2: $res2")
+ }
+
+ def test3(): Unit = {
+ // should accept jars with overlapping packages, but no conflicts
+ val jar1 = "test1.jar"
+ val jar3 = "test3.jar"
+ compileCode(app3, jar3)
+
+ val codeToRun = toCodeInSeparateLines(s":require ${testOutput.path}/$jar1", s":require ${testOutput.path}/$jar3", "test.Test3.test()")
+ val output = ILoop.run(codeToRun, settings)
+ val lines = output.split("\n")
+ val res1 = lines(4).contains("Added") && lines(4).contains("test1.jar")
+ val res2 = lines(lines.length-3).contains("new object in existing package")
+
+ println(s"test3 res1: $res1")
+ println(s"test3 res2: $res2")
+ }
+
+ def test4(): Unit = {
+ // twice the same jar should be rejected
+ val jar1 = "test1.jar"
+ val codeToRun = toCodeInSeparateLines(s":require ${testOutput.path}/$jar1", s":require ${testOutput.path}/$jar1")
+ val output = ILoop.run(codeToRun, settings)
+ val lines = output.split("\n")
+ val res1 = lines(4).contains("Added") && lines(4).contains("test1.jar")
+ val res2 = lines(lines.length-3).contains("test1.jar") && lines(lines.length-3).contains("existing classpath entries conflict")
+
+ println(s"test4 res1: $res1")
+ println(s"test4 res2: $res2")
+ }
+
+ def show(): Unit = {
+ test1()
+ test2()
+ test3()
+ test4()
+ }
+
+ def toCodeInSeparateLines(lines: String*): String = lines.map(_ + "\n").mkString
+}
diff --git a/test/files/run/t6541-option.scala b/test/files/run/t6541-option.scala
new file mode 100644
index 0000000000..2c10c9e09d
--- /dev/null
+++ b/test/files/run/t6541-option.scala
@@ -0,0 +1,19 @@
+import scala.tools.partest.ReplTest
+
+object Test extends ReplTest {
+ def code = """
+:setting -Xsource:2.12
+case class C12(clazz: Class[_])
+val o: Option[Class[T] forSome { type T}] = C12.unapply(C12(classOf[String]))
+
+:setting -Xsource:2.11
+import scala.language.existentials
+case class C11(clazz: Class[_])
+val o: Option[Class[T]] forSome { type T } = C11.unapply(C11(classOf[String]))
+ """
+
+ override def show() = {
+ val r = eval().mkString("\n")
+ assert(!(r.contains("warning") || r.contains("error")), r)
+ }
+}
diff --git a/test/files/run/t6541.flags b/test/files/run/t6541.flags
new file mode 100644
index 0000000000..68d0ddfec2
--- /dev/null
+++ b/test/files/run/t6541.flags
@@ -0,0 +1 @@
+-feature -Xfatal-warnings -Xsource:2.12 \ No newline at end of file
diff --git a/test/files/run/t6541.scala b/test/files/run/t6541.scala
new file mode 100644
index 0000000000..f127143691
--- /dev/null
+++ b/test/files/run/t6541.scala
@@ -0,0 +1,25 @@
+class A
+class B[T](x: T)
+case class C(a: A, b: B[_])
+
+case class D(a: A, b: B[_]*)
+
+case class E(c: Class[_])
+
+object Test extends App {
+ def f1(c: C) = c match {
+ case C(a, b) => ()
+ }
+
+ def f2(d: D) = d match {
+ case D(a, b1, b2) => ()
+ }
+
+ def f3(e: E) = e match {
+ case E(c) => ()
+ }
+
+ f1(C(new A, new B(1)))
+ f2(D(new A, new B(1), new B(2)))
+ f3(E(classOf[E]))
+}
diff --git a/test/files/run/t6555.check b/test/files/run/t6555.check
index 9ac115a13f..e3b467ce7c 100644
--- a/test/files/run/t6555.check
+++ b/test/files/run/t6555.check
@@ -6,7 +6,7 @@ package <empty> {
()
};
private[this] val f: Int => Int = {
- @SerialVersionUID(0) final <synthetic> class $anonfun extends scala.runtime.AbstractFunction1$mcII$sp with Serializable {
+ @SerialVersionUID(value = 0) final <synthetic> class $anonfun extends scala.runtime.AbstractFunction1$mcII$sp with Serializable {
def <init>(): <$anon: Int => Int> = {
$anonfun.super.<init>();
()
diff --git a/test/files/run/t6669.scala b/test/files/run/t6669.scala
index e18f2514a9..27c4970d60 100644
--- a/test/files/run/t6669.scala
+++ b/test/files/run/t6669.scala
@@ -1,4 +1,5 @@
import java.io.{ByteArrayOutputStream, PrintStream}
+import scala.reflect.io.File
object Test extends App {
val baos = new ByteArrayOutputStream()
@@ -9,9 +10,11 @@ object Test extends App {
scala.tools.scalap.Main.main(Array("-verbose", "java.lang.Object"))
}
+ val currentLocationCpFragment = File.pathSeparator + "."
+
// now make sure we saw the '.' in the classpath
val msg1 = baos.toString()
- assert(msg1 contains "directory classpath: .", s"Did not see '.' in the default class path. Full results were:\n$msg1")
+ assert(msg1 contains currentLocationCpFragment, s"Did not see '.' in the default class path. Full results were:\n$msg1")
// then test again with a user specified classpath
baos.reset
@@ -22,5 +25,5 @@ object Test extends App {
// now make sure we did not see the '.' in the classpath
val msg2 = baos.toString()
- assert(!(msg2 contains "directory classpath: ."), s"Did saw '.' in the user specified class path. Full results were:\n$msg2")
+ assert(!(msg2 contains currentLocationCpFragment), s"Did saw '.' in the user specified class path. Full results were:\n$msg2")
}
diff --git a/test/files/run/t7019.scala b/test/files/run/t7019.scala
new file mode 100644
index 0000000000..5dcc09d2b6
--- /dev/null
+++ b/test/files/run/t7019.scala
@@ -0,0 +1,10 @@
+final class Foo(val i: Int) extends AnyVal {
+ def foo() = go(i)
+ private[this] def go(i: Int) = i * 2
+}
+
+object Test {
+ def main(args: Array[String]): Unit = {
+ assert(new Foo(1).foo() == 2)
+ }
+}
diff --git a/test/files/run/t7407.flags b/test/files/run/t7407.flags
index c8547a27dc..be4ef0798a 100644
--- a/test/files/run/t7407.flags
+++ b/test/files/run/t7407.flags
@@ -1 +1 @@
--Ynooptimise -Ybackend:GenBCode
+-Ynooptimise -Yopt:l:none -Ybackend:GenBCode
diff --git a/test/files/run/t8253.check b/test/files/run/t8253.check
new file mode 100644
index 0000000000..0b4cb2d1f7
--- /dev/null
+++ b/test/files/run/t8253.check
@@ -0,0 +1,40 @@
+
+<sample xmlns='ns1'/>
+{
+ var $tmpscope: _root_.scala.xml.NamespaceBinding = $scope;
+ $tmpscope = new _root_.scala.xml.NamespaceBinding(null, "ns1", $tmpscope);
+ {
+ val $scope: _root_.scala.xml.NamespaceBinding = $tmpscope;
+ new _root_.scala.xml.Elem(null, "sample", _root_.scala.xml.Null, $scope, true)
+ }
+}
+
+<sample xmlns={identity(ns1)}/>
+{
+ var $tmpscope: _root_.scala.xml.NamespaceBinding = $scope;
+ $tmpscope = new _root_.scala.xml.NamespaceBinding(null, ns1, $tmpscope);
+ {
+ val $scope: _root_.scala.xml.NamespaceBinding = $tmpscope;
+ new _root_.scala.xml.Elem(null, "sample", _root_.scala.xml.Null, $scope, true)
+ }
+}
+
+<sample xmlns:foo='ns1'/>
+{
+ var $tmpscope: _root_.scala.xml.NamespaceBinding = $scope;
+ $tmpscope = new _root_.scala.xml.NamespaceBinding("foo", "ns1", $tmpscope);
+ {
+ val $scope: _root_.scala.xml.NamespaceBinding = $tmpscope;
+ new _root_.scala.xml.Elem(null, "sample", _root_.scala.xml.Null, $scope, true)
+ }
+}
+
+<sample xmlns:foo={identity(ns1)}/>
+{
+ var $tmpscope: _root_.scala.xml.NamespaceBinding = $scope;
+ $tmpscope = new _root_.scala.xml.NamespaceBinding("foo", ns1, $tmpscope);
+ {
+ val $scope: _root_.scala.xml.NamespaceBinding = $tmpscope;
+ new _root_.scala.xml.Elem(null, "sample", _root_.scala.xml.Null, $scope, true)
+ }
+}
diff --git a/test/files/run/t8253.scala b/test/files/run/t8253.scala
new file mode 100644
index 0000000000..c4800b4491
--- /dev/null
+++ b/test/files/run/t8253.scala
@@ -0,0 +1,14 @@
+object Test extends App {
+ import reflect.runtime.universe._ // not using the XML library in compiler tests
+
+ def show(code: String, t: Tree) = println(s"\n$code\n$t")
+
+ val ns1 = "ns1"
+ show("<sample xmlns='ns1'/>", q"<sample xmlns='ns1'/>")
+ show("<sample xmlns={identity(ns1)}/>", q"<sample xmlns={ns1}/>")
+ show("<sample xmlns:foo='ns1'/>", q"<sample xmlns:foo='ns1'/>")
+ show("<sample xmlns:foo={identity(ns1)}/>", q"<sample xmlns:foo={ns1}/>")
+
+ // `identity(foo)` used to match the overly permissive match in SymbolXMLBuilder
+ // which was intented to more specifically match `_root_.scala.xml.Text(...)`
+}
diff --git a/test/files/run/t8502.scala b/test/files/run/t8502.scala
new file mode 100644
index 0000000000..903e573711
--- /dev/null
+++ b/test/files/run/t8502.scala
@@ -0,0 +1,41 @@
+import scala.tools.partest._
+import java.io.File
+
+object Test extends StoreReporterDirectTest {
+ def code = ???
+
+ def compileCode(code: String) = {
+ val classpath = List(sys.props("partest.lib"), testOutput.path) mkString sys.props("path.separator")
+ compileString(newCompiler("-cp", classpath, "-d", testOutput.path))(code)
+ }
+
+ def show(): Unit = {
+ compileCode("""
+ object U {
+ def foo(log: vanishing.Vanishing) = ()
+ }
+
+ package vanishing {
+ class Vanishing
+ }
+ """)
+ assert(filteredInfos.isEmpty, filteredInfos)
+ deletePackage("vanishing")
+ compileCode("""
+ class Test {
+ U
+ }
+ """)
+ assert(storeReporter.infos.isEmpty, storeReporter.infos.mkString("\n")) // Included a MissingRequirementError before.
+ }
+
+ def deletePackage(name: String) {
+ val directory = new File(testOutput.path, name)
+ for (f <- directory.listFiles()) {
+ assert(f.getName.endsWith(".class"))
+ assert(f.delete())
+ }
+ assert(directory.listFiles().isEmpty)
+ assert(directory.delete())
+ }
+}
diff --git a/test/files/run/t8549.scala b/test/files/run/t8549.scala
index d3355208fa..cb254e3810 100644
--- a/test/files/run/t8549.scala
+++ b/test/files/run/t8549.scala
@@ -79,9 +79,12 @@ object Test extends App {
}
}
- // Generated on 20140505-14:47:14 with Scala version 2.11.1-20140505-142300-e8562571d2)
+ // Generated on 20141010-14:01:28 with Scala version 2.11.2)
overwrite.foreach(updateComment)
+ check(Some(1))("rO0ABXNyAApzY2FsYS5Tb21lESLyaV6hi3QCAAFMAAF4dAASTGphdmEvbGFuZy9PYmplY3Q7eHIADHNjYWxhLk9wdGlvbv5pN/3bDmZ0AgAAeHBzcgARamF2YS5sYW5nLkludGVnZXIS4qCk94GHOAIAAUkABXZhbHVleHIAEGphdmEubGFuZy5OdW1iZXKGrJUdC5TgiwIAAHhwAAAAAQ==")
+ check(None)("rO0ABXNyAAtzY2FsYS5Ob25lJEZQJPZTypSsAgAAeHIADHNjYWxhLk9wdGlvbv5pN/3bDmZ0AgAAeHA=")
+
check(List(1, 2, 3))( "rO0ABXNyADJzY2FsYS5jb2xsZWN0aW9uLmltbXV0YWJsZS5MaXN0JFNlcmlhbGl6YXRpb25Qcm94eQAAAAAAAAABAwAAeHBzcgARamF2YS5sYW5nLkludGVnZXIS4qCk94GHOAIAAUkABXZhbHVleHIAEGphdmEubGFuZy5OdW1iZXKGrJUdC5TgiwIAAHhwAAAAAXNxAH4AAgAAAAJzcQB+AAIAAAADc3IALHNjYWxhLmNvbGxlY3Rpb24uaW1tdXRhYmxlLkxpc3RTZXJpYWxpemVFbmQkilxjW/dTC20CAAB4cHg=")
check(Nil)( "rO0ABXNyADJzY2FsYS5jb2xsZWN0aW9uLmltbXV0YWJsZS5MaXN0JFNlcmlhbGl6YXRpb25Qcm94eQAAAAAAAAABAwAAeHBzcgAsc2NhbGEuY29sbGVjdGlvbi5pbW11dGFibGUuTGlzdFNlcmlhbGl6ZUVuZCSKXGNb91MLbQIAAHhweA==")
diff --git a/test/files/run/t8601-closure-elim.flags b/test/files/run/t8601-closure-elim.flags
index 49d036a887..2b5fd8a7b2 100644
--- a/test/files/run/t8601-closure-elim.flags
+++ b/test/files/run/t8601-closure-elim.flags
@@ -1 +1 @@
--optimize
+-optimize -Ydelambdafy:inline
diff --git a/test/files/run/t8893.scala b/test/files/run/t8893.scala
new file mode 100644
index 0000000000..6fef8ae912
--- /dev/null
+++ b/test/files/run/t8893.scala
@@ -0,0 +1,40 @@
+import annotation.tailrec
+
+object Test {
+ def a(): Option[String] = Some("a")
+
+ def test1: Any = {
+ a() match {
+ case Some(b1) =>
+ a() match {
+ case Some(b2) =>
+ @tailrec
+ def tick(i: Int): Unit = if (i < 0) () else tick(i - 1)
+ tick(10000000) // testing that this doesn't SOE
+ case None => None
+ }
+ case None => None
+ }
+ }
+
+ def test2: Any = {
+ a() match {
+ case Some(b1) =>
+ a() match {
+ case Some(b2) =>
+ @tailrec
+ def tick(i: Int): Unit = if (i < 0) () else tick(i - 1)
+ tick(10000000) // testing that this doesn't SOE
+ case None => test1
+ }
+ case None =>
+ test1 // not a tail call
+ test1
+ }
+ }
+
+ def main(args: Array[String]) {
+ test1
+ test2
+ }
+}
diff --git a/test/files/run/t8893b.scala b/test/files/run/t8893b.scala
new file mode 100644
index 0000000000..19120871aa
--- /dev/null
+++ b/test/files/run/t8893b.scala
@@ -0,0 +1,15 @@
+// Testing that recursive calls in tail positions are replaced with
+// jumps, even though the method contains recursive calls outside
+// of the tail position.
+object Test {
+ def tick(i : Int): Unit =
+ if (i == 0) ()
+ else if (i == 42) {
+ tick(0) /*not in tail posiiton*/
+ tick(i - 1)
+ } else tick(i - 1)
+
+ def main(args: Array[String]): Unit = {
+ tick(1000000)
+ }
+}
diff --git a/test/files/run/t8925.check b/test/files/run/t8925.check
new file mode 100644
index 0000000000..112e7005df
--- /dev/null
+++ b/test/files/run/t8925.check
@@ -0,0 +1,2 @@
+bar
+abcd
diff --git a/test/files/run/t8925.flags b/test/files/run/t8925.flags
new file mode 100644
index 0000000000..be4ef0798a
--- /dev/null
+++ b/test/files/run/t8925.flags
@@ -0,0 +1 @@
+-Ynooptimise -Yopt:l:none -Ybackend:GenBCode
diff --git a/test/files/run/t8925.scala b/test/files/run/t8925.scala
new file mode 100644
index 0000000000..33f4505f03
--- /dev/null
+++ b/test/files/run/t8925.scala
@@ -0,0 +1,31 @@
+object Ex {
+ def unapply(t: Throwable): Option[Throwable] = Some(t)
+}
+
+class A {
+ var x = ""
+
+ def bar =
+ try {
+ "bar"
+ } finally {
+ try {
+ x += "a"
+ } finally {
+ x += "b"
+ try {
+ x += "c"
+ throw null
+ } catch {
+ case Ex(_) =>
+ x += "d"
+ }
+ }
+ }
+}
+
+object Test extends App {
+ val a = new A
+ println(a.bar)
+ println(a.x)
+}
diff --git a/test/files/run/t8931.check b/test/files/run/t8931.check
new file mode 100644
index 0000000000..d08546b5a9
--- /dev/null
+++ b/test/files/run/t8931.check
@@ -0,0 +1 @@
+List(interface B)
diff --git a/test/files/run/t8931.scala b/test/files/run/t8931.scala
new file mode 100644
index 0000000000..11718471bc
--- /dev/null
+++ b/test/files/run/t8931.scala
@@ -0,0 +1,15 @@
+
+trait A
+
+trait B extends A
+
+class C extends A with B
+
+object Test extends App {
+ val c = classOf[C]
+
+ println(c.getGenericInterfaces.toList)
+
+ assert(c.getGenericInterfaces.length == c.getInterfaces.length,
+ s"mismatch between ${c.getGenericInterfaces} and ${c.getInterfaces}")
+}
diff --git a/test/files/run/t8933.check b/test/files/run/t8933.check
new file mode 100644
index 0000000000..d5ef468b98
--- /dev/null
+++ b/test/files/run/t8933.check
@@ -0,0 +1 @@
+'traitSymbol
diff --git a/test/files/run/t8933/A_1.scala b/test/files/run/t8933/A_1.scala
new file mode 100644
index 0000000000..996e3b4a2c
--- /dev/null
+++ b/test/files/run/t8933/A_1.scala
@@ -0,0 +1,6 @@
+class MotherClass
+
+trait MixinWithSymbol {
+ self: MotherClass =>
+ def symbolFromTrait: Symbol = 'traitSymbol
+}
diff --git a/test/files/run/t8933/Test_2.scala b/test/files/run/t8933/Test_2.scala
new file mode 100644
index 0000000000..c506a7c51f
--- /dev/null
+++ b/test/files/run/t8933/Test_2.scala
@@ -0,0 +1,10 @@
+class MotherClass extends MixinWithSymbol {
+ val classSymbol = 'classSymbol
+}
+
+object Test {
+ def main(args: Array[String]) {
+ val symbol = (new MotherClass).symbolFromTrait
+ println(symbol)
+ }
+}
diff --git a/test/files/run/t8933b/A.scala b/test/files/run/t8933b/A.scala
new file mode 100644
index 0000000000..d25d893c6f
--- /dev/null
+++ b/test/files/run/t8933b/A.scala
@@ -0,0 +1,4 @@
+trait MixinWithSymbol {
+ self: MotherClass =>
+ def symbolFromTrait: Any = 'traitSymbol
+}
diff --git a/test/files/run/t8933b/Test.scala b/test/files/run/t8933b/Test.scala
new file mode 100644
index 0000000000..46eedd660f
--- /dev/null
+++ b/test/files/run/t8933b/Test.scala
@@ -0,0 +1,9 @@
+class MotherClass extends MixinWithSymbol {
+ def foo = 'sym1
+}
+
+object Test {
+ def main(args: Array[String]) {
+ (new MotherClass).symbolFromTrait
+ }
+}
diff --git a/test/files/run/t8933c.scala b/test/files/run/t8933c.scala
new file mode 100644
index 0000000000..22011bc323
--- /dev/null
+++ b/test/files/run/t8933c.scala
@@ -0,0 +1,14 @@
+object Test {
+ def main(args: Array[String]): Unit = {
+ try {
+ {throw T; Symbol}.apply("a")
+ assert(false, "exception not thrown")
+ } catch {
+ case T => // ok
+ case t: Throwable =>
+ assert(false, "wrong not thrown: " + t)
+ }
+ }
+}
+
+object T extends Throwable
diff --git a/test/files/run/t8960.scala b/test/files/run/t8960.scala
new file mode 100644
index 0000000000..a58ac53d33
--- /dev/null
+++ b/test/files/run/t8960.scala
@@ -0,0 +1,72 @@
+object Test extends App {
+ def test(o: AnyRef, sp: Boolean = false) = {
+ val isSpecialized = o.getClass.getSuperclass.getName contains "$sp"
+ val isDelambdafyMethod = o.getClass.getName contains "$lambda$"
+ assert(
+ // delambdafy:method doesn't currently emit specialized anonymous function classes
+ if (sp) (isSpecialized || isDelambdafyMethod) else !isSpecialized,
+ o.getClass.getName)
+
+ val Some(f) = o.getClass.getDeclaredFields.find(_.getName == "serialVersionUID")
+ assert(f.getLong(null) == 0l)
+ }
+
+ test(() => (), sp = true)
+ test(() => 1, sp = true)
+ test(() => "")
+
+ test((x: Int) => x, sp = true)
+ test((x: Boolean) => x)
+ test((x: Int) => "")
+
+ test((x1: Int, x2: Int) => 0d, sp = true)
+ test((x1: Int, x2: AnyRef) => 0d)
+ test((x1: Any, x2: Any) => x1)
+
+ // scala> println((for (i <- 3 to 22) yield (for (j <- 1 to i) yield s"x$j: Int").mkString(" test((", ", ", ") => x1)")).mkString("\n"))
+
+ test((x1: Int, x2: Int, x3: Int) => x1)
+ test((x1: Int, x2: Int, x3: Int, x4: Int) => x1)
+ test((x1: Int, x2: Int, x3: Int, x4: Int, x5: Int) => x1)
+ test((x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int) => x1)
+ test((x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int) => x1)
+ test((x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int) => x1)
+ test((x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int) => x1)
+ test((x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int) => x1)
+ test((x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int) => x1)
+ test((x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int) => x1)
+ test((x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int) => x1)
+ test((x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int) => x1)
+ test((x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int) => x1)
+ test((x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int) => x1)
+ test((x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int, x17: Int) => x1)
+ test((x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int, x17: Int, x18: Int) => x1)
+ test((x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int, x17: Int, x18: Int, x19: Int) => x1)
+ test((x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int, x17: Int, x18: Int, x19: Int, x20: Int) => x1)
+ test((x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int, x17: Int, x18: Int, x19: Int, x20: Int, x21: Int) => x1)
+ test((x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int, x17: Int, x18: Int, x19: Int, x20: Int, x21: Int, x22: Int) => x1)
+
+ test({
+ case x: Int => x
+ }: PartialFunction[Int, Int], sp = true)
+
+ test({
+ case x: Int => x
+ }: PartialFunction[Any, Any])
+
+ test({
+ case x: Int => ()
+ }: PartialFunction[Int, Unit], sp = true)
+
+ test({
+ case x: String => 1
+ }: PartialFunction[String, Int])
+
+ test({
+ case x: String => ()
+ }: PartialFunction[String, Unit])
+
+ test({
+ case x: String => x
+ }: PartialFunction[String, String])
+}
diff --git a/test/files/run/t9003.flags b/test/files/run/t9003.flags
new file mode 100644
index 0000000000..49d036a887
--- /dev/null
+++ b/test/files/run/t9003.flags
@@ -0,0 +1 @@
+-optimize
diff --git a/test/files/run/t9003.scala b/test/files/run/t9003.scala
new file mode 100644
index 0000000000..4f24712201
--- /dev/null
+++ b/test/files/run/t9003.scala
@@ -0,0 +1,71 @@
+object Single {
+ var i = 0
+ def isEmpty = false
+ def get = i
+ def unapply(a: Single.type) = this
+}
+
+object Product {
+ var i = 0
+ def _1: Int = i
+ def _2: String = ???
+ def productArity = 2
+ def unapply(a: Product.type) = this
+ def isEmpty = false
+ def get: this.type = this
+}
+
+object Sequence {
+ var i = 0
+ def apply(n: Int): Int = i
+ def length = 2
+ def unapplySeq(a: Sequence.type) = this
+ def isEmpty = false
+ def get = this
+}
+
+object Test {
+ def main(args: Array[String]): Unit = {
+ def assertZero(i: Int) = assert(i == 0)
+
+ Single match {
+ case Single(i) =>
+ Single.i = 1
+ assertZero(i) // fails under -optimize
+ }
+
+ Product match {
+ case Product(i, _) =>
+ Product.i = 1
+ assertZero(i) // fails under -optimize
+ }
+
+ Sequence match {
+ case Sequence(i, _ @ _*) =>
+ Sequence.i = 1
+ assertZero(i) // okay
+ }
+
+ Sequence.i = 0
+ Sequence match {
+ case Sequence(_, i) =>
+ Sequence.i = 1
+ assertZero(i) // okay
+ }
+
+ val buffer = collection.mutable.Buffer(0, 0)
+ buffer match {
+ case Seq(_, i) =>
+ buffer(1) = 1
+ assertZero(i) // failed
+ }
+
+ case class CaseSequence(as: Int*)
+ val buffer1 = collection.mutable.Buffer(0, 0)
+ CaseSequence(buffer1: _*) match {
+ case CaseSequence(_, i) =>
+ buffer1(1) = 1
+ assertZero(i) // failed
+ }
+ }
+}
diff --git a/test/files/run/t9027.check b/test/files/run/t9027.check
new file mode 100644
index 0000000000..3429254286
--- /dev/null
+++ b/test/files/run/t9027.check
@@ -0,0 +1,19 @@
+{
+ {
+ val $buf = new _root_.scala.xml.NodeBuffer();
+ $buf.$amp$plus(new _root_.scala.xml.Elem(null, "a", _root_.scala.xml.Null, $scope, true));
+ $buf.$amp$plus(new _root_.scala.xml.Elem(null, "b", _root_.scala.xml.Null, $scope, true));
+ $buf
+ };
+ println("hello, world.")
+}
+{
+ {
+ val $buf = new _root_.scala.xml.NodeBuffer();
+ $buf.$amp$plus(new _root_.scala.xml.Elem(null, "a", _root_.scala.xml.Null, $scope, true));
+ $buf.$amp$plus(new _root_.scala.xml.Elem(null, "b", _root_.scala.xml.Null, $scope, true));
+ $buf.$amp$plus(new _root_.scala.xml.Elem(null, "c", _root_.scala.xml.Null, $scope, true));
+ $buf
+ };
+ println("hello, world.")
+}
diff --git a/test/files/run/t9027.scala b/test/files/run/t9027.scala
new file mode 100644
index 0000000000..26238147da
--- /dev/null
+++ b/test/files/run/t9027.scala
@@ -0,0 +1,15 @@
+
+// used to be parsed as .println
+object Test extends App {
+ import reflect.runtime._, universe._
+
+ val trees = List(
+ q"""<a/><b/>
+ println("hello, world.")""",
+ q"""<a/>
+ <b/>
+ <c/>
+ println("hello, world.")"""
+ )
+ trees foreach println
+}
diff --git a/test/files/run/various-flat-classpath-types.check b/test/files/run/various-flat-classpath-types.check
new file mode 100644
index 0000000000..401f707d0e
--- /dev/null
+++ b/test/files/run/various-flat-classpath-types.check
@@ -0,0 +1,12 @@
+ZipBin()
+JarBin()
+DirBin()
+ZipSrc()
+JarSrc()
+DirSrc()
+NestedZipBin()
+NestedJarBin()
+NestedDirBin()
+NestedZipSrc()
+NestedJarSrc()
+NestedDirSrc() \ No newline at end of file
diff --git a/test/files/run/various-flat-classpath-types.scala b/test/files/run/various-flat-classpath-types.scala
new file mode 100644
index 0000000000..d39019e885
--- /dev/null
+++ b/test/files/run/various-flat-classpath-types.scala
@@ -0,0 +1,214 @@
+/*
+ * Copyright (c) 2014 Contributor. All rights reserved.
+ */
+
+import java.io.{File => JFile, FileInputStream, FileOutputStream}
+import java.util.zip.{ZipEntry, ZipOutputStream}
+import scala.reflect.io.{Directory, File}
+import scala.tools.nsc.classpath.FlatClassPath.RootPackage
+import scala.tools.nsc.classpath.PackageNameUtils
+import scala.tools.nsc.io.Jar
+
+/**
+ * Generates directories, jars and zip files containing sources and classes
+ * (the result of a compilation which is executed here)
+ * and use them as a class- and sourcepath during compilation and running
+ * created application. At the end everything is cleaned up.
+ *
+ * It can test also current, recursive classpath. Just right now we force
+ * flat classpath to test it also when the recursive one would be set as a default.
+ */
+object Test {
+
+ private implicit class JFileOps(file: JFile) {
+
+ def createDir(newDirName: String) = {
+ val newDir = new JFile(file, newDirName)
+ newDir.mkdir()
+ newDir
+ }
+
+ def createSrcFile(newFileName: String) = createFile(newFileName + ".scala")
+
+ def createFile(fullFileName: String) = {
+ val newFile = new JFile(file, fullFileName)
+ newFile.createNewFile()
+ newFile
+ }
+
+ def writeAll(text: String): Unit = File(file) writeAll text
+
+ def moveContentToZip(zipName: String): Unit = {
+ val newZip = zipsDir createFile s"$zipName.zip"
+ val outputStream = new ZipOutputStream(new FileOutputStream(newZip))
+
+ def addFileToZip(dirPrefix: String = "")(fileToAdd: JFile): Unit =
+ if (fileToAdd.isDirectory) {
+ val dirEntryName = fileToAdd.getName + "/"
+ outputStream.putNextEntry(new ZipEntry(dirEntryName))
+ fileToAdd.listFiles() foreach addFileToZip(dirEntryName)
+ } else {
+ val inputStream = new FileInputStream(fileToAdd)
+ outputStream.putNextEntry(new ZipEntry(dirPrefix + fileToAdd.getName))
+
+ val buffer = new Array[Byte](1024)
+ var count = inputStream.read(buffer)
+ while (count > 0) {
+ outputStream.write(buffer, 0, count)
+ count = inputStream.read(buffer)
+ }
+
+ inputStream.close()
+ }
+
+ file.listFiles() foreach addFileToZip()
+ outputStream.close()
+
+ cleanDir(file)
+ }
+
+ def moveContentToJar(jarName: String): Unit = {
+ val newJar = jarsDir createFile s"$jarName.jar"
+ Jar.create(file = File(newJar), sourceDir = Directory(file), mainClass = "won't be used")
+ cleanDir(file)
+ }
+
+ def path: String = file.getAbsolutePath
+ }
+
+ private case class DirRep(name: String, nestedDirs: Seq[DirRep] = Nil, sourceFiles: Seq[String] = Nil)
+
+ private val compiler = new scala.tools.nsc.MainClass
+ private val appRunner = new scala.tools.nsc.MainGenericRunner
+ private val classPathImplFlag = "-YclasspathImpl:flat"
+ private val javaClassPath = sys.props("java.class.path")
+
+ // creates a test dir in a temporary dir containing compiled files of this test
+ // root dir will be automatically deleted after the end of test
+ private val rootDir = new JFile(sys.props("partest.output"))
+ private val testDir = rootDir createDir s"cp-tests-${System.currentTimeMillis()}"
+
+ private val jarsDir = testDir createDir "jars"
+ private val zipsDir = testDir createDir "zips"
+ private val srcDir = testDir createDir "src"
+ private val binDir = testDir createDir "bin"
+ private val outDir = testDir createDir "out"
+
+ def main(args: Array[String]): Unit = {
+ createClassesZipInZipsDir()
+ createClassesJarInJarsDir()
+ createClassesInBinDir()
+ createSourcesZipInZipsDir()
+ createSourcesJarInJarsDir()
+ createSourcesInSrcDir()
+ compileFinalApp()
+ runApp()
+ // at the end all created files will be deleted automatically
+ }
+
+ private def createClassesZipInZipsDir(): Unit = {
+ val baseFileName = "ZipBin"
+ createStandardSrcHierarchy(baseFileName)
+ compileSrc(baseFileName)
+ outDir moveContentToZip "Bin"
+ cleanDir(srcDir)
+ }
+
+ private def createClassesJarInJarsDir(): Unit = {
+ val baseFileName = "JarBin"
+ createStandardSrcHierarchy(baseFileName)
+ compileSrc(baseFileName)
+ outDir moveContentToJar "Bin"
+ cleanDir(srcDir)
+ }
+
+ private def createClassesInBinDir(): Unit = {
+ val baseFileName = "DirBin"
+ createStandardSrcHierarchy(baseFileName)
+ compileSrc(baseFileName, destination = binDir)
+ cleanDir(srcDir)
+ }
+
+ private def createSourcesZipInZipsDir(): Unit = {
+ createStandardSrcHierarchy(baseFileName = "ZipSrc")
+ srcDir moveContentToZip "Src"
+ }
+
+ private def createSourcesJarInJarsDir(): Unit = {
+ createStandardSrcHierarchy(baseFileName = "JarSrc")
+ srcDir moveContentToJar "Src"
+ }
+
+ private def createSourcesInSrcDir(): Unit = {
+ createStandardSrcHierarchy(baseFileName = "DirSrc")
+
+ val appFile = srcDir createSrcFile "Main"
+ appFile writeAll s"""import nested._
+ | object Main extends App {
+ | println(new ZipBin)
+ | println(new JarBin)
+ | println(new DirBin)
+ | println(new ZipSrc)
+ | println(new JarSrc)
+ | println(new DirSrc)
+ |
+ | println(new NestedZipBin)
+ | println(new NestedJarBin)
+ | println(new NestedDirBin)
+ | println(new NestedZipSrc)
+ | println(new NestedJarSrc)
+ | println(new NestedDirSrc)
+ | }
+ """.stripMargin
+ }
+
+ private def compileFinalApp(): Unit = {
+ val classPath = mkPath(javaClassPath, binDir.path, zipsDir.path + "/Bin.zip", jarsDir.path + "/Bin.jar")
+ val sourcePath = mkPath(srcDir.path, zipsDir.path + "/Src.zip", jarsDir.path + "/Src.jar")
+
+ compiler.process(Array(classPathImplFlag, "-cp", classPath, "-sourcepath", sourcePath,
+ "-d", outDir.path, s"${srcDir.path}/Main.scala"))
+ }
+
+ private def runApp(): Unit = {
+ val classPath = mkPath(javaClassPath, outDir.path, binDir.path, zipsDir.path + "/Bin.zip", jarsDir.path + "/Bin.jar")
+ appRunner.process(Array(classPathImplFlag, "-cp", classPath, "Main"))
+ }
+
+ private def createStandardSrcHierarchy(baseFileName: String): Unit =
+ createSources(RootPackage, srcDir,
+ DirRep("",
+ nestedDirs = Seq(DirRep("nested", sourceFiles = Seq("Nested" + baseFileName))),
+ sourceFiles = Seq(baseFileName)
+ )
+ )
+
+ private def createSources(pkg: String, dirFile: JFile, dirRep: DirRep): Unit = {
+ dirRep.nestedDirs foreach { rep =>
+ val nestedDir = dirFile createDir rep.name
+ val nestedPkg = PackageNameUtils.packagePrefix(pkg) + rep.name
+ createSources(nestedPkg, nestedDir, rep)
+ }
+
+ val pkgHeader = if (pkg == RootPackage) "" else s"package $pkg\n\n"
+ dirRep.sourceFiles foreach { srcName =>
+ val text = s"""${pkgHeader}case class $srcName(x: String = "")"""
+ val srcFile = dirFile createSrcFile srcName
+ srcFile writeAll text
+ }
+ }
+
+ private def compileSrc(baseFileName: String, destination: JFile = outDir): Unit = {
+ val srcDirPath = srcDir.path
+ compiler.process(Array(classPathImplFlag, "-cp", javaClassPath, "-d", destination.path,
+ s"$srcDirPath/$baseFileName.scala", s"$srcDirPath/nested/Nested$baseFileName.scala"))
+ }
+
+ private def cleanDir(dir: JFile): Unit =
+ dir.listFiles().foreach { file =>
+ if (file.isDirectory) cleanDir(file)
+ file.delete()
+ }
+
+ private def mkPath(pathEntries: String*) = pathEntries.mkString(File.pathSeparator)
+}
diff --git a/test/files/run/xMigration.check b/test/files/run/xMigration.check
new file mode 100644
index 0000000000..378f7bb6c3
--- /dev/null
+++ b/test/files/run/xMigration.check
@@ -0,0 +1,49 @@
+Type in expressions to have them evaluated.
+Type :help for more information.
+
+scala> Map(1 -> "eis").values // no warn
+res0: Iterable[String] = MapLike(eis)
+
+scala> :setting -Xmigration:none
+
+scala> Map(1 -> "eis").values // no warn
+res1: Iterable[String] = MapLike(eis)
+
+scala> :setting -Xmigration:any
+
+scala> Map(1 -> "eis").values // warn
+<console>:8: warning: method values in trait MapLike has changed semantics in version 2.8.0:
+`values` returns `Iterable[B]` rather than `Iterator[B]`.
+ Map(1 -> "eis").values // warn
+ ^
+res2: Iterable[String] = MapLike(eis)
+
+scala> :setting -Xmigration:2.8
+
+scala> Map(1 -> "eis").values // no warn
+res3: Iterable[String] = MapLike(eis)
+
+scala> :setting -Xmigration:2.7
+
+scala> Map(1 -> "eis").values // warn
+<console>:8: warning: method values in trait MapLike has changed semantics in version 2.8.0:
+`values` returns `Iterable[B]` rather than `Iterator[B]`.
+ Map(1 -> "eis").values // warn
+ ^
+res4: Iterable[String] = MapLike(eis)
+
+scala> :setting -Xmigration:2.11
+
+scala> Map(1 -> "eis").values // no warn
+res5: Iterable[String] = MapLike(eis)
+
+scala> :setting -Xmigration // same as :any
+
+scala> Map(1 -> "eis").values // warn
+<console>:8: warning: method values in trait MapLike has changed semantics in version 2.8.0:
+`values` returns `Iterable[B]` rather than `Iterator[B]`.
+ Map(1 -> "eis").values // warn
+ ^
+res6: Iterable[String] = MapLike(eis)
+
+scala> :quit
diff --git a/test/files/run/xMigration.scala b/test/files/run/xMigration.scala
new file mode 100644
index 0000000000..688e878397
--- /dev/null
+++ b/test/files/run/xMigration.scala
@@ -0,0 +1,19 @@
+import scala.tools.partest.ReplTest
+
+object Test extends ReplTest {
+ def code = """
+Map(1 -> "eis").values // no warn
+:setting -Xmigration:none
+Map(1 -> "eis").values // no warn
+:setting -Xmigration:any
+Map(1 -> "eis").values // warn
+:setting -Xmigration:2.8
+Map(1 -> "eis").values // no warn
+:setting -Xmigration:2.7
+Map(1 -> "eis").values // warn
+:setting -Xmigration:2.11
+Map(1 -> "eis").values // no warn
+:setting -Xmigration // same as :any
+Map(1 -> "eis").values // warn
+ """
+}
diff --git a/test/files/t8449/Client.scala b/test/files/t8449/Client.scala
new file mode 100644
index 0000000000..5d273f06b2
--- /dev/null
+++ b/test/files/t8449/Client.scala
@@ -0,0 +1,3 @@
+object Client {
+ def foo: Any = new Test().foo
+}
diff --git a/test/files/t8449/Test.java b/test/files/t8449/Test.java
new file mode 100644
index 0000000000..ecb1711b24
--- /dev/null
+++ b/test/files/t8449/Test.java
@@ -0,0 +1,10 @@
+public class Test {
+ // Raw type over a Scala type constructor
+ public scala.Function1 foo() { return null; }
+ // scalac reported:
+ // % scalac-hash v2.11.2 -d /tmp sandbox/{Test.java,Client.scala}
+ // sandbox/Test.java:2: error: trait Function1 takes type parameters
+ // public scala.Function1 foo() { return null; }
+ // ^
+ // one error found
+}
diff --git a/test/junit/scala/collection/IndexedSeqOptimizedTest.scala b/test/junit/scala/collection/IndexedSeqOptimizedTest.scala
index e5382907af..419e1454cb 100644
--- a/test/junit/scala/collection/IndexedSeqOptimizedTest.scala
+++ b/test/junit/scala/collection/IndexedSeqOptimizedTest.scala
@@ -13,4 +13,17 @@ class IndexedSeqOptimizedTest {
assertEquals(0, (Array(2): collection.mutable.WrappedArray[Int]).lastIndexWhere(_ => true, 1))
assertEquals(2, "abc123".lastIndexWhere(_.isLetter, 6))
}
+
+ @Test
+ def hasCorrectDropAndTakeMethods() {
+ assertEquals("", "abc" take Int.MinValue)
+ assertEquals("", "abc" takeRight Int.MinValue)
+ assertEquals("abc", "abc" drop Int.MinValue)
+ assertEquals("abc", "abc" dropRight Int.MinValue)
+
+ assertArrayEquals(Array.empty[Int], Array(1, 2, 3) take Int.MinValue)
+ assertArrayEquals(Array.empty[Int], Array(1, 2, 3) takeRight Int.MinValue)
+ assertArrayEquals(Array(1, 2, 3), Array(1, 2, 3) drop Int.MinValue)
+ assertArrayEquals(Array(1, 2, 3), Array(1, 2, 3) dropRight Int.MinValue)
+ }
}
diff --git a/test/junit/scala/collection/IterableViewLikeTest.scala b/test/junit/scala/collection/IterableViewLikeTest.scala
new file mode 100644
index 0000000000..55da02744b
--- /dev/null
+++ b/test/junit/scala/collection/IterableViewLikeTest.scala
@@ -0,0 +1,20 @@
+package scala.collection
+
+import org.junit.Assert._
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.junit.runners.JUnit4
+
+@RunWith(classOf[JUnit4])
+class IterableViewLikeTest {
+
+ @Test
+ def hasCorrectDropAndTakeMethods() {
+ val iter = Iterable(1, 2, 3)
+
+ assertEquals(Iterable.empty[Int], iter.view take Int.MinValue force)
+ assertEquals(Iterable.empty[Int], iter.view takeRight Int.MinValue force)
+ assertEquals(iter, iter.view drop Int.MinValue force)
+ assertEquals(iter, iter.view dropRight Int.MinValue force)
+ }
+}
diff --git a/test/junit/scala/collection/IteratorTest.scala b/test/junit/scala/collection/IteratorTest.scala
index b7a9805c9f..d5389afd0c 100644
--- a/test/junit/scala/collection/IteratorTest.scala
+++ b/test/junit/scala/collection/IteratorTest.scala
@@ -6,11 +6,14 @@ import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.JUnit4
+import scala.tools.testing.AssertUtil._
+
+import Seq.empty
+
@RunWith(classOf[JUnit4])
class IteratorTest {
- @Test
- def groupedIteratorShouldNotAskForUnneededElement(): Unit = {
+ @Test def groupedIteratorShouldNotAskForUnneededElement(): Unit = {
var counter = 0
val it = new Iterator[Int] { var i = 0 ; def hasNext = { counter = i; true } ; def next = { i += 1; i } }
val slidingIt = it sliding 2
@@ -25,4 +28,130 @@ class IteratorTest {
slidingIt.next
assertEquals("Counter should be one, that means we didn't look further than needed", 1, counter)
}
+
+ @Test def dropDoesNotGrowStack(): Unit = {
+ def it = new Iterator[Throwable] { def hasNext = true ; def next = new Throwable }
+
+ assertEquals(it.drop(1).next.getStackTrace.length, it.drop(1).drop(1).next.getStackTrace.length)
+ }
+
+ @Test def dropIsChainable(): Unit = {
+ assertSameElements(1 to 4, Iterator from 0 take 5 drop 1)
+ assertSameElements(3 to 4, Iterator from 0 take 5 drop 3)
+ assertSameElements(empty, Iterator from 0 take 5 drop 5)
+ assertSameElements(empty, Iterator from 0 take 5 drop 10)
+ assertSameElements(0 to 4, Iterator from 0 take 5 drop 0)
+ assertSameElements(0 to 4, Iterator from 0 take 5 drop -1)
+ assertSameElements(2 to 8 by 2, Iterator from 0 take 5 drop 1 map (2 * _))
+ assertSameElements(2 to 8 by 2, Iterator from 0 take 5 map (2 * _) drop 1)
+ assertSameElements(3 to 4, Iterator from 0 take 5 drop 1 drop 2)
+ assertSameElements(3 to 4, Iterator from 0 take 5 drop 2 drop 1)
+ }
+
+ @Test def sliceIsChainable(): Unit = {
+ assertSameElements(3 to 6, Iterator from 0 slice (3, 7))
+ assertSameElements(empty, Iterator from 0 slice (3, 3))
+ assertSameElements(0 to 2, Iterator from 0 slice (-1, 3))
+ assertSameElements(empty, Iterator from 0 slice (3, -1))
+ assertSameElements(6 to 12 by 2, Iterator from 0 slice (3, 7) map (2 * _))
+ assertSameElements(6 to 12 by 2, Iterator from 0 map (2 * _) slice (3, 7))
+ assertSameElements(4 to 6, Iterator from 0 slice (3, 7) drop 1)
+ assertSameElements(4 to 7, Iterator from 0 drop 1 slice (3, 7))
+ assertSameElements(4 to 5, Iterator from 0 slice (3, 7) slice (1, 3))
+ assertSameElements(4 to 6, Iterator from 0 slice (3, 7) slice (1, 10))
+ }
+
+ // test/files/run/iterator-concat.scala
+ @Test def concatIsStackFriendly(): Unit = {
+ // Create `size` Function0s, each of which evaluates to an Iterator
+ // which produces 1. Then fold them over ++ to get a single iterator,
+ // which should sum to "size".
+ def mk(size: Int): Iterator[Int] = {
+ //val closures = (1 to size).toList.map(x => (() => Iterator(1)))
+ //closures.foldLeft(Iterator.empty: Iterator[Int])((res, f) => res ++ f())
+ List.fill(size)(() => Iterator(1)).foldLeft(Iterator.empty: Iterator[Int])((res, f) => res ++ f())
+ }
+ assertEquals(100, mk(100).sum)
+ assertEquals(1000, mk(1000).sum)
+ assertEquals(10000, mk(10000).sum)
+ assertEquals(100000, mk(100000).sum)
+ }
+
+ @Test def from(): Unit = {
+ val it1 = Iterator.from(-1)
+ val it2 = Iterator.from(0, -1)
+ assertEquals(-1, it1.next())
+ assertEquals(0, it2.next())
+ }
+ @Test def range(): Unit = {
+ assertEquals(5, Iterator.range(0, 10, 2).size)
+ assertEquals(0, Iterator.range(0, 10, -2).size)
+ assertEquals(5, Iterator.range(10, 0, -2).size)
+ assertEquals(0, Iterator.range(10, 0, 2).size)
+ assertEquals(1, Iterator.range(0, 10, 11).size)
+ assertEquals(10, Iterator.range(0, 10, 1).size)
+ assertEquals(10, Iterator.range(10, 0, -1).size)
+ }
+ @Test def range3(): Unit = {
+ val r1 = Iterator.range(0, 10)
+ assertTrue(r1 contains 5)
+ assertTrue(r1 contains 6)
+ assertFalse(r1 contains 4)
+ val r2a = Iterator.range(0, 10, 2)
+ assertFalse(r2a contains 5)
+ val r2b = Iterator.range(0, 10, 2)
+ assertTrue(r2b contains 6)
+ val r3 = Iterator.range(0, 10, 11)
+ assertFalse(r3 contains 5)
+ assertTrue(r3.isEmpty)
+ }
+ @Test def take(): Unit = {
+ assertEquals(10, (Iterator from 0 take 10).size)
+ }
+ @Test def foreach(): Unit = {
+ val it1 = Iterator.from(0) take 20
+ var n = 0
+ it1 foreach { n += _ }
+ assertEquals(190, n)
+ }
+ // ticket #429
+ @Test def fromArray(): Unit = {
+ val a = List(1, 2, 3, 4).toArray
+ var xs0 = a.iterator.toList;
+ var xs1 = a.slice(0, 1).iterator
+ var xs2 = a.slice(0, 2).iterator
+ var xs3 = a.slice(0, 3).iterator
+ var xs4 = a.slice(0, 4).iterator
+ assertEquals(14, xs0.size + xs1.size + xs2.size + xs3.size + xs4.size)
+ }
+ @Test def toSeq(): Unit = {
+ assertEquals("1x2x3x4x5", List(1, 2, 3, 4, 5).iterator.mkString("x"))
+ }
+ @Test def indexOf(): Unit = {
+ assertEquals(3, List(1, 2, 3, 4, 5).iterator.indexOf(4))
+ assertEquals(-1, List(1, 2, 3, 4, 5).iterator.indexOf(16))
+ }
+ @Test def indexWhere(): Unit = {
+ assertEquals(3, List(1, 2, 3, 4, 5).iterator.indexWhere { x: Int => x >= 4 })
+ assertEquals(-1, List(1, 2, 3, 4, 5).iterator.indexWhere { x: Int => x >= 16 })
+ }
+ // iterator-iterate-lazy.scala
+ // was java.lang.UnsupportedOperationException: tail of empty list
+ @Test def iterateIsSufficientlyLazy(): Unit = {
+ //Iterator.iterate((1 to 5).toList)(_.tail).takeWhile(_.nonEmpty).toList // suffices
+ Iterator.iterate((1 to 5).toList)(_.tail).takeWhile(_.nonEmpty).map(_.head).toList
+ }
+ // SI-3516
+ @Test def toStreamIsSufficientlyLazy(): Unit = {
+ val results = collection.mutable.ListBuffer.empty[Int]
+ def mkIterator = (1 to 5).iterator map (x => { results += x ; x })
+ def mkInfinite = Iterator continually { results += 1 ; 1 }
+
+ // Stream is strict in its head so we should see 1 from each of them.
+ val s1 = mkIterator.toStream
+ val s2 = mkInfinite.toStream
+ // back and forth without slipping into nontermination.
+ results += (Stream from 1).toIterator.drop(10).toStream.drop(10).toIterator.next()
+ assertSameElements(List(1,1,21), results)
+ }
}
diff --git a/test/junit/scala/collection/immutable/ListTest.scala b/test/junit/scala/collection/immutable/ListTest.scala
new file mode 100644
index 0000000000..1006801029
--- /dev/null
+++ b/test/junit/scala/collection/immutable/ListTest.scala
@@ -0,0 +1,49 @@
+package scala.collection.immutable
+
+import org.junit.{Assert, Test}
+import org.junit.runner.RunWith
+import org.junit.runners.JUnit4
+
+import scala.ref.WeakReference
+
+@RunWith(classOf[JUnit4])
+class ListTest {
+ /**
+ * Test that empty iterator does not hold reference
+ * to complete List
+ */
+ @Test
+ def testIteratorGC(): Unit = {
+ var num = 0
+ var emptyIterators = Seq.empty[(Iterator[Int], WeakReference[List[Int]])]
+
+ do {
+ val list = List.fill(10000)(num)
+ val ref = WeakReference(list)
+
+ val i = list.iterator
+
+ while (i.hasNext) i.next()
+
+ emptyIterators = (i, ref) +: emptyIterators
+
+ num+=1
+ } while (emptyIterators.forall(_._2.get.isDefined) && num<1000)
+
+ // check something is result to protect from JIT optimizations
+ for ((i, _) <- emptyIterators) {
+ Assert.assertTrue(i.isEmpty)
+ }
+
+ // await gc up to ~5 seconds
+ var forceLoops = 50
+ while (emptyIterators.forall(_._2.get.isDefined) && forceLoops>0) {
+ System.gc()
+ Thread.sleep(100)
+ forceLoops -= 1
+ }
+
+ // real assertion
+ Assert.assertTrue(emptyIterators.exists(_._2.get.isEmpty))
+ }
+}
diff --git a/test/junit/scala/collection/immutable/PagedSeqTest.scala b/test/junit/scala/collection/immutable/PagedSeqTest.scala
index 5f83cf6f31..2b576a3655 100644
--- a/test/junit/scala/collection/immutable/PagedSeqTest.scala
+++ b/test/junit/scala/collection/immutable/PagedSeqTest.scala
@@ -5,12 +5,24 @@ import org.junit.runners.JUnit4
import org.junit.Test
import org.junit.Assert._
-/* Test for SI-6615 */
@RunWith(classOf[JUnit4])
class PagedSeqTest {
+ // should not NPE, and should equal the given Seq
@Test
- def rovingDoesNotNPE(): Unit = {
- // should not NPE, and should equal the given Seq
+ def test_SI6615(): Unit = {
assertEquals(Seq('a'), PagedSeq.fromStrings(List.fill(5000)("a")).slice(4096, 4097))
}
+
+ // Slices shouldn't read outside where they belong
+ @Test
+ def test_SI6519 {
+ var readAttempt = 0
+ val sideEffectingIterator = new Iterator[Int] {
+ def hasNext = readAttempt < 65536
+ def next = { readAttempt += 1; readAttempt }
+ }
+ val s = PagedSeq.fromIterator(sideEffectingIterator).slice(0,2).mkString
+ assertEquals(s, "12")
+ assert(readAttempt <= 4096)
+ }
}
diff --git a/test/junit/scala/collection/immutable/TreeMapTest.scala b/test/junit/scala/collection/immutable/TreeMapTest.scala
new file mode 100644
index 0000000000..4c21b94b24
--- /dev/null
+++ b/test/junit/scala/collection/immutable/TreeMapTest.scala
@@ -0,0 +1,20 @@
+package scala.collection.immutable
+
+import org.junit.Assert._
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.junit.runners.JUnit4
+
+@RunWith(classOf[JUnit4])
+class TreeMapTest {
+
+ @Test
+ def hasCorrectDropAndTakeMethods() {
+ val tree = TreeMap(1 -> "a", 2 -> "b", 3 -> "c")
+
+ assertEquals(TreeMap.empty[Int, String], tree take Int.MinValue)
+ assertEquals(TreeMap.empty[Int, String], tree takeRight Int.MinValue)
+ assertEquals(tree, tree drop Int.MinValue)
+ assertEquals(tree, tree dropRight Int.MinValue)
+ }
+}
diff --git a/test/junit/scala/collection/immutable/TreeSetTest.scala b/test/junit/scala/collection/immutable/TreeSetTest.scala
new file mode 100644
index 0000000000..8efe1bfeb8
--- /dev/null
+++ b/test/junit/scala/collection/immutable/TreeSetTest.scala
@@ -0,0 +1,20 @@
+package scala.collection.immutable
+
+import org.junit.Assert._
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.junit.runners.JUnit4
+
+@RunWith(classOf[JUnit4])
+class TreeSetTest {
+
+ @Test
+ def hasCorrectDropAndTakeMethods() {
+ val set = TreeSet(1, 2, 3)
+
+ assertEquals(TreeSet.empty[Int], set take Int.MinValue)
+ assertEquals(TreeSet.empty[Int], set takeRight Int.MinValue)
+ assertEquals(set, set drop Int.MinValue)
+ assertEquals(set, set dropRight Int.MinValue)
+ }
+}
diff --git a/test/junit/scala/collection/mutable/BitSetTest.scala b/test/junit/scala/collection/mutable/BitSetTest.scala
new file mode 100644
index 0000000000..8d164b50d4
--- /dev/null
+++ b/test/junit/scala/collection/mutable/BitSetTest.scala
@@ -0,0 +1,22 @@
+package scala.collection.mutable
+
+import org.junit.runner.RunWith
+import org.junit.runners.JUnit4
+import org.junit.{Test, Ignore}
+
+@RunWith(classOf[JUnit4])
+class BitSetTest {
+ // Test for SI-8910
+ @Test def capacityExpansionTest() {
+ val bitSet = BitSet.empty
+ val size = bitSet.toBitMask.length
+ bitSet ^= bitSet
+ assert(bitSet.toBitMask.length == size, "Capacity of bitset changed after ^=")
+ bitSet |= bitSet
+ assert(bitSet.toBitMask.length == size, "Capacity of bitset changed after |=")
+ bitSet &= bitSet
+ assert(bitSet.toBitMask.length == size, "Capacity of bitset changed after &=")
+ bitSet &~= bitSet
+ assert(bitSet.toBitMask.length == size, "Capacity of bitset changed after &~=")
+ }
+}
diff --git a/test/junit/scala/math/BigDecimalTest.scala b/test/junit/scala/math/BigDecimalTest.scala
index d1ba96fcc8..c7a63da890 100644
--- a/test/junit/scala/math/BigDecimalTest.scala
+++ b/test/junit/scala/math/BigDecimalTest.scala
@@ -222,4 +222,10 @@ class BigDecimalTest {
for (a <- different; b <- different if (a ne b))
assert(a != b, "BigDecimal representations of Double mistakenly conflated")
}
+
+ // Make sure hash code agrees with decimal representation of Double
+ @Test
+ def test_SI8970() {
+ assert((0.1).## == BigDecimal(0.1).##)
+ }
}
diff --git a/test/junit/scala/reflect/internal/PrintersTest.scala b/test/junit/scala/reflect/internal/PrintersTest.scala
index ca9b4671b2..7043c26d5e 100644
--- a/test/junit/scala/reflect/internal/PrintersTest.scala
+++ b/test/junit/scala/reflect/internal/PrintersTest.scala
@@ -354,6 +354,13 @@ trait ClassPrintTests {
| def y = "test"
|}""")
+ @Test def testClassConstructorModifiers = assertPrintedCode("class X private (x: scala.Int)")
+
+ @Test def testClassConstructorModifierVisibility = assertPrintedCode(sm"""
+ |object A {
+ | class X protected[A] (x: scala.Int)
+ |}""")
+
@Test def testClassWithPublicParams = assertPrintedCode("class X(val x: scala.Int, val s: scala.Predef.String)")
@Test def testClassWithParams1 = assertPrintedCode("class X(x: scala.Int, s: scala.Predef.String)")
diff --git a/test/junit/scala/tools/nsc/SampleTest.scala b/test/junit/scala/tools/nsc/SampleTest.scala
index 810c88ef9d..60bb09e98f 100644
--- a/test/junit/scala/tools/nsc/SampleTest.scala
+++ b/test/junit/scala/tools/nsc/SampleTest.scala
@@ -11,6 +11,6 @@ import org.junit.runners.JUnit4
class SampleTest {
@Test
def testMath: Unit = {
- assert(2+2 == 4, "you didn't get the math right fellow")
+ assertTrue("you didn't get the math right fellow", 2 + 2 == 4)
}
}
diff --git a/test/junit/scala/tools/nsc/backend/jvm/CodeGenTools.scala b/test/junit/scala/tools/nsc/backend/jvm/CodeGenTools.scala
index b892eb36cf..c1c5a71b83 100644
--- a/test/junit/scala/tools/nsc/backend/jvm/CodeGenTools.scala
+++ b/test/junit/scala/tools/nsc/backend/jvm/CodeGenTools.scala
@@ -7,6 +7,8 @@ import scala.reflect.io.VirtualDirectory
import scala.tools.asm.Opcodes
import scala.tools.asm.tree.{AbstractInsnNode, LabelNode, ClassNode, MethodNode}
import scala.tools.cmd.CommandLineParser
+import scala.tools.nsc.backend.jvm.opt.LocalOpt
+import scala.tools.nsc.settings.{MutableSettings, ScalaSettings}
import scala.tools.nsc.{Settings, Global}
import scala.tools.partest.ASMConverters
import scala.collection.JavaConverters._
@@ -79,4 +81,23 @@ object CodeGenTools {
def getSingleMethod(classNode: ClassNode, name: String): Method =
convertMethod(classNode.methods.asScala.toList.find(_.name == name).get)
+
+ def assertHandlerLabelPostions(h: ExceptionHandler, instructions: List[Instruction], startIndex: Int, endIndex: Int, handlerIndex: Int): Unit = {
+ val insVec = instructions.toVector
+ assertTrue(h.start == insVec(startIndex) && h.end == insVec(endIndex) && h.handler == insVec(handlerIndex))
+ }
+
+ val localOpt = {
+ val settings = new MutableSettings(msg => throw new IllegalArgumentException(msg))
+ settings.processArguments(List("-Yopt:l:method"), processAll = true)
+ new LocalOpt(settings)
+ }
+
+ import scala.language.implicitConversions
+
+ implicit def aliveInstruction(ins: Instruction): (Instruction, Boolean) = (ins, true)
+
+ implicit class MortalInstruction(val ins: Instruction) extends AnyVal {
+ def dead: (Instruction, Boolean) = (ins, false)
+ }
}
diff --git a/test/junit/scala/tools/nsc/backend/jvm/DirectCompileTest.scala b/test/junit/scala/tools/nsc/backend/jvm/DirectCompileTest.scala
index 2fb5bb8052..89900291ca 100644
--- a/test/junit/scala/tools/nsc/backend/jvm/DirectCompileTest.scala
+++ b/test/junit/scala/tools/nsc/backend/jvm/DirectCompileTest.scala
@@ -10,13 +10,12 @@ import scala.tools.partest.ASMConverters._
@RunWith(classOf[JUnit4])
class DirectCompileTest {
- val compiler = newCompiler(extraArgs = "-Ybackend:GenBCode")
+ val compiler = newCompiler(extraArgs = "-Ybackend:GenBCode -Yopt:l:method")
@Test
def testCompile(): Unit = {
val List(("C.class", bytes)) = compile(compiler)(
- """
- |class C {
+ """class C {
| def f = 1
|}
""".stripMargin)
@@ -26,19 +25,12 @@ class DirectCompileTest {
@Test
def testCompileClasses(): Unit = {
- val List(cClass, cModuleClass) = compileClasses(compiler)(
- """
- |class C
- |object C
- """.stripMargin)
+ val List(cClass, cModuleClass) = compileClasses(compiler)("class C; object C")
assertTrue(cClass.name == "C")
assertTrue(cModuleClass.name == "C$")
- val List(dMirror, dModuleClass) = compileClasses(compiler)(
- """
- |object D
- """.stripMargin)
+ val List(dMirror, dModuleClass) = compileClasses(compiler)("object D")
assertTrue(dMirror.name == "D")
assertTrue(dModuleClass.name == "D$")
@@ -47,35 +39,35 @@ class DirectCompileTest {
@Test
def testCompileMethods(): Unit = {
val List(f, g) = compileMethods(compiler)(
- """
- |def f = 10
+ """def f = 10
|def g = f
""".stripMargin)
assertTrue(f.name == "f")
assertTrue(g.name == "g")
- assertTrue(instructionsFromMethod(f).dropNonOp ===
+ assertSameCode(instructionsFromMethod(f).dropNonOp,
List(IntOp(BIPUSH, 10), Op(IRETURN)))
- assertTrue(instructionsFromMethod(g).dropNonOp ===
- List(VarOp(ALOAD, 0), Invoke(INVOKEVIRTUAL, "C", "f", "()I", false), Op(IRETURN)))
+ assertSameCode(instructionsFromMethod(g).dropNonOp,
+ List(VarOp(ALOAD, 0), Invoke(INVOKEVIRTUAL, "C", "f", "()I", itf = false), Op(IRETURN)))
}
@Test
def testDropNonOpAliveLabels(): Unit = {
+ // makes sure that dropNoOp doesn't drop labels that are being used
val List(f) = compileMethods(compiler)("""def f(x: Int) = if (x == 0) "a" else "b"""")
- assertTrue(instructionsFromMethod(f).dropNonOp === List(
- VarOp(ILOAD, 1),
- Op(ICONST_0),
- Jump(IF_ICMPEQ, Label(6)),
- Jump(GOTO, Label(10)),
- Label(6),
- Ldc(LDC, "a"),
- Jump(GOTO, Label(13)),
- Label(10),
- Ldc(LDC, "b"),
- Label(13),
- Op(ARETURN)
+ assertSameCode(instructionsFromMethod(f).dropLinesFrames, List(
+ Label(0),
+ VarOp(ILOAD, 1),
+ Op(ICONST_0),
+ Jump(IF_ICMPNE,
+ Label(7)),
+ Ldc(LDC, "a"),
+ Op(ARETURN),
+ Label(7),
+ Ldc(LDC, "b"),
+ Op(ARETURN),
+ Label(11)
))
}
}
diff --git a/test/junit/scala/tools/nsc/backend/jvm/opt/CompactLocalVariablesTest.scala b/test/junit/scala/tools/nsc/backend/jvm/opt/CompactLocalVariablesTest.scala
new file mode 100644
index 0000000000..fc748196d0
--- /dev/null
+++ b/test/junit/scala/tools/nsc/backend/jvm/opt/CompactLocalVariablesTest.scala
@@ -0,0 +1,80 @@
+package scala.tools.nsc
+package backend.jvm
+package opt
+
+import org.junit.runner.RunWith
+import org.junit.runners.JUnit4
+import org.junit.Test
+import scala.tools.asm.Opcodes._
+import org.junit.Assert._
+
+import CodeGenTools._
+import scala.tools.partest.ASMConverters
+import ASMConverters._
+
+@RunWith(classOf[JUnit4])
+class CompactLocalVariablesTest {
+
+ // recurse-unreachable-jumps is required for eliminating catch blocks, in the first dce round they
+ // are still live.only after eliminating the empty handler the catch blocks become unreachable.
+ val methodOptCompiler = newCompiler(extraArgs = "-target:jvm-1.6 -Ybackend:GenBCode -Yopt:unreachable-code,recurse-unreachable-jumps,compact-locals")
+ val noCompactVarsCompiler = newCompiler(extraArgs = "-target:jvm-1.6 -Ybackend:GenBCode -Yopt:unreachable-code,recurse-unreachable-jumps")
+
+ @Test
+ def compactUnused(): Unit = {
+ val code =
+ """def f: Double = {
+ | try { }
+ | catch {
+ | case _: Throwable =>
+ | // eliminated by dce
+ | val i = 1
+ | val d = 1d
+ | val f = 1f
+ | val l = 1l
+ | }
+ |
+ | val i = 1 // variable index 1 (it's an instance method, so at index 0 we have `this`)
+ | val d = 1d // 2,3
+ | val f = 1f // 4
+ | val l = 1l // 5,6
+ |
+ | try { }
+ | catch {
+ | case _: Throwable =>
+ | // eliminated by dce
+ | val i = 1
+ | val d = 1d
+ | val f = 1f
+ | val l = 1l
+ | }
+ |
+ | val ii = 1 // 7
+ | val dd = 1d // 8,9
+ | val ff = 1f // 10
+ | val ll = 1l // 11,12
+ |
+ | i + ii + d + dd + f + ff + l + ll
+ |}
+ |""".stripMargin
+
+ val List(noCompact) = compileMethods(noCompactVarsCompiler)(code)
+ val List(withCompact) = compileMethods(methodOptCompiler)(code)
+
+ // code is the same, except for local var indices
+ assertTrue(noCompact.instructions.size == withCompact.instructions.size)
+
+ val varOpSlots = convertMethod(withCompact).instructions collect {
+ case VarOp(_, v) => v
+ }
+ assertTrue(varOpSlots.toString, varOpSlots == List(1, 2, 4, 5, 7, 8, 10, 11, // stores
+ 1, 7, 2, 8, 4, 10, 5, 11)) // loads
+
+ // the local variables descriptor table is cleaned up to remove stale entries after dce,
+ // also when the slots are not compacted
+ assertTrue(noCompact.localVariables.size == withCompact.localVariables.size)
+
+ assertTrue(noCompact.maxLocals == 25)
+ assertTrue(withCompact.maxLocals == 13)
+ }
+}
diff --git a/test/junit/scala/tools/nsc/backend/jvm/opt/EmptyExceptionHandlersTest.scala b/test/junit/scala/tools/nsc/backend/jvm/opt/EmptyExceptionHandlersTest.scala
index 57fa1a7b66..7d83c54b5b 100644
--- a/test/junit/scala/tools/nsc/backend/jvm/opt/EmptyExceptionHandlersTest.scala
+++ b/test/junit/scala/tools/nsc/backend/jvm/opt/EmptyExceptionHandlersTest.scala
@@ -26,7 +26,7 @@ class EmptyExceptionHandlersTest {
Op(RETURN)
)
assertTrue(convertMethod(asmMethod).handlers.length == 1)
- LocalOpt.removeEmptyExceptionHandlers(asmMethod)
+ localOpt.removeEmptyExceptionHandlers(asmMethod)
assertTrue(convertMethod(asmMethod).handlers.isEmpty)
}
@@ -35,12 +35,8 @@ class EmptyExceptionHandlersTest {
val handlers = List(ExceptionHandler(Label(1), Label(2), Label(2), Some(exceptionDescriptor)))
val asmMethod = genMethod(handlers = handlers)(
Label(1), // nops only
- Op(NOP),
- Op(NOP),
Jump(GOTO, Label(3)),
- Op(NOP),
Label(3),
- Op(NOP),
Jump(GOTO, Label(4)),
Label(2), // handler
@@ -51,7 +47,7 @@ class EmptyExceptionHandlersTest {
Op(RETURN)
)
assertTrue(convertMethod(asmMethod).handlers.length == 1)
- LocalOpt.removeEmptyExceptionHandlers(asmMethod)
+ localOpt.removeEmptyExceptionHandlers(asmMethod)
assertTrue(convertMethod(asmMethod).handlers.isEmpty)
}
diff --git a/test/junit/scala/tools/nsc/backend/jvm/opt/EmptyLabelsAndLineNumbersTest.scala b/test/junit/scala/tools/nsc/backend/jvm/opt/EmptyLabelsAndLineNumbersTest.scala
new file mode 100644
index 0000000000..8c0168826e
--- /dev/null
+++ b/test/junit/scala/tools/nsc/backend/jvm/opt/EmptyLabelsAndLineNumbersTest.scala
@@ -0,0 +1,99 @@
+package scala.tools.nsc
+package backend.jvm
+package opt
+
+import org.junit.runner.RunWith
+import org.junit.runners.JUnit4
+import org.junit.Test
+import scala.tools.asm.Opcodes._
+import org.junit.Assert._
+import scala.tools.testing.AssertUtil._
+
+import CodeGenTools._
+import scala.tools.partest.ASMConverters
+import ASMConverters._
+
+@RunWith(classOf[JUnit4])
+class EmptyLabelsAndLineNumbersTest {
+ @Test
+ def removeEmptyLineNumbers(): Unit = {
+ val ops = List[(Instruction, Boolean)](
+ Label(1),
+ LineNumber(1, Label(1)),
+ Label(2),
+ Label(3),
+ Op(RETURN),
+
+ Label(4),
+ LineNumber(4, Label(4)).dead,
+ LineNumber(5, Label(4)),
+ Op(RETURN),
+
+ Label(5),
+ LineNumber(6, Label(5)).dead,
+ Label(6),
+ Label(7),
+ LineNumber(7, Label(7)),
+ Op(RETURN),
+
+ Label(9),
+ LineNumber(8, Label(9)).dead,
+ Label(10)
+ )
+
+ val method = genMethod()(ops.map(_._1): _*)
+ assertTrue(localOpt.removeEmptyLineNumbers(method))
+ assertSameCode(instructionsFromMethod(method), ops.filter(_._2).map(_._1))
+ }
+
+ @Test
+ def badlyLocatedLineNumbers(): Unit = {
+ def t(ops: Instruction*) =
+ assertThrows[AssertionError](localOpt.removeEmptyLineNumbers(genMethod()(ops: _*)))
+
+ // line numbers have to be right after their referenced label node
+ t(LineNumber(0, Label(1)), Label(1))
+ t(Label(0), Label(1), LineNumber(0, Label(0)))
+ }
+
+ @Test
+ def removeEmptyLabels(): Unit = {
+ val handler = List(ExceptionHandler(Label(4), Label(5), Label(6), Some("java/lang/Throwable")))
+ def ops(target1: Int, target2: Int, target3: Int, target4: Int, target5: Int, target6: Int) = List[(Instruction, Boolean)](
+ Label(1),
+ Label(2).dead,
+ Label(3).dead,
+ LineNumber(3, Label(target1)),
+ VarOp(ILOAD, 1),
+ Jump(IFGE, Label(target2)),
+
+ Label(4),
+ Label(5).dead,
+ Label(6).dead,
+ VarOp(ILOAD, 2),
+ Jump(IFGE, Label(target3)),
+
+ Label(7),
+ Label(8).dead,
+ Label(9).dead,
+ Op(RETURN),
+
+ LookupSwitch(LOOKUPSWITCH, Label(target4), List(1,2), List(Label(target4), Label(target5))),
+ TableSwitch(TABLESWITCH, 1, 2, Label(target4), List(Label(target4), Label(target5))),
+
+ Label(10),
+ LineNumber(10, Label(10)),
+ Label(11).dead,
+ LineNumber(12, Label(target6))
+ )
+
+ val method = genMethod(handlers = handler)(ops(2, 3, 8, 8, 9, 11).map(_._1): _*)
+ assertTrue(localOpt.removeEmptyLabelNodes(method))
+ val m = convertMethod(method)
+ assertSameCode(m.instructions, ops(1, 1, 7, 7, 7, 10).filter(_._2).map(_._1))
+ assertTrue(m.handlers match {
+ case List(ExceptionHandler(Label(4), Label(4), Label(4), _)) => true
+ case _ => false
+ })
+ }
+}
diff --git a/test/junit/scala/tools/nsc/backend/jvm/opt/MethodLevelOpts.scala b/test/junit/scala/tools/nsc/backend/jvm/opt/MethodLevelOpts.scala
new file mode 100644
index 0000000000..5b0f0f238a
--- /dev/null
+++ b/test/junit/scala/tools/nsc/backend/jvm/opt/MethodLevelOpts.scala
@@ -0,0 +1,83 @@
+package scala.tools.nsc
+package backend.jvm
+package opt
+
+import org.junit.runner.RunWith
+import org.junit.runners.JUnit4
+import org.junit.Test
+import scala.tools.asm.Opcodes._
+import org.junit.Assert._
+
+import scala.tools.testing.AssertUtil._
+
+import CodeGenTools._
+import scala.tools.partest.ASMConverters
+import ASMConverters._
+
+@RunWith(classOf[JUnit4])
+class MethodLevelOpts {
+ val methodOptCompiler = newCompiler(extraArgs = "-target:jvm-1.6 -Ybackend:GenBCode -Yopt:l:method")
+
+ def wrapInDefault(code: Instruction*) = List(Label(0), LineNumber(1, Label(0))) ::: code.toList ::: List(Label(1))
+
+ @Test
+ def eliminateEmptyTry(): Unit = {
+ val code = "def f = { try {} catch { case _: Throwable => 0; () }; 1 }"
+ assertSameCode(singleMethodInstructions(methodOptCompiler)(code), wrapInDefault(Op(ICONST_1), Op(IRETURN)))
+ }
+
+ @Test
+ def cannotEliminateLoadBoxedUnit(): Unit = {
+ // the compiler inserts a boxed into the try block. it's therefore non-empty (and live) and not eliminated.
+ val code = "def f = { try {} catch { case _: Throwable => 0 }; 1 }"
+ val m = singleMethod(methodOptCompiler)(code)
+ assertTrue(m.handlers.length == 1)
+ assertSameCode(m.instructions.take(3), List(Label(0), LineNumber(1, Label(0)), Field(GETSTATIC, "scala/runtime/BoxedUnit", "UNIT", "Lscala/runtime/BoxedUnit;")))
+ }
+
+ @Test
+ def inlineThrowInCatchNotTry(): Unit = {
+ // the try block does not contain the `ATHROW` instruction, but in the catch block, `ATHROW` is inlined
+ val code = "def f(e: Exception) = throw { try e catch { case _: Throwable => e } }"
+ val m = singleMethod(methodOptCompiler)(code)
+ assertHandlerLabelPostions(m.handlers.head, m.instructions, 0, 3, 5)
+ assertSameCode(m.instructions,
+ wrapInDefault(VarOp(ALOAD, 1), Label(3), Op(ATHROW), Label(5), FrameEntry(4, List(), List("java/lang/Throwable")), Op(POP), VarOp(ALOAD, 1), Op(ATHROW))
+ )
+ }
+
+ @Test
+ def inlineReturnInCachtNotTry(): Unit = {
+ val code = "def f: Int = return { try 1 catch { case _: Throwable => 2 } }"
+ // cannot inline the IRETURN into the try block (because RETURN may throw IllegalMonitorState)
+ val m = singleMethod(methodOptCompiler)(code)
+ assertHandlerLabelPostions(m.handlers.head, m.instructions, 0, 3, 5)
+ assertSameCode(m.instructions,
+ wrapInDefault(Op(ICONST_1), Label(3), Op(IRETURN), Label(5), FrameEntry(4, List(), List("java/lang/Throwable")), Op(POP), Op(ICONST_2), Op(IRETURN)))
+ }
+
+ @Test
+ def simplifyJumpsInTryCatchFinally(): Unit = {
+ val code =
+ """def f: Int =
+ | try {
+ | return 1
+ | } catch {
+ | case _: Throwable =>
+ | return 2
+ | } finally {
+ | return 2
+ | // dead
+ | val x = try 10 catch { case _: Throwable => 11 }
+ | println(x)
+ | }
+ """.stripMargin
+ val m = singleMethod(methodOptCompiler)(code)
+ assertTrue(m.handlers.length == 2)
+ assertSameCode(m.instructions.dropNonOp, // drop line numbers and lables that are only used by line numbers
+
+ // one single label left :-)
+ List(Op(ICONST_1), VarOp(ISTORE, 2), Jump(GOTO, Label(20)), Op(POP), Op(ICONST_2), VarOp(ISTORE, 2), Jump(GOTO, Label(20)), VarOp(ASTORE, 3), Op(ICONST_2), Op(IRETURN), Label(20), Op(ICONST_2), Op(IRETURN))
+ )
+ }
+}
diff --git a/test/junit/scala/tools/nsc/backend/jvm/opt/SimplifyJumpsTest.scala b/test/junit/scala/tools/nsc/backend/jvm/opt/SimplifyJumpsTest.scala
new file mode 100644
index 0000000000..360fa1d23d
--- /dev/null
+++ b/test/junit/scala/tools/nsc/backend/jvm/opt/SimplifyJumpsTest.scala
@@ -0,0 +1,221 @@
+package scala.tools.nsc
+package backend.jvm
+package opt
+
+import org.junit.runner.RunWith
+import org.junit.runners.JUnit4
+import org.junit.Test
+import scala.tools.asm.Opcodes._
+import org.junit.Assert._
+
+import CodeGenTools._
+import scala.tools.partest.ASMConverters
+import ASMConverters._
+
+@RunWith(classOf[JUnit4])
+class SimplifyJumpsTest {
+ @Test
+ def simpleGotoReturn(): Unit = {
+ val ops = List(
+ Jump(GOTO, Label(2)), // replaced by RETURN
+ Op(ICONST_1), // need some code, otherwise removeJumpToSuccessor kicks in
+ Op(POP),
+ Label(1), // multiple labels OK
+ Label(2),
+ Label(3),
+ Op(RETURN)
+ )
+ val method = genMethod()(ops: _*)
+ assertTrue(localOpt.simplifyJumps(method))
+ assertSameCode(instructionsFromMethod(method), Op(RETURN) :: ops.tail)
+ }
+
+ @Test
+ def simpleGotoThrow(): Unit = {
+ val rest = List(
+ Op(ICONST_1), // need some code, otherwise removeJumpToSuccessor kicks in
+ Op(POP),
+ Label(1),
+ Label(2),
+ Label(3),
+ Op(ATHROW)
+ )
+ val method = genMethod()(
+ Op(ACONST_NULL) ::
+ Jump(GOTO, Label(2)) :: // replaced by ATHROW
+ rest: _*
+ )
+ assertTrue(localOpt.simplifyJumps(method))
+ assertSameCode(instructionsFromMethod(method), Op(ACONST_NULL) :: Op(ATHROW) :: rest)
+ }
+
+ @Test
+ def gotoThrowInTry(): Unit = {
+ val handler = List(ExceptionHandler(Label(1), Label(2), Label(4), Some("java/lang/Throwable")))
+ val initialInstrs = List(
+ Label(1),
+ Op(ACONST_NULL),
+ Jump(GOTO, Label(3)), // not by ATHROW (would move the ATHROW into a try block)
+ Label(2),
+ Op(ICONST_1), // need some code, otherwise removeJumpToSuccessor kicks in
+ Op(POP),
+ Label(3),
+ Op(ATHROW),
+ Label(4),
+ Op(POP),
+ Op(RETURN)
+ )
+ val method = genMethod(handlers = handler)(initialInstrs: _*)
+ assertFalse(localOpt.simplifyJumps(method))
+ assertSameCode(instructionsFromMethod(method), initialInstrs)
+
+ val optMethod = genMethod()(initialInstrs: _*) // no handler
+ assertTrue(localOpt.simplifyJumps(optMethod))
+ assertSameCode(instructionsFromMethod(optMethod).take(3), List(Label(1), Op(ACONST_NULL), Op(ATHROW)))
+ }
+
+ @Test
+ def simplifyBranchOverGoto(): Unit = {
+ val begin = List(
+ VarOp(ILOAD, 1),
+ Jump(IFGE, Label(2))
+ )
+ val rest = List(
+ Jump(GOTO, Label(3)),
+ Label(11), // other labels here are allowed
+ Label(2),
+ VarOp(ILOAD, 1),
+ Op(RETURN),
+ Label(3),
+ VarOp(ILOAD, 1),
+ Op(IRETURN)
+ )
+ val method = genMethod()(begin ::: rest: _*)
+ assertTrue(localOpt.simplifyJumps(method))
+ assertSameCode(
+ instructionsFromMethod(method),
+ List(VarOp(ILOAD, 1), Jump(IFLT, Label(3))) ::: rest.tail )
+
+ // no label allowed between begin and rest. if there's another label, then there could be a
+ // branch that label. eliminating the GOTO would change the behavior.
+ val nonOptMethod = genMethod()(begin ::: Label(22) :: rest: _*)
+ assertFalse(localOpt.simplifyJumps(nonOptMethod))
+ }
+
+ @Test
+ def ensureGotoRemoved(): Unit = {
+ def code(jumps: Instruction*) = List(
+ VarOp(ILOAD, 1)) ::: jumps.toList ::: List(
+ Label(2),
+
+ Op(RETURN),
+ Label(3),
+ Op(RETURN)
+ )
+
+ // ensures that the goto is safely removed. ASM supports removing while iterating, but not the
+ // next element of the current. Here, the current is the IFGE, the next is the GOTO.
+ val method = genMethod()(code(Jump(IFGE, Label(2)), Jump(GOTO, Label(3))): _*)
+ assertTrue(localOpt.simplifyJumps(method))
+ assertSameCode(instructionsFromMethod(method), code(Jump(IFLT, Label(3))))
+ }
+
+ @Test
+ def removeJumpToSuccessor(): Unit = {
+ val ops = List(
+ Jump(GOTO, Label(1)),
+ Label(11),
+ Label(1),
+ Label(2),
+ VarOp(ILOAD, 1),
+ Op(IRETURN)
+ )
+ val method = genMethod()(ops: _*)
+ assertTrue(localOpt.simplifyJumps(method))
+ assertSameCode(instructionsFromMethod(method), ops.tail)
+ }
+
+ @Test
+ def collapseJumpChains(): Unit = {
+ def ops(target1: Int, target2: Int, target3: Int) = List(
+ VarOp(ILOAD, 1),
+ Jump(IFGE, Label(target1)), // initially 1, then 3
+ VarOp(ILOAD, 1),
+ Op(IRETURN),
+
+ Label(2),
+ Jump(GOTO, Label(target3)),
+
+ Label(1),
+ Jump(GOTO, Label(target2)), // initially 2, then 3
+
+ VarOp(ILOAD, 1), // some code to prevent jumpToSuccessor optimization (once target2 is replaced by 3)
+ Op(RETURN),
+
+ Label(3),
+ VarOp(ILOAD, 1),
+ Op(IRETURN)
+ )
+ val method = genMethod()(ops(1, 2, 3): _*)
+ assertTrue(localOpt.simplifyJumps(method))
+ assertSameCode(instructionsFromMethod(method), ops(3, 3, 3))
+ }
+
+ @Test
+ def collapseJumpChainLoop(): Unit = {
+ def ops(target: Int) = List(
+ VarOp(ILOAD, 1),
+ Jump(IFGE, Label(target)),
+
+ Label(4),
+ Jump(GOTO, Label(3)),
+
+ VarOp(ILOAD, 1), // some code to prevent jumpToSuccessor (label 3)
+ Op(IRETURN),
+
+ Label(3),
+ Jump(GOTO, Label(4)),
+
+ Label(2),
+ Jump(GOTO, Label(3))
+ )
+
+ val method = genMethod()(ops(2): _*)
+ assertTrue(localOpt.simplifyJumps(method))
+ assertSameCode(instructionsFromMethod(method), ops(3))
+ }
+
+ @Test
+ def simplifyThenElseSameTarget(): Unit = {
+ def ops(jumpOp: Instruction) = List(
+ VarOp(ILOAD, 1),
+ jumpOp,
+ Label(2),
+ Jump(GOTO, Label(1)),
+
+ VarOp(ILOAD, 1), // some code to prevent jumpToSuccessor (label 1)
+ Op(IRETURN),
+
+ Label(1),
+ VarOp(ILOAD, 1),
+ Op(IRETURN)
+ )
+
+ val method = genMethod()(ops(Jump(IFGE, Label(1))): _*)
+ assertTrue(localOpt.simplifyJumps(method))
+ assertSameCode(instructionsFromMethod(method), ops(Op(POP)))
+ }
+
+ @Test
+ def thenElseSameTargetLoop(): Unit = {
+ def ops(br: List[Instruction]) = List(
+ VarOp(ILOAD, 1),
+ VarOp(ILOAD, 2)) ::: br ::: List(
+ Label(1),
+ Jump(GOTO, Label(1))
+ )
+ val method = genMethod()(ops(List(Jump(IF_ICMPGE, Label(1)))): _*)
+ assertTrue(localOpt.simplifyJumps(method))
+ assertSameCode(instructionsFromMethod(method), ops(List(Op(POP), Op(POP))))
+ }
+}
diff --git a/test/junit/scala/tools/nsc/backend/jvm/opt/UnreachableCodeTest.scala b/test/junit/scala/tools/nsc/backend/jvm/opt/UnreachableCodeTest.scala
index a3bd7ae6fe..4a45dd9138 100644
--- a/test/junit/scala/tools/nsc/backend/jvm/opt/UnreachableCodeTest.scala
+++ b/test/junit/scala/tools/nsc/backend/jvm/opt/UnreachableCodeTest.scala
@@ -16,12 +16,20 @@ import ASMConverters._
@RunWith(classOf[JUnit4])
class UnreachableCodeTest {
- import UnreachableCodeTest._
+
+ def assertEliminateDead(code: (Instruction, Boolean)*): Unit = {
+ val method = genMethod()(code.map(_._1): _*)
+ localOpt.removeUnreachableCodeImpl(method, "C")
+ val nonEliminated = instructionsFromMethod(method)
+ val expectedLive = code.filter(_._2).map(_._1).toList
+ assertSameCode(nonEliminated, expectedLive)
+ }
// jvm-1.6 enables emitting stack map frames, which impacts the code generation wrt dead basic blocks,
// see comment in BCodeBodyBuilder
- val dceCompiler = newCompiler(extraArgs = "-target:jvm-1.6 -Ybackend:GenBCode -Yopt:unreachable-code")
- val noOptCompiler = newCompiler(extraArgs = "-target:jvm-1.6 -Ybackend:GenBCode -Yopt:l:none")
+ val methodOptCompiler = newCompiler(extraArgs = "-target:jvm-1.6 -Ybackend:GenBCode -Yopt:l:method")
+ val dceCompiler = newCompiler(extraArgs = "-target:jvm-1.6 -Ybackend:GenBCode -Yopt:unreachable-code")
+ val noOptCompiler = newCompiler(extraArgs = "-target:jvm-1.6 -Ybackend:GenBCode -Yopt:l:none")
// jvm-1.5 disables computing stack map frames, and it emits dead code as-is.
val noOptNoFramesCompiler = newCompiler(extraArgs = "-target:jvm-1.5 -Ybackend:GenBCode -Yopt:l:none")
@@ -48,8 +56,8 @@ class UnreachableCodeTest {
@Test
def eliminateNop(): Unit = {
assertEliminateDead(
- // not dead, since visited by data flow analysis. need a different opt to eliminate it.
- Op(NOP),
+ // reachable, but removed anyway.
+ Op(NOP).dead,
Op(RETURN),
Op(NOP).dead
)
@@ -136,28 +144,31 @@ class UnreachableCodeTest {
@Test
def eliminateDeadCatchBlocks(): Unit = {
+ // the Label(1) is live: it's used in the local variable descriptor table (local variable "this" has a range from 0 to 1).
+ def wrapInDefault(code: Instruction*) = List(Label(0), LineNumber(1, Label(0))) ::: code.toList ::: List(Label(1))
+
val code = "def f: Int = { return 0; try { 1 } catch { case _: Exception => 2 } }"
- assertSameCode(singleMethodInstructions(dceCompiler)(code).dropNonOp,
- List(Op(ICONST_0), Op(IRETURN)))
+ val m = singleMethod(dceCompiler)(code)
+ assertTrue(m.handlers.isEmpty) // redundant (if code is gone, handler is gone), but done once here for extra safety
+ assertSameCode(m.instructions,
+ wrapInDefault(Op(ICONST_0), Op(IRETURN)))
val code2 = "def f: Unit = { try { } catch { case _: Exception => () }; () }"
- // DCE only removes dead basic blocks, but not NOPs, and also not useless jumps
- assertSameCode(singleMethodInstructions(dceCompiler)(code2).dropNonOp,
- List(Op(NOP), Jump(GOTO, Label(33)), Label(33), Op(RETURN)))
+ // requires fixpoint optimization of methodOptCompiler (dce alone is not enough): first the handler is eliminated, then it's dead catch block.
+ assertSameCode(singleMethodInstructions(methodOptCompiler)(code2), wrapInDefault(Op(RETURN)))
val code3 = "def f: Unit = { try { } catch { case _: Exception => try { } catch { case _: Exception => () } }; () }"
- assertSameCode(singleMethodInstructions(dceCompiler)(code3).dropNonOp,
- List(Op(NOP), Jump(GOTO, Label(33)), Label(33), Op(RETURN)))
+ assertSameCode(singleMethodInstructions(methodOptCompiler)(code3), wrapInDefault(Op(RETURN)))
+ // this example requires two iterations to get rid of the outer handler.
+ // the first iteration of DCE cannot remove the inner handler. then the inner (empty) handler is removed.
+ // then the second iteration of DCE removes the inner catch block, and then the outer handler is removed.
val code4 = "def f: Unit = { try { try { } catch { case _: Exception => () } } catch { case _: Exception => () }; () }"
- assertSameCode(singleMethodInstructions(dceCompiler)(code4).dropNonOp,
- List(Op(NOP), Jump(GOTO, Label(4)), Label(4), Jump(GOTO, Label(7)), Label(7), Op(RETURN)))
+ assertSameCode(singleMethodInstructions(methodOptCompiler)(code4), wrapInDefault(Op(RETURN)))
}
@Test // test the dce-testing tools
def metaTest(): Unit = {
- assertEliminateDead() // no instructions
-
assertThrows[AssertionError](
assertEliminateDead(Op(RETURN).dead),
_.contains("Expected: List()\nActual : List(Op(RETURN))")
@@ -198,20 +209,3 @@ class UnreachableCodeTest {
List(FrameEntry(F_FULL, List(INTEGER, DOUBLE, Label(1)), List("java/lang/Object", Label(3))), Label(1), Label(3)))
}
}
-
-object UnreachableCodeTest {
- import scala.language.implicitConversions
- implicit def aliveInstruction(ins: Instruction): (Instruction, Boolean) = (ins, true)
-
- implicit class MortalInstruction(val ins: Instruction) extends AnyVal {
- def dead: (Instruction, Boolean) = (ins, false)
- }
-
- def assertEliminateDead(code: (Instruction, Boolean)*): Unit = {
- val cls = wrapInClass(genMethod()(code.map(_._1): _*))
- LocalOpt.removeUnreachableCode(cls)
- val nonEliminated = instructionsFromMethod(cls.methods.get(0))
- val expectedLive = code.filter(_._2).map(_._1).toList
- assertSameCode(nonEliminated, expectedLive)
- }
-}
diff --git a/test/junit/scala/tools/nsc/classpath/AggregateFlatClassPathTest.scala b/test/junit/scala/tools/nsc/classpath/AggregateFlatClassPathTest.scala
new file mode 100644
index 0000000000..9a004d5e0e
--- /dev/null
+++ b/test/junit/scala/tools/nsc/classpath/AggregateFlatClassPathTest.scala
@@ -0,0 +1,208 @@
+/*
+ * Copyright (c) 2014 Contributor. All rights reserved.
+ */
+package scala.tools.nsc.classpath
+
+import java.net.URL
+import org.junit.Assert._
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.junit.runners.JUnit4
+import scala.reflect.io.VirtualFile
+import scala.tools.nsc.io.AbstractFile
+
+/**
+ * Tests whether AggregateFlatClassPath returns correct entries taken from
+ * cp instances used during creating it and whether it preserves the ordering
+ * (in the case of the repeated entry for a class or a source it returns the first one).
+ */
+@RunWith(classOf[JUnit4])
+class AggregateFlatClassPathTest {
+
+ private class TestFlatClassPath extends FlatClassPath {
+ override def packages(inPackage: String): Seq[PackageEntry] = unsupported
+ override def sources(inPackage: String): Seq[SourceFileEntry] = unsupported
+ override def classes(inPackage: String): Seq[ClassFileEntry] = unsupported
+
+ override def list(inPackage: String): FlatClassPathEntries = unsupported
+ override def findClassFile(name: String): Option[AbstractFile] = unsupported
+
+ override def asClassPathStrings: Seq[String] = unsupported
+ override def asSourcePathString: String = unsupported
+ override def asURLs: Seq[URL] = unsupported
+ }
+
+ private case class TestClassPath(virtualPath: String, classesInPackage: EntryNamesInPackage*) extends TestFlatClassPath {
+
+ override def classes(inPackage: String): Seq[ClassFileEntry] =
+ for {
+ entriesWrapper <- classesInPackage if entriesWrapper.inPackage == inPackage
+ name <- entriesWrapper.names
+ } yield classFileEntry(virtualPath, inPackage, name)
+
+ override def sources(inPackage: String): Seq[SourceFileEntry] = Nil
+
+ // we'll ignore packages
+ override def list(inPackage: String): FlatClassPathEntries = FlatClassPathEntries(Nil, classes(inPackage))
+ }
+
+ private case class TestSourcePath(virtualPath: String, sourcesInPackage: EntryNamesInPackage*) extends TestFlatClassPath {
+
+ override def sources(inPackage: String): Seq[SourceFileEntry] =
+ for {
+ entriesWrapper <- sourcesInPackage if entriesWrapper.inPackage == inPackage
+ name <- entriesWrapper.names
+ } yield sourceFileEntry(virtualPath, inPackage, name)
+
+ override def classes(inPackage: String): Seq[ClassFileEntry] = Nil
+
+ // we'll ignore packages
+ override def list(inPackage: String): FlatClassPathEntries = FlatClassPathEntries(Nil, sources(inPackage))
+ }
+
+ private case class EntryNamesInPackage(inPackage: String)(val names: String*)
+
+ private val dir1 = "./dir1"
+ private val dir2 = "./dir2"
+ private val dir3 = "./dir3"
+ private val dir4 = ""
+
+ private val pkg1 = "pkg1"
+ private val pkg2 = "pkg2"
+ private val pkg3 = "pkg1.nested"
+ private val nonexistingPkg = "nonexisting"
+
+ private def unsupported = throw new UnsupportedOperationException
+
+ private def classFileEntry(pathPrefix: String, inPackage: String, fileName: String) =
+ ClassFileEntryImpl(classFile(pathPrefix, inPackage, fileName))
+
+ private def sourceFileEntry(pathPrefix: String, inPackage: String, fileName: String) =
+ SourceFileEntryImpl(sourceFile(pathPrefix, inPackage, fileName))
+
+ private def classFile(pathPrefix: String, inPackage: String, fileName: String) =
+ virtualFile(pathPrefix, inPackage, fileName, ".class")
+
+ private def sourceFile(pathPrefix: String, inPackage: String, fileName: String) =
+ virtualFile(pathPrefix, inPackage, fileName, ".scala")
+
+ private def virtualFile(pathPrefix: String, inPackage: String, fileName: String, extension: String) = {
+ val packageDirs =
+ if (inPackage == FlatClassPath.RootPackage) ""
+ else inPackage.split('.').mkString("/", "/", "")
+ new VirtualFile(fileName + extension, s"$pathPrefix$packageDirs/$fileName$extension")
+ }
+
+ private def createDefaultTestClasspath() = {
+ val partialClassPaths = Seq(TestSourcePath(dir1, EntryNamesInPackage(pkg1)("F", "A", "G")),
+ TestClassPath(dir2, EntryNamesInPackage(pkg1)("C", "B", "A"), EntryNamesInPackage(pkg2)("D", "A", "E")),
+ TestClassPath(dir3, EntryNamesInPackage(pkg1)("A", "D", "F")),
+ TestSourcePath(dir4, EntryNamesInPackage(pkg2)("A", "H", "I"), EntryNamesInPackage(pkg1)("A")),
+ TestSourcePath(dir2, EntryNamesInPackage(pkg3)("J", "K", "L"))
+ )
+
+ AggregateFlatClassPath(partialClassPaths)
+ }
+
+ @Test
+ def testGettingPackages: Unit = {
+ case class ClassPathWithPackages(packagesInPackage: EntryNamesInPackage*) extends TestFlatClassPath {
+ override def packages(inPackage: String): Seq[PackageEntry] =
+ packagesInPackage.find(_.inPackage == inPackage).map(_.names).getOrElse(Nil) map PackageEntryImpl
+ }
+
+ val partialClassPaths = Seq(ClassPathWithPackages(EntryNamesInPackage(pkg1)("pkg1.a", "pkg1.d", "pkg1.f")),
+ ClassPathWithPackages(EntryNamesInPackage(pkg1)("pkg1.c", "pkg1.b", "pkg1.a"),
+ EntryNamesInPackage(pkg2)("pkg2.d", "pkg2.a", "pkg2.e"))
+ )
+ val cp = AggregateFlatClassPath(partialClassPaths)
+
+ val packagesInPkg1 = Seq("pkg1.a", "pkg1.d", "pkg1.f", "pkg1.c", "pkg1.b")
+ assertEquals(packagesInPkg1, cp.packages(pkg1).map(_.name))
+
+ val packagesInPkg2 = Seq("pkg2.d", "pkg2.a", "pkg2.e")
+ assertEquals(packagesInPkg2, cp.packages(pkg2).map(_.name))
+
+ assertEquals(Seq.empty, cp.packages(nonexistingPkg))
+ }
+
+ @Test
+ def testGettingClasses: Unit = {
+ val cp = createDefaultTestClasspath()
+
+ val classesInPkg1 = Seq(classFileEntry(dir2, pkg1, "C"),
+ classFileEntry(dir2, pkg1, "B"),
+ classFileEntry(dir2, pkg1, "A"),
+ classFileEntry(dir3, pkg1, "D"),
+ classFileEntry(dir3, pkg1, "F")
+ )
+ assertEquals(classesInPkg1, cp.classes(pkg1))
+
+ val classesInPkg2 = Seq(classFileEntry(dir2, pkg2, "D"),
+ classFileEntry(dir2, pkg2, "A"),
+ classFileEntry(dir2, pkg2, "E")
+ )
+ assertEquals(classesInPkg2, cp.classes(pkg2))
+
+ assertEquals(Seq.empty, cp.classes(pkg3))
+ assertEquals(Seq.empty, cp.classes(nonexistingPkg))
+ }
+
+ @Test
+ def testGettingSources: Unit = {
+ val partialClassPaths = Seq(TestClassPath(dir1, EntryNamesInPackage(pkg1)("F", "A", "G")),
+ TestSourcePath(dir2, EntryNamesInPackage(pkg1)("C", "B", "A"), EntryNamesInPackage(pkg2)("D", "A", "E")),
+ TestSourcePath(dir3, EntryNamesInPackage(pkg1)("A", "D", "F")),
+ TestClassPath(dir4, EntryNamesInPackage(pkg2)("A", "H", "I")),
+ TestClassPath(dir2, EntryNamesInPackage(pkg3)("J", "K", "L"))
+ )
+ val cp = AggregateFlatClassPath(partialClassPaths)
+
+ val sourcesInPkg1 = Seq(sourceFileEntry(dir2, pkg1, "C"),
+ sourceFileEntry(dir2, pkg1, "B"),
+ sourceFileEntry(dir2, pkg1, "A"),
+ sourceFileEntry(dir3, pkg1, "D"),
+ sourceFileEntry(dir3, pkg1, "F")
+ )
+ assertEquals(sourcesInPkg1, cp.sources(pkg1))
+
+ val sourcesInPkg2 = Seq(sourceFileEntry(dir2, pkg2, "D"),
+ sourceFileEntry(dir2, pkg2, "A"),
+ sourceFileEntry(dir2, pkg2, "E")
+ )
+ assertEquals(sourcesInPkg2, cp.sources(pkg2))
+
+ assertEquals(Seq.empty, cp.sources(pkg3))
+ assertEquals(Seq.empty, cp.sources(nonexistingPkg))
+ }
+
+ @Test
+ def testList: Unit = {
+ val cp = createDefaultTestClasspath()
+
+ val classesAndSourcesInPkg1 = Seq(
+ ClassAndSourceFilesEntry(classFile(dir3, pkg1, "F"), sourceFile(dir1, pkg1, "F")),
+ ClassAndSourceFilesEntry(classFile(dir2, pkg1, "A"), sourceFile(dir1, pkg1, "A")),
+ sourceFileEntry(dir1, pkg1, "G"),
+ classFileEntry(dir2, pkg1, "C"),
+ classFileEntry(dir2, pkg1, "B"),
+ classFileEntry(dir3, pkg1, "D")
+ )
+ assertEquals(classesAndSourcesInPkg1, cp.list(pkg1).classesAndSources)
+
+ assertEquals(FlatClassPathEntries(Nil, Nil), cp.list(nonexistingPkg))
+ }
+
+ @Test
+ def testFindClass: Unit = {
+ val cp = createDefaultTestClasspath()
+
+ assertEquals(
+ Some(ClassAndSourceFilesEntry(classFile(dir2, pkg1, "A"), sourceFile(dir1, pkg1, "A"))),
+ cp.findClass(s"$pkg1.A")
+ )
+ assertEquals(Some(classFileEntry(dir3, pkg1, "D")), cp.findClass(s"$pkg1.D"))
+ assertEquals(Some(sourceFileEntry(dir2, pkg3, "L")), cp.findClass(s"$pkg3.L"))
+ assertEquals(None, cp.findClass("Nonexisting"))
+ }
+}
diff --git a/test/junit/scala/tools/nsc/classpath/FlatClassPathResolverTest.scala b/test/junit/scala/tools/nsc/classpath/FlatClassPathResolverTest.scala
new file mode 100644
index 0000000000..a37ba31b31
--- /dev/null
+++ b/test/junit/scala/tools/nsc/classpath/FlatClassPathResolverTest.scala
@@ -0,0 +1,159 @@
+/*
+ * Copyright (c) 2014 Contributor. All rights reserved.
+ */
+package scala.tools.nsc.classpath
+
+import java.io.File
+import org.junit.Assert._
+import org.junit._
+import org.junit.rules.TemporaryFolder
+import org.junit.runner.RunWith
+import org.junit.runners.JUnit4
+import scala.annotation.tailrec
+import scala.tools.nsc.io.AbstractFile
+import scala.tools.nsc.util.ClassPath
+import scala.tools.nsc.Settings
+import scala.tools.util.FlatClassPathResolver
+import scala.tools.util.PathResolver
+
+@RunWith(classOf[JUnit4])
+class FlatClassPathResolverTest {
+
+ val tempDir = new TemporaryFolder()
+
+ private val packagesToTest = List(FlatClassPath.RootPackage, "scala", "scala.reflect", "scala.reflect.io")
+ private val classFilesToFind = List("scala.tools.util.FlatClassPathResolver",
+ "scala.reflect.io.AbstractFile",
+ "scala.collection.immutable.List",
+ "scala.Option",
+ "scala.collection.immutable.Vector",
+ "scala.util.hashing.MurmurHash3",
+ "java.lang.Object",
+ "java.util.Date")
+
+ private val classesToFind = classFilesToFind ++ List("TestSourceInRootPackage",
+ "scala.reflect.io.TestScalaSource",
+ "scala.reflect.io.TestJavaSource")
+
+ private val settings = new Settings
+
+ @Before
+ def initTempDirAndSourcePath: Unit = {
+ // In Java TemporaryFolder in JUnit is managed automatically using @Rule.
+ // It would work also in Scala after adding and extending a class like
+ // TestWithTempFolder.java containing it. But in this case it doesn't work when running tests
+ // from the command line - java class is not compiled due to some, misterious reasons.
+ // That's why such dirs are here created and deleted manually.
+ tempDir.create()
+ tempDir.newFile("TestSourceInRootPackage.scala")
+ val ioDir = tempDir.newFolder("scala", "reflect", "io")
+ new File(ioDir, "AbstractFile.scala").createNewFile()
+ new File(ioDir, "ZipArchive.java").createNewFile()
+ new File(ioDir, "TestScalaSource.scala").createNewFile()
+ new File(ioDir, "TestJavaSource.java").createNewFile()
+
+ settings.usejavacp.value = true
+ settings.sourcepath.value = tempDir.getRoot.getAbsolutePath
+ }
+
+ @After
+ def deleteTempDir: Unit = tempDir.delete()
+
+ private def createFlatClassPath(settings: Settings) =
+ new FlatClassPathResolver(settings).result
+
+ @Test
+ def testEntriesFromListOperationAgainstSeparateMethods: Unit = {
+ val classPath = createFlatClassPath(settings)
+
+ def compareEntriesInPackage(inPackage: String): Unit = {
+ val packages = classPath.packages(inPackage)
+ val classes = classPath.classes(inPackage)
+ val sources = classPath.sources(inPackage)
+ val FlatClassPathEntries(packagesFromList, classesAndSourcesFromList) = classPath.list(inPackage)
+
+ val packageNames = packages.map(_.name).sorted
+ val packageNamesFromList = packagesFromList.map(_.name).sorted
+ assertEquals(s"Methods list and packages for package '$inPackage' should return the same packages",
+ packageNames, packageNamesFromList)
+
+ val classFileNames = classes.map(_.name).sorted
+ val classFileNamesFromList = classesAndSourcesFromList.filter(_.binary.isDefined).map(_.name).sorted
+ assertEquals(s"Methods list and classes for package '$inPackage' should return entries for the same class files",
+ classFileNames, classFileNamesFromList)
+
+ val sourceFileNames = sources.map(_.name).sorted
+ val sourceFileNamesFromList = classesAndSourcesFromList.filter(_.source.isDefined).map(_.name).sorted
+ assertEquals(s"Methods list and sources for package '$inPackage' should return entries for the same source files",
+ sourceFileNames, sourceFileNamesFromList)
+
+ val uniqueNamesOfClassAndSourceFiles = (classFileNames ++ sourceFileNames).toSet
+ assertEquals(s"Class and source entries with the same name obtained via list for package '$inPackage' should be merged into one containing both files",
+ uniqueNamesOfClassAndSourceFiles.size, classesAndSourcesFromList.length)
+ }
+
+ packagesToTest foreach compareEntriesInPackage
+ }
+
+ @Test
+ def testCreatedEntriesAgainstRecursiveClassPath: Unit = {
+ val flatClassPath = createFlatClassPath(settings)
+ val recursiveClassPath = new PathResolver(settings).result
+
+ def compareEntriesInPackage(inPackage: String): Unit = {
+
+ @tailrec
+ def traverseToPackage(packageNameParts: Seq[String], cp: ClassPath[AbstractFile]): ClassPath[AbstractFile] = {
+ packageNameParts match {
+ case Nil => cp
+ case h :: t =>
+ cp.packages.find(_.name == h) match {
+ case Some(nestedCp) => traverseToPackage(t, nestedCp)
+ case _ => throw new Exception(s"There's no package $inPackage in recursive classpath - error when searching for '$h'")
+ }
+ }
+ }
+
+ val packageNameParts = if (inPackage == FlatClassPath.RootPackage) Nil else inPackage.split('.').toList
+ val recursiveClassPathInPackage = traverseToPackage(packageNameParts, recursiveClassPath)
+
+ val flatCpPackages = flatClassPath.packages(inPackage).map(_.name)
+ val pkgPrefix = PackageNameUtils.packagePrefix(inPackage)
+ val recursiveCpPackages = recursiveClassPathInPackage.packages.map(pkgPrefix + _.name)
+ assertEquals(s"Packages in package '$inPackage' on flat cp should be the same as on the recursive cp",
+ recursiveCpPackages, flatCpPackages)
+
+ val flatCpSources = flatClassPath.sources(inPackage).map(_.name).sorted
+ val recursiveCpSources = recursiveClassPathInPackage.classes
+ .filter(_.source.nonEmpty)
+ .map(_.name).sorted
+ assertEquals(s"Source entries in package '$inPackage' on flat cp should be the same as on the recursive cp",
+ recursiveCpSources, flatCpSources)
+
+ val flatCpClasses = flatClassPath.classes(inPackage).map(_.name).sorted
+ val recursiveCpClasses = recursiveClassPathInPackage.classes
+ .filter(_.binary.nonEmpty)
+ .map(_.name).sorted
+ assertEquals(s"Class entries in package '$inPackage' on flat cp should be the same as on the recursive cp",
+ recursiveCpClasses, flatCpClasses)
+ }
+
+ packagesToTest foreach compareEntriesInPackage
+ }
+
+ @Test
+ def testFindClassFile: Unit = {
+ val classPath = createFlatClassPath(settings)
+ classFilesToFind foreach { className =>
+ assertTrue(s"File for $className should be found", classPath.findClassFile(className).isDefined)
+ }
+ }
+
+ @Test
+ def testFindClass: Unit = {
+ val classPath = createFlatClassPath(settings)
+ classesToFind foreach { className =>
+ assertTrue(s"File for $className should be found", classPath.findClass(className).isDefined)
+ }
+ }
+}
diff --git a/test/junit/scala/tools/nsc/settings/ScalaVersionTest.scala b/test/junit/scala/tools/nsc/settings/ScalaVersionTest.scala
new file mode 100644
index 0000000000..77a2da828e
--- /dev/null
+++ b/test/junit/scala/tools/nsc/settings/ScalaVersionTest.scala
@@ -0,0 +1,18 @@
+package scala.tools.nsc
+package settings
+
+import org.junit.Assert._
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.junit.runners.JUnit4
+import scala.tools.testing.AssertUtil.assertThrows
+
+@RunWith(classOf[JUnit4])
+class ScalaVersionTest {
+ // SI-8711
+ @Test def versionUnparse() {
+ val v = "2.11.3"
+
+ assertEquals(ScalaVersion(v).unparse, v)
+ }
+}
diff --git a/test/junit/scala/tools/nsc/settings/SettingsTest.scala b/test/junit/scala/tools/nsc/settings/SettingsTest.scala
index eda0c27834..96f83c4c2f 100644
--- a/test/junit/scala/tools/nsc/settings/SettingsTest.scala
+++ b/test/junit/scala/tools/nsc/settings/SettingsTest.scala
@@ -164,4 +164,20 @@ class SettingsTest {
assertThrows[IllegalArgumentException](check("-m:a,b,-ab")(_ => true), _ contains "'ab' cannot be negated")
assertThrows[IllegalArgumentException](check("-m:a,ac,-uber,uber")(_ => true), _ contains "'uber' cannot be negated")
}
+
+ @Test def xSourceTest(): Unit = {
+ def check(expected: String, args: String*): Unit = {
+ val s = new MutableSettings(msg => throw new IllegalArgumentException(msg))
+ val (_, residual) = s.processArguments(args.toList, processAll = true)
+ assert(residual.isEmpty)
+ assertTrue(s.source.value == ScalaVersion(expected))
+ }
+ check(expected = "2.11.0") // default
+ check(expected = "2.11.0", "-Xsource:2.11")
+ check(expected = "2.10", "-Xsource:2.10.0")
+ check(expected = "2.12", "-Xsource:2.12")
+ assertThrows[IllegalArgumentException](check(expected = "2.11", "-Xsource"), _ == "-Xsource requires an argument, the syntax is -Xsource:<version>")
+ assertThrows[IllegalArgumentException](check(expected = "2.11", "-Xsource", "2.11"), _ == "-Xsource requires an argument, the syntax is -Xsource:<version>")
+ assertThrows[IllegalArgumentException](check(expected = "2.11", "-Xsource:2.invalid"), _ contains "There was a problem parsing 2.invalid")
+ }
}
diff --git a/test/junit/scala/tools/nsc/symtab/CannotHaveAttrsTest.scala b/test/junit/scala/tools/nsc/symtab/CannotHaveAttrsTest.scala
index d424f12710..69931c9e24 100644
--- a/test/junit/scala/tools/nsc/symtab/CannotHaveAttrsTest.scala
+++ b/test/junit/scala/tools/nsc/symtab/CannotHaveAttrsTest.scala
@@ -64,4 +64,16 @@ class CannotHaveAttrsTest {
assertThrows[IllegalArgumentException] { t.setType(tpe) }
}
}
+
+ class Attach
+ @Test
+ def attachmentsAreIgnored = {
+ attrlessTrees.foreach { t =>
+ t.setAttachments(NoPosition.update(new Attach))
+ assert(t.attachments == NoPosition)
+ t.updateAttachment(new Attach)
+ assert(t.attachments == NoPosition)
+ t.removeAttachment[Attach] // no exception
+ }
+ }
}
diff --git a/test/junit/scala/tools/nsc/symtab/SymbolTableForUnitTesting.scala b/test/junit/scala/tools/nsc/symtab/SymbolTableForUnitTesting.scala
index e4be42ac96..f0f20acf07 100644
--- a/test/junit/scala/tools/nsc/symtab/SymbolTableForUnitTesting.scala
+++ b/test/junit/scala/tools/nsc/symtab/SymbolTableForUnitTesting.scala
@@ -3,6 +3,9 @@ package symtab
import scala.reflect.ClassTag
import scala.reflect.internal.{Phase, NoPhase, SomePhase}
+import scala.tools.nsc.classpath.FlatClassPath
+import scala.tools.nsc.settings.ClassPathRepresentationType
+import scala.tools.util.FlatClassPathResolver
import scala.tools.util.PathResolver
import util.ClassPath
import io.AbstractFile
@@ -26,13 +29,28 @@ class SymbolTableForUnitTesting extends SymbolTable {
class LazyTreeCopier extends super.LazyTreeCopier with TreeCopier
override def isCompilerUniverse: Boolean = true
- def classPath = new PathResolver(settings).result
+
+ def classPath = platform.classPath
+ def flatClassPath: FlatClassPath = platform.flatClassPath
object platform extends backend.Platform {
val symbolTable: SymbolTableForUnitTesting.this.type = SymbolTableForUnitTesting.this
lazy val loaders: SymbolTableForUnitTesting.this.loaders.type = SymbolTableForUnitTesting.this.loaders
+
def platformPhases: List[SubComponent] = Nil
- val classPath: ClassPath[AbstractFile] = new PathResolver(settings).result
+
+ lazy val classPath: ClassPath[AbstractFile] = {
+ assert(settings.YclasspathImpl.value == ClassPathRepresentationType.Recursive,
+ "It's not possible to use the recursive classpath representation, when it's not the chosen classpath scanning method")
+ new PathResolver(settings).result
+ }
+
+ private[nsc] lazy val flatClassPath: FlatClassPath = {
+ assert(settings.YclasspathImpl.value == ClassPathRepresentationType.Flat,
+ "It's not possible to use the flat classpath representation, when it's not the chosen classpath scanning method")
+ new FlatClassPathResolver(settings).result
+ }
+
def isMaybeBoxed(sym: Symbol): Boolean = ???
def needCompile(bin: AbstractFile, src: AbstractFile): Boolean = ???
def externalEquals: Symbol = ???
@@ -50,7 +68,12 @@ class SymbolTableForUnitTesting extends SymbolTable {
class GlobalMirror extends Roots(NoSymbol) {
val universe: SymbolTableForUnitTesting.this.type = SymbolTableForUnitTesting.this
- def rootLoader: LazyType = new loaders.PackageLoader(classPath)
+
+ def rootLoader: LazyType = settings.YclasspathImpl.value match {
+ case ClassPathRepresentationType.Flat => new loaders.PackageLoaderUsingFlatClassPath(FlatClassPath.RootPackage, flatClassPath)
+ case ClassPathRepresentationType.Recursive => new loaders.PackageLoader(classPath)
+ }
+
override def toString = "compiler mirror"
}
@@ -60,7 +83,7 @@ class SymbolTableForUnitTesting extends SymbolTable {
rm.asInstanceOf[Mirror]
}
- def settings: Settings = {
+ lazy val settings: Settings = {
val s = new Settings
// initialize classpath using java classpath
s.usejavacp.value = true
diff --git a/test/junit/scala/tools/nsc/util/ClassPathImplComparator.scala b/test/junit/scala/tools/nsc/util/ClassPathImplComparator.scala
new file mode 100644
index 0000000000..f2926e3e17
--- /dev/null
+++ b/test/junit/scala/tools/nsc/util/ClassPathImplComparator.scala
@@ -0,0 +1,143 @@
+/*
+ * Copyright (c) 2014 Contributor. All rights reserved.
+ */
+package scala.tools.nsc.util
+
+import scala.reflect.io.AbstractFile
+import scala.tools.nsc.Settings
+import scala.tools.nsc.settings.ClassPathRepresentationType
+import scala.tools.util.PathResolverFactory
+
+/**
+ * Simple application to compare efficiency of the recursive and the flat classpath representations
+ */
+object ClassPathImplComparator {
+
+ private class TestSettings extends Settings {
+ val checkClasses = PathSetting("-checkClasses", "Specify names of classes which should be found separated with ;", "")
+ val requiredIterations = IntSetting("-requiredIterations",
+ "Repeat tests specified number of times (to check e.g. impact of caches)", 1, Some((1, Int.MaxValue)), (_: String) => None)
+ val cpCreationRepetitions = IntSetting("-cpCreationRepetitions",
+ "Repeat tests specified number of times (to check e.g. impact of caches)", 1, Some((1, Int.MaxValue)), (_: String) => None)
+ val cpLookupRepetitions = IntSetting("-cpLookupRepetitions",
+ "Repeat tests specified number of times (to check e.g. impact of caches)", 1, Some((1, Int.MaxValue)), (_: String) => None)
+ }
+
+ private class DurationStats(name: String) {
+ private var sum = 0L
+ private var iterations = 0
+
+ def noteMeasuredTime(millis: Long): Unit = {
+ sum += millis
+ iterations += 1
+ }
+
+ def printResults(): Unit = {
+ val avg = if (iterations == 0) 0 else sum.toDouble / iterations
+ println(s"$name - total duration: $sum ms; iterations: $iterations; avg: $avg ms")
+ }
+ }
+
+ private lazy val defaultClassesToFind = List(
+ "scala.collection.immutable.List",
+ "scala.Option",
+ "scala.Int",
+ "scala.collection.immutable.Vector",
+ "scala.util.hashing.MurmurHash3"
+ )
+
+ private val oldCpCreationStats = new DurationStats("Old classpath - create")
+ private val oldCpSearchingStats = new DurationStats("Old classpath - search")
+
+ private val flatCpCreationStats = new DurationStats("Flat classpath - create")
+ private val flatCpSearchingStats = new DurationStats("Flat classpath - search")
+
+ def main(args: Array[String]): Unit = {
+
+ if (args contains "-help")
+ usage()
+ else {
+ val oldCpSettings = loadSettings(args.toList, ClassPathRepresentationType.Recursive)
+ val flatCpSettings = loadSettings(args.toList, ClassPathRepresentationType.Flat)
+
+ val classesToCheck = oldCpSettings.checkClasses.value
+ val classesToFind =
+ if (classesToCheck.isEmpty) defaultClassesToFind
+ else classesToCheck.split(";").toList
+
+ def doTest(classPath: => ClassFileLookup[AbstractFile], cpCreationStats: DurationStats, cpSearchingStats: DurationStats,
+ cpCreationRepetitions: Int, cpLookupRepetitions: Int)= {
+
+ def createClassPaths() = (1 to cpCreationRepetitions).map(_ => classPath).last
+ def testClassLookup(cp: ClassFileLookup[AbstractFile]): Boolean = (1 to cpCreationRepetitions).foldLeft(true) {
+ case (a, _) => a && checkExistenceOfClasses(classesToFind)(cp)
+ }
+
+ val cp = withMeasuredTime("Creating classpath", createClassPaths(), cpCreationStats)
+ val result = withMeasuredTime("Searching for specified classes", testClassLookup(cp), cpSearchingStats)
+ println(s"The end of the test case. All expected classes found = $result \n")
+ }
+
+ (1 to oldCpSettings.requiredIterations.value) foreach { iteration =>
+ if (oldCpSettings.requiredIterations.value > 1)
+ println(s"Iteration no $iteration")
+
+ println("Recursive (old) classpath representation:")
+ doTest(PathResolverFactory.create(oldCpSettings).result, oldCpCreationStats, oldCpSearchingStats,
+ oldCpSettings.cpCreationRepetitions.value, oldCpSettings.cpLookupRepetitions.value)
+
+ println("Flat classpath representation:")
+ doTest(PathResolverFactory.create(flatCpSettings).result, flatCpCreationStats, flatCpSearchingStats,
+ flatCpSettings.cpCreationRepetitions.value, flatCpSettings.cpLookupRepetitions.value)
+ }
+
+ if (oldCpSettings.requiredIterations.value > 1) {
+ println("\nOld classpath - summary")
+ oldCpCreationStats.printResults()
+ oldCpSearchingStats.printResults()
+
+ println("\nFlat classpath - summary")
+ flatCpCreationStats.printResults()
+ flatCpSearchingStats.printResults()
+ }
+ }
+ }
+
+ /**
+ * Prints usage information
+ */
+ private def usage(): Unit =
+ println("""Use classpath and sourcepath options like in the case of e.g. 'scala' command.
+ | There are also two additional options:
+ | -checkClasses <semicolon separated class names> Specify names of classes which should be found
+ | -requiredIterations <int value> Repeat tests specified count of times (to check e.g. impact of caches)
+ | Note: Option -YclasspathImpl will be set automatically for each case.
+ """.stripMargin.trim)
+
+ private def loadSettings(args: List[String], implType: String) = {
+ val settings = new TestSettings()
+ settings.processArguments(args, processAll = true)
+ settings.YclasspathImpl.value = implType
+ if (settings.classpath.isDefault)
+ settings.classpath.value = sys.props("java.class.path")
+ settings
+ }
+
+ private def withMeasuredTime[T](operationName: String, f: => T, durationStats: DurationStats): T = {
+ val startTime = System.currentTimeMillis()
+ val res = f
+ val elapsed = System.currentTimeMillis() - startTime
+ durationStats.noteMeasuredTime(elapsed)
+ println(s"$operationName - elapsed $elapsed ms")
+ res
+ }
+
+ private def checkExistenceOfClasses(classesToCheck: Seq[String])(classPath: ClassFileLookup[AbstractFile]): Boolean =
+ classesToCheck.foldLeft(true) {
+ case (res, classToCheck) =>
+ val found = classPath.findClass(classToCheck).isDefined
+ if (!found)
+ println(s"Class $classToCheck not found") // of course in this case the measured time will be affected by IO operation
+ found
+ }
+}
diff --git a/test/junit/scala/tools/testing/AssertUtil.scala b/test/junit/scala/tools/testing/AssertUtil.scala
index 9b4833d46b..83a637783f 100644
--- a/test/junit/scala/tools/testing/AssertUtil.scala
+++ b/test/junit/scala/tools/testing/AssertUtil.scala
@@ -1,6 +1,11 @@
package scala.tools
package testing
+import org.junit.Assert
+import Assert.fail
+import scala.runtime.ScalaRunTime.stringOf
+import scala.collection.{ GenIterable, IterableLike }
+
/** This module contains additional higher-level assert statements
* that are ultimately based on junit.Assert primitives.
*/
@@ -21,6 +26,19 @@ object AssertUtil {
throw e
else return
}
- throw new AssertionError("Expression did not throw!")
+ fail("Expression did not throw!")
}
+
+ /** JUnit-style assertion for `IterableLike.sameElements`.
+ */
+ def assertSameElements[A, B >: A](expected: IterableLike[A, _], actual: GenIterable[B], message: String = ""): Unit =
+ if (!(expected sameElements actual))
+ fail(
+ f"${ if (message.nonEmpty) s"$message " else "" }expected:<${ stringOf(expected) }> but was:<${ stringOf(actual) }>"
+ )
+
+ /** Convenient for testing iterators.
+ */
+ def assertSameElements[A, B >: A](expected: IterableLike[A, _], actual: Iterator[B]): Unit =
+ assertSameElements(expected, actual.toList, "")
}
diff --git a/test/osgi/src/BasicLibrary.scala b/test/osgi/src/BasicLibrary.scala
index 6618f02102..ee8b7634ff 100644
--- a/test/osgi/src/BasicLibrary.scala
+++ b/test/osgi/src/BasicLibrary.scala
@@ -7,19 +7,16 @@ import org.ops4j.pax.exam.CoreOptions._
import org.junit.Test
import org.junit.runner.RunWith
import org.ops4j.pax.exam
-import org.ops4j.pax.exam.junit.{
- Configuration,
- ExamReactorStrategy,
- JUnit4TestRunner
-}
-import org.ops4j.pax.exam.spi.reactors.AllConfinedStagedReactorFactory
-import org.ops4j.pax.swissbox.framework.ServiceLookup
+import org.ops4j.pax.exam.Configuration
+import org.ops4j.pax.exam.junit.PaxExam
+import org.ops4j.pax.exam.spi.reactors.{ ExamReactorStrategy, PerMethod }
+import org.ops4j.pax.swissbox.tracker.ServiceLookup
import org.osgi.framework.BundleContext
-@RunWith(classOf[JUnit4TestRunner])
-@ExamReactorStrategy(Array(classOf[AllConfinedStagedReactorFactory]))
+@RunWith(classOf[PaxExam])
+@ExamReactorStrategy(Array(classOf[PerMethod]))
class BasicLibraryTest extends ScalaOsgiHelper {
@Configuration
def config(): Array[exam.Option] =
diff --git a/test/osgi/src/BasicReflection.scala b/test/osgi/src/BasicReflection.scala
index d601f04f89..53ab7e5345 100644
--- a/test/osgi/src/BasicReflection.scala
+++ b/test/osgi/src/BasicReflection.scala
@@ -10,13 +10,10 @@ import org.ops4j.pax.exam.CoreOptions._
import org.junit.Test
import org.junit.runner.RunWith
import org.ops4j.pax.exam
-import org.ops4j.pax.exam.junit.{
- Configuration,
- ExamReactorStrategy,
- JUnit4TestRunner
-}
-import org.ops4j.pax.exam.spi.reactors.AllConfinedStagedReactorFactory
-import org.ops4j.pax.swissbox.framework.ServiceLookup
+import org.ops4j.pax.exam.Configuration
+import org.ops4j.pax.exam.junit.PaxExam
+import org.ops4j.pax.exam.spi.reactors.{ ExamReactorStrategy, PerMethod }
+import org.ops4j.pax.swissbox.tracker.ServiceLookup
import org.osgi.framework.BundleContext
@@ -38,8 +35,8 @@ class C {
object M
-@RunWith(classOf[JUnit4TestRunner])
-@ExamReactorStrategy(Array(classOf[AllConfinedStagedReactorFactory]))
+@RunWith(classOf[PaxExam])
+@ExamReactorStrategy(Array(classOf[PerMethod]))
class BasicReflectionTest extends ScalaOsgiHelper {
@Configuration
diff --git a/test/osgi/src/BasicTest.scala b/test/osgi/src/BasicTest.scala
index 109b7b911a..5adf87ecc1 100644
--- a/test/osgi/src/BasicTest.scala
+++ b/test/osgi/src/BasicTest.scala
@@ -6,21 +6,18 @@ import org.ops4j.pax.exam.CoreOptions._
import org.junit.Test
import org.junit.runner.RunWith
import org.ops4j.pax.exam
-import org.ops4j.pax.exam.junit.{
- Configuration,
- ExamReactorStrategy,
- JUnit4TestRunner
-}
-import org.ops4j.pax.exam.spi.reactors.AllConfinedStagedReactorFactory
-import org.ops4j.pax.swissbox.framework.ServiceLookup
+import org.ops4j.pax.exam.Configuration
+import org.ops4j.pax.exam.junit.PaxExam
+import org.ops4j.pax.exam.spi.reactors.{ ExamReactorStrategy, PerMethod }
+import org.ops4j.pax.swissbox.tracker.ServiceLookup
import org.osgi.framework.BundleContext
-@RunWith(classOf[JUnit4TestRunner])
-@ExamReactorStrategy(Array(classOf[AllConfinedStagedReactorFactory]))
+@RunWith(classOf[PaxExam])
+@ExamReactorStrategy(Array(classOf[PerMethod]))
class BasicTest extends ScalaOsgiHelper {
@Configuration
def config(): Array[exam.Option] = {
diff --git a/test/osgi/src/ReflectionToolboxTest.scala b/test/osgi/src/ReflectionToolboxTest.scala
index bb48078e95..a23de18d07 100644
--- a/test/osgi/src/ReflectionToolboxTest.scala
+++ b/test/osgi/src/ReflectionToolboxTest.scala
@@ -8,13 +8,10 @@ import org.ops4j.pax.exam.CoreOptions._
import org.junit.Test
import org.junit.runner.RunWith
import org.ops4j.pax.exam
-import org.ops4j.pax.exam.junit.{
- Configuration,
- ExamReactorStrategy,
- JUnit4TestRunner
-}
-import org.ops4j.pax.exam.spi.reactors.AllConfinedStagedReactorFactory
-import org.ops4j.pax.swissbox.framework.ServiceLookup
+import org.ops4j.pax.exam.Configuration
+import org.ops4j.pax.exam.junit.PaxExam
+import org.ops4j.pax.exam.spi.reactors.{ ExamReactorStrategy, PerMethod }
+import org.ops4j.pax.swissbox.tracker.ServiceLookup
import org.osgi.framework.BundleContext
@@ -22,8 +19,8 @@ class C {
val f1 = 2
}
-@RunWith(classOf[JUnit4TestRunner])
-@ExamReactorStrategy(Array(classOf[AllConfinedStagedReactorFactory]))
+@RunWith(classOf[PaxExam])
+@ExamReactorStrategy(Array(classOf[PerMethod]))
class ReflectionToolBoxTest extends ScalaOsgiHelper {
@Configuration
diff --git a/test/osgi/src/ScalaOsgiHelper.scala b/test/osgi/src/ScalaOsgiHelper.scala
index 084afe8643..7ba8883bb8 100644
--- a/test/osgi/src/ScalaOsgiHelper.scala
+++ b/test/osgi/src/ScalaOsgiHelper.scala
@@ -20,19 +20,19 @@ trait ScalaOsgiHelper {
def standardOptions: Array[exam.Option] = {
val bundles = (allBundleFiles map makeBundle)
- bundles ++ Array[exam.Option](felix(), equinox(), junitBundles())
+ bundles ++ Array[exam.Option](junitBundles())
// to change the local repo used (for some operations, but not all -- which is why I didn't bother):
// systemProperty("org.ops4j.pax.url.mvn.localRepository").value(sys.props("maven.repo.local")))
}
def justReflectionOptions: Array[exam.Option] = {
val bundles = filteredBundleFiles("scala-library", "scala-reflect")
- bundles ++ Array[exam.Option](felix(), equinox(), junitBundles())
+ bundles ++ Array[exam.Option](junitBundles())
}
def justCoreLibraryOptions: Array[exam.Option] = {
val bundles = filteredBundleFiles("scala-library")
- bundles ++ Array[exam.Option](felix(), equinox(), junitBundles())
+ bundles ++ Array[exam.Option](junitBundles())
}
}
diff --git a/test/pending/pos/t3439.scala b/test/pending/pos/t3439.scala
deleted file mode 100644
index 425f1aeeb5..0000000000
--- a/test/pending/pos/t3439.scala
+++ /dev/null
@@ -1,2 +0,0 @@
-abstract class ParametricMessage[M: Manifest](msg: M) { def message = msg }
-case class ParametricMessage1[M: Manifest](msg: M, p1: Class[_]) extends ParametricMessage(msg)
diff --git a/test/scaladoc/run/t5730.check b/test/scaladoc/run/t5730.check
new file mode 100644
index 0000000000..619c56180b
--- /dev/null
+++ b/test/scaladoc/run/t5730.check
@@ -0,0 +1 @@
+Done.
diff --git a/test/scaladoc/run/t5730.scala b/test/scaladoc/run/t5730.scala
new file mode 100644
index 0000000000..cc4c2444b1
--- /dev/null
+++ b/test/scaladoc/run/t5730.scala
@@ -0,0 +1,36 @@
+import scala.tools.nsc.doc.base._
+import scala.tools.nsc.doc.model._
+import scala.tools.partest.ScaladocModelTest
+
+object Test extends ScaladocModelTest {
+
+ override def code = """
+ package scala.test.scaladoc.T5730
+
+ /**
+ * A link:
+ *
+ * [[scala.Option$ object Option]].
+ */
+ sealed abstract class A
+
+ case object B extends A
+
+ abstract final class C
+ """
+
+ def scaladocSettings = ""
+
+ def testModel(rootPackage: Package) = {
+ // get the quick access implicit defs in scope (_package(s), _class(es), _trait(s), object(s) _method(s), _value(s))
+ import access._
+
+ val p = rootPackage._package("scala")._package("test")._package("scaladoc")._package("T5730")
+
+ val a = p._class("A")
+ val c = p._class("C")
+
+ assert(a.constructors.isEmpty, s"there should be no constructors, found: ${a.constructors}")
+ assert(c.constructors.isEmpty, s"there should be no constructors, found: ${c.constructors}")
+ }
+}
diff --git a/test/scaladoc/run/t6626.check b/test/scaladoc/run/t6626.check
new file mode 100644
index 0000000000..de3a6c5c0b
--- /dev/null
+++ b/test/scaladoc/run/t6626.check
@@ -0,0 +1,7 @@
+newSource:10: warning: Could not find any member to link for "SomeUnknownException".
+ /**
+ ^
+newSource:10: warning: Could not find any member to link for "IOException".
+ /**
+ ^
+Done.
diff --git a/test/scaladoc/run/t6626.scala b/test/scaladoc/run/t6626.scala
new file mode 100644
index 0000000000..6c61c605d6
--- /dev/null
+++ b/test/scaladoc/run/t6626.scala
@@ -0,0 +1,42 @@
+import scala.tools.nsc.doc.base._
+import scala.tools.nsc.doc.base.comment._
+import scala.tools.nsc.doc.model._
+import scala.tools.partest.ScaladocModelTest
+
+object Test extends ScaladocModelTest {
+
+ override def code = """
+
+package org.foo
+
+class MyException extends Exception
+
+class MyOtherException extends Exception
+
+object Foo {
+ /**
+ * Test exception linking
+ *
+ * @throws org.foo.MyException linked with a fully-qualified name
+ * @throws MyOtherException linked with a relative name
+ * @throws SomeUnknownException not linked at all (but with some text)
+ * @throws IOException
+ */
+ def test(): Unit = ???
+}
+ """
+
+ def scaladocSettings = ""
+
+ def testModel(rootPackage: Package) = {
+ // get the quick access implicit defs in scope (_package(s), _class(es), _trait(s), object(s) _method(s), _value(s))
+ import access._
+
+ val a = rootPackage._package("org")._package("foo")._object("Foo")._method("test")
+ val throws = a.comment.get.throws
+ val allbodies = Body(throws.values.flatMap(_.blocks).toSeq)
+
+ val links = countLinksInBody(allbodies, _.link.isInstanceOf[LinkToTpl[_]])
+ assert(links == 2, links + " == 2 (links to MyException and MyOtherException)")
+ }
+}
diff --git a/test/script-tests/README b/test/script-tests/README
index 3f5c2ce19c..7b3291c407 100755
--- a/test/script-tests/README
+++ b/test/script-tests/README
@@ -5,4 +5,9 @@ putting self-contained script tests in here to run some way that doesn't
depend on all the platform stars aligning all the time. Feel free to
join me.
--- extempore, Nov 21 2011 \ No newline at end of file
+-- extempore, Nov 21 2011
+
+But there's a problem that probably nobody would run such tests so they would become outdated quite quickly.
+And therefore they wouldn't work (and even compile) after some time - like this one existing currently.
+
+-- mpociecha, Oct 9 2014 \ No newline at end of file