diff options
Diffstat (limited to 'test/files')
102 files changed, 795 insertions, 621 deletions
diff --git a/test/files/buildmanager/overloaded_1/A.scala b/test/files/disabled/A.scala index 33b63b8006..c070faf978 100644 --- a/test/files/buildmanager/overloaded_1/A.scala +++ b/test/files/disabled/A.scala @@ -3,7 +3,7 @@ trait As { override def foo = this /// Shouldn't cause the change override def foo(act: List[D]) = this } - + abstract class D{ def foo: D = this def foo(act: List[D]) = this diff --git a/test/files/buildmanager/overloaded_1/overloaded_1.check b/test/files/disabled/overloaded_1.check index 4d643ce6b4..4d643ce6b4 100644 --- a/test/files/buildmanager/overloaded_1/overloaded_1.check +++ b/test/files/disabled/overloaded_1.check diff --git a/test/files/buildmanager/overloaded_1/overloaded_1.test b/test/files/disabled/overloaded_1.test index 392e0d365f..392e0d365f 100644 --- a/test/files/buildmanager/overloaded_1/overloaded_1.test +++ b/test/files/disabled/overloaded_1.test diff --git a/test/files/buildmanager/t4245/A.scala b/test/files/disabled/t4245/A.scala index 7c4efe1b4b..7c4efe1b4b 100644 --- a/test/files/buildmanager/t4245/A.scala +++ b/test/files/disabled/t4245/A.scala diff --git a/test/files/buildmanager/t4245/t4245.check b/test/files/disabled/t4245/t4245.check index 3d3898c671..3d3898c671 100644 --- a/test/files/buildmanager/t4245/t4245.check +++ b/test/files/disabled/t4245/t4245.check diff --git a/test/files/buildmanager/t4245/t4245.test b/test/files/disabled/t4245/t4245.test index 392e0d365f..392e0d365f 100644 --- a/test/files/buildmanager/t4245/t4245.test +++ b/test/files/disabled/t4245/t4245.test diff --git a/test/files/jvm/serialization-new.check b/test/files/jvm/serialization-new.check index fa51c6a879..f886cfe29c 100644 --- a/test/files/jvm/serialization-new.check +++ b/test/files/jvm/serialization-new.check @@ -168,6 +168,30 @@ x = History() y = History() x equals y: true, y equals x: true +x = Map(Linked -> 1, Hash -> 2, Map -> 3) +y = Map(Linked -> 1, Hash -> 2, Map -> 3) +x equals y: true, y equals x: true + +x = ArrayBuffer((Linked,1), (Hash,2), (Map,3)) +y = ArrayBuffer((Linked,1), (Hash,2), (Map,3)) +x equals y: true, y equals x: true + +x = ArrayBuffer((Linked,1), (Hash,2), (Map,3)) +y = List((Linked,1), (Hash,2), (Map,3)) +x equals y: true, y equals x: true + +x = Set(layers, buffers, title) +y = Set(layers, buffers, title) +x equals y: true, y equals x: true + +x = ArrayBuffer(layers, buffers, title) +y = ArrayBuffer(layers, buffers, title) +x equals y: true, y equals x: true + +x = ArrayBuffer(layers, buffers, title) +y = List(layers, buffers, title) +x equals y: true, y equals x: true + x = ListBuffer(white, black) y = ListBuffer(white, black) x equals y: true, y equals x: true diff --git a/test/files/jvm/serialization-new.scala b/test/files/jvm/serialization-new.scala index 91eb52928f..1522fc8e27 100644 --- a/test/files/jvm/serialization-new.scala +++ b/test/files/jvm/serialization-new.scala @@ -285,8 +285,8 @@ object Test3_mutable { import scala.reflect.ClassTag import scala.collection.mutable.{ ArrayBuffer, ArrayBuilder, ArraySeq, ArrayStack, BitSet, DoubleLinkedList, - HashMap, HashSet, History, LinkedList, ListBuffer, Publisher, Queue, - Stack, StringBuilder, WrappedArray, TreeSet} + HashMap, HashSet, History, LinkedHashMap, LinkedHashSet, LinkedList, ListBuffer, + Publisher, Queue, Stack, StringBuilder, WrappedArray, TreeSet} import scala.collection.concurrent.TrieMap // in alphabetic order @@ -346,6 +346,26 @@ object Test3_mutable { val h1 = new History[String, Int] val _h1: History[String, Int] = read(write(h1)) check(h1, _h1) + + // LinkedHashMap + { val lhm1 = new LinkedHashMap[String, Int] + val list = List(("Linked", 1), ("Hash", 2), ("Map", 3)) + lhm1 ++= list.iterator + val _lhm1: LinkedHashMap[String, Int] = read(write(lhm1)) + check(lhm1, _lhm1) + check(lhm1.toSeq, _lhm1.toSeq) // check elements order + check(lhm1.toSeq, list) // check elements order + } + + // LinkedHashSet + { val lhs1 = new LinkedHashSet[String] + val list = List("layers", "buffers", "title") + lhs1 ++= list.iterator + val _lhs1: LinkedHashSet[String] = read(write(lhs1)) + check(lhs1, _lhs1) + check(lhs1.toSeq, _lhs1.toSeq) // check elements order + check(lhs1.toSeq, list) // check elements order + } /* // LinkedList val ll1 = new LinkedList[Int](2, null) diff --git a/test/files/jvm/serialization.check b/test/files/jvm/serialization.check index fa51c6a879..f886cfe29c 100644 --- a/test/files/jvm/serialization.check +++ b/test/files/jvm/serialization.check @@ -168,6 +168,30 @@ x = History() y = History() x equals y: true, y equals x: true +x = Map(Linked -> 1, Hash -> 2, Map -> 3) +y = Map(Linked -> 1, Hash -> 2, Map -> 3) +x equals y: true, y equals x: true + +x = ArrayBuffer((Linked,1), (Hash,2), (Map,3)) +y = ArrayBuffer((Linked,1), (Hash,2), (Map,3)) +x equals y: true, y equals x: true + +x = ArrayBuffer((Linked,1), (Hash,2), (Map,3)) +y = List((Linked,1), (Hash,2), (Map,3)) +x equals y: true, y equals x: true + +x = Set(layers, buffers, title) +y = Set(layers, buffers, title) +x equals y: true, y equals x: true + +x = ArrayBuffer(layers, buffers, title) +y = ArrayBuffer(layers, buffers, title) +x equals y: true, y equals x: true + +x = ArrayBuffer(layers, buffers, title) +y = List(layers, buffers, title) +x equals y: true, y equals x: true + x = ListBuffer(white, black) y = ListBuffer(white, black) x equals y: true, y equals x: true diff --git a/test/files/jvm/serialization.scala b/test/files/jvm/serialization.scala index 9c2f2acdbf..34b64938b4 100644 --- a/test/files/jvm/serialization.scala +++ b/test/files/jvm/serialization.scala @@ -285,8 +285,8 @@ object Test3_mutable { import scala.reflect.ClassManifest import scala.collection.mutable.{ ArrayBuffer, ArrayBuilder, ArraySeq, ArrayStack, BitSet, DoubleLinkedList, - HashMap, HashSet, History, LinkedList, ListBuffer, Publisher, Queue, - Stack, StringBuilder, WrappedArray, TreeSet} + HashMap, HashSet, History, LinkedHashMap, LinkedHashSet, LinkedList, ListBuffer, + Publisher, Queue, Stack, StringBuilder, WrappedArray, TreeSet} import scala.collection.concurrent.TrieMap // in alphabetic order @@ -346,6 +346,26 @@ object Test3_mutable { val h1 = new History[String, Int] val _h1: History[String, Int] = read(write(h1)) check(h1, _h1) + + // LinkedHashMap + { val lhm1 = new LinkedHashMap[String, Int] + val list = List(("Linked", 1), ("Hash", 2), ("Map", 3)) + lhm1 ++= list.iterator + val _lhm1: LinkedHashMap[String, Int] = read(write(lhm1)) + check(lhm1, _lhm1) + check(lhm1.toSeq, _lhm1.toSeq) // check elements order + check(lhm1.toSeq, list) // check elements order + } + + // LinkedHashSet + { val lhs1 = new LinkedHashSet[String] + val list = List("layers", "buffers", "title") + lhs1 ++= list.iterator + val _lhs1: LinkedHashSet[String] = read(write(lhs1)) + check(lhs1, _lhs1) + check(lhs1.toSeq, _lhs1.toSeq) // check elements order + check(lhs1.toSeq, list) // check elements order + } /* // LinkedList val ll1 = new LinkedList[Int](2, null) diff --git a/test/files/lib/javac-artifacts.jar.desired.sha1 b/test/files/lib/javac-artifacts.jar.desired.sha1 new file mode 100644 index 0000000000..8dbbc1d451 --- /dev/null +++ b/test/files/lib/javac-artifacts.jar.desired.sha1 @@ -0,0 +1 @@ +c5788c5e518eb267445c5a995fd98b2210f90a58 ?javac-artifacts.jar diff --git a/test/files/neg/applydynamic_sip.check b/test/files/neg/applydynamic_sip.check index 8845f68a52..dcf97b29fc 100644 --- a/test/files/neg/applydynamic_sip.check +++ b/test/files/neg/applydynamic_sip.check @@ -7,4 +7,52 @@ applydynamic_sip.scala:8: error: applyDynamicNamed does not support passing a va applydynamic_sip.scala:9: error: applyDynamicNamed does not support passing a vararg parameter qual.sel(arg, arg2 = "a2", a2: _*) ^ -three errors found +applydynamic_sip.scala:18: error: type mismatch; + found : String("sel") + required: Int +error after rewriting to Test.this.bad1.selectDynamic("sel") +possible cause: maybe a wrong Dynamic method signature? + bad1.sel + ^ +applydynamic_sip.scala:19: error: type mismatch; + found : String("sel") + required: Int +error after rewriting to Test.this.bad1.applyDynamic("sel") +possible cause: maybe a wrong Dynamic method signature? + bad1.sel(1) + ^ +applydynamic_sip.scala:20: error: type mismatch; + found : String("sel") + required: Int +error after rewriting to Test.this.bad1.applyDynamicNamed("sel") +possible cause: maybe a wrong Dynamic method signature? + bad1.sel(a = 1) + ^ +applydynamic_sip.scala:21: error: type mismatch; + found : String("sel") + required: Int +error after rewriting to Test.this.bad1.updateDynamic("sel") +possible cause: maybe a wrong Dynamic method signature? + bad1.sel = 1 + ^ +applydynamic_sip.scala:29: error: Int does not take parameters +error after rewriting to Test.this.bad2.selectDynamic("sel") +possible cause: maybe a wrong Dynamic method signature? + bad2.sel + ^ +applydynamic_sip.scala:30: error: Int does not take parameters +error after rewriting to Test.this.bad2.applyDynamic("sel") +possible cause: maybe a wrong Dynamic method signature? + bad2.sel(1) + ^ +applydynamic_sip.scala:31: error: Int does not take parameters +error after rewriting to Test.this.bad2.applyDynamicNamed("sel") +possible cause: maybe a wrong Dynamic method signature? + bad2.sel(a = 1) + ^ +applydynamic_sip.scala:32: error: Int does not take parameters +error after rewriting to Test.this.bad2.updateDynamic("sel") +possible cause: maybe a wrong Dynamic method signature? + bad2.sel = 1 + ^ +11 errors found diff --git a/test/files/neg/applydynamic_sip.flags b/test/files/neg/applydynamic_sip.flags new file mode 100644 index 0000000000..1141f97507 --- /dev/null +++ b/test/files/neg/applydynamic_sip.flags @@ -0,0 +1 @@ +-language:dynamics diff --git a/test/files/neg/applydynamic_sip.scala b/test/files/neg/applydynamic_sip.scala index 362461577b..ee4432ebe6 100644 --- a/test/files/neg/applydynamic_sip.scala +++ b/test/files/neg/applydynamic_sip.scala @@ -7,4 +7,27 @@ object Test extends App { qual.sel(a, a2: _*) qual.sel(arg = a, a2: _*) qual.sel(arg, arg2 = "a2", a2: _*) -}
\ No newline at end of file + + val bad1 = new Dynamic { + def selectDynamic(n: Int) = n + def applyDynamic(n: Int) = n + def applyDynamicNamed(n: Int) = n + def updateDynamic(n: Int) = n + + } + bad1.sel + bad1.sel(1) + bad1.sel(a = 1) + bad1.sel = 1 + + val bad2 = new Dynamic { + def selectDynamic = 1 + def applyDynamic = 1 + def applyDynamicNamed = 1 + def updateDynamic = 1 + } + bad2.sel + bad2.sel(1) + bad2.sel(a = 1) + bad2.sel = 1 +} diff --git a/test/files/neg/macro-invalidret-nonuniversetree.check b/test/files/neg/macro-invalidret-nonuniversetree.check index 09df2c0a92..b3a4d0da80 100644 --- a/test/files/neg/macro-invalidret-nonuniversetree.check +++ b/test/files/neg/macro-invalidret-nonuniversetree.check @@ -1,7 +1,7 @@ Macros_Test_2.scala:2: error: macro implementation has wrong shape:
required: (c: scala.reflect.macros.Context): c.Expr[Any]
- found : (c: scala.reflect.macros.Context): reflect.basis.Literal
-type mismatch for return type: reflect.basis.Literal does not conform to c.Expr[Any]
+ found : (c: scala.reflect.macros.Context): reflect.runtime.universe.Literal
+type mismatch for return type: reflect.runtime.universe.Literal does not conform to c.Expr[Any]
def foo = macro Impls.foo
^
one error found
diff --git a/test/files/neg/macro-invalidret-nonuniversetree/Impls_1.scala b/test/files/neg/macro-invalidret-nonuniversetree/Impls_1.scala index 8311d474c2..f98376a2ba 100644 --- a/test/files/neg/macro-invalidret-nonuniversetree/Impls_1.scala +++ b/test/files/neg/macro-invalidret-nonuniversetree/Impls_1.scala @@ -1,5 +1,6 @@ import scala.reflect.macros.{Context => Ctx} +import scala.reflect.runtime.{universe => ru} object Impls { - def foo(c: Ctx) = scala.reflect.basis.Literal(scala.reflect.basis.Constant(42)) + def foo(c: Ctx) = ru.Literal(ru.Constant(42)) } diff --git a/test/files/neg/static-annot.check b/test/files/neg/static-annot.check deleted file mode 100644 index c98e7d9658..0000000000 --- a/test/files/neg/static-annot.check +++ /dev/null @@ -1,22 +0,0 @@ -static-annot.scala:8: error: Only members of top-level objects and their nested objects can be annotated with @static. - @static val bar = 1 - ^ -static-annot.scala:27: error: @static annotated field bar has the same name as a member of class Conflicting - @static val bar = 1 - ^ -static-annot.scala:37: error: The @static annotation is only allowed on public members. - @static private val bar = 1 - ^ -static-annot.scala:38: error: The @static annotation is only allowed on public members. - @static private val baz = 2 - ^ -static-annot.scala:39: error: The @static annotation is not allowed on lazy members. - @static lazy val bam = 3 - ^ -static-annot.scala:52: error: The @static annotation is not allowed on method definitions. - @static def x = 42 - ^ -static-annot.scala:14: error: Only members of top-level objects and their nested objects can be annotated with @static. - @static val blah = 2 - ^ -7 errors found diff --git a/test/files/neg/static-annot.scala b/test/files/neg/static-annot.scala deleted file mode 100644 index c0b5ed30d8..0000000000 --- a/test/files/neg/static-annot.scala +++ /dev/null @@ -1,53 +0,0 @@ - - -import annotation.static - - - -class StaticInClass { - @static val bar = 1 -} - - -class NestedObjectInClass { - object Nested { - @static val blah = 2 - } -} - - -object NestedObjectInObject { - object Nested { - @static val succeed = 3 - } -} - - -object Conflicting { - @static val bar = 1 -} - - -class Conflicting { - val bar = 45 -} - - -object PrivateProtectedLazy { - @static private val bar = 1 - @static private val baz = 2 - @static lazy val bam = 3 -} - - -class PrivateProtectedLazy { - println(PrivateProtectedLazy.bar) - println(PrivateProtectedLazy.baz) - println(PrivateProtectedLazy.bam) -} - - -class StaticDef { - // this should not crash the compiler - @static def x = 42 -} diff --git a/test/files/neg/t4581/static-declaration_1.scala b/test/files/neg/t4581/static-declaration_1.scala deleted file mode 100644 index f9a66b29c1..0000000000 --- a/test/files/neg/t4581/static-declaration_1.scala +++ /dev/null @@ -1,14 +0,0 @@ - - - - - -object Constants { - import scala.annotation.static - @static val Const: Int = 0 // should generate a static final field - @static final val FinalConst: Int = 0 // ditto - @static var MutableField: Int = 0 // should not be final -} - - - diff --git a/test/files/neg/t4581/static_2.java b/test/files/neg/t4581/static_2.java deleted file mode 100644 index 2fd5bf1d82..0000000000 --- a/test/files/neg/t4581/static_2.java +++ /dev/null @@ -1,15 +0,0 @@ - - - - -public class static_2 { - public static void main(String[] args) { - Constants.Const = 17; - Constants.FinalConst = 99; - Constants.MutableField = 199; - } -} - - - - diff --git a/test/files/neg/t5692a.check b/test/files/neg/t5692a.check new file mode 100644 index 0000000000..527cb35fba --- /dev/null +++ b/test/files/neg/t5692a.check @@ -0,0 +1,4 @@ +Test_2.scala:2: error: type parameter not specified
+ def x = Macros.foo
+ ^
+one error found
diff --git a/test/files/neg/t5692a.flags b/test/files/neg/t5692a.flags new file mode 100644 index 0000000000..cd66464f2f --- /dev/null +++ b/test/files/neg/t5692a.flags @@ -0,0 +1 @@ +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/t5692a/Macros_1.scala b/test/files/neg/t5692a/Macros_1.scala new file mode 100644 index 0000000000..06b5a3de36 --- /dev/null +++ b/test/files/neg/t5692a/Macros_1.scala @@ -0,0 +1,6 @@ +import scala.reflect.macros.Context + +object Macros { + def impl[T](c: Context) = c.literalUnit + def foo[T] = macro impl[T] +}
\ No newline at end of file diff --git a/test/files/neg/t5692a/Test_2.scala b/test/files/neg/t5692a/Test_2.scala new file mode 100644 index 0000000000..08d510cc6f --- /dev/null +++ b/test/files/neg/t5692a/Test_2.scala @@ -0,0 +1,3 @@ +class Test { + def x = Macros.foo +}
\ No newline at end of file diff --git a/test/files/neg/t5692b.check b/test/files/neg/t5692b.check new file mode 100644 index 0000000000..8f6b2624cf --- /dev/null +++ b/test/files/neg/t5692b.check @@ -0,0 +1,4 @@ +Test_2.scala:2: error: type parameters not specified
+ def x = Macros.foo
+ ^
+one error found
diff --git a/test/files/neg/t5692b.flags b/test/files/neg/t5692b.flags new file mode 100644 index 0000000000..cd66464f2f --- /dev/null +++ b/test/files/neg/t5692b.flags @@ -0,0 +1 @@ +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/t5692b/Macros_1.scala b/test/files/neg/t5692b/Macros_1.scala new file mode 100644 index 0000000000..b28d19f903 --- /dev/null +++ b/test/files/neg/t5692b/Macros_1.scala @@ -0,0 +1,6 @@ +import scala.reflect.macros.Context + +object Macros { + def impl[T, U](c: Context) = c.literalUnit + def foo[T, U] = macro impl[T, U] +}
\ No newline at end of file diff --git a/test/files/neg/t5692b/Test_2.scala b/test/files/neg/t5692b/Test_2.scala new file mode 100644 index 0000000000..08d510cc6f --- /dev/null +++ b/test/files/neg/t5692b/Test_2.scala @@ -0,0 +1,3 @@ +class Test { + def x = Macros.foo +}
\ No newline at end of file diff --git a/test/files/neg/t6260.check b/test/files/neg/t6260.check new file mode 100644 index 0000000000..2b7f1a8bfb --- /dev/null +++ b/test/files/neg/t6260.check @@ -0,0 +1,13 @@ +t6260.scala:3: error: bridge generated for member method apply: (x$1: Box[X])Box[Y] in anonymous class $anonfun +which overrides method apply: (v1: T1)R in trait Function1 +clashes with definition of the member itself; +both have erased type (v1: Object)Object + ((bx: Box[X]) => new Box(f(bx.x)))(this) + ^ +t6260.scala:8: error: bridge generated for member method apply: (x$1: Box[X])Box[Y] in anonymous class $anonfun +which overrides method apply: (v1: T1)R in trait Function1 +clashes with definition of the member itself; +both have erased type (v1: Object)Object + ((bx: Box[X]) => new Box(f(bx.x)))(self) + ^ +two errors found diff --git a/test/files/neg/t6260.scala b/test/files/neg/t6260.scala new file mode 100644 index 0000000000..93b5448227 --- /dev/null +++ b/test/files/neg/t6260.scala @@ -0,0 +1,17 @@ +class Box[X](val x: X) extends AnyVal { + def map[Y](f: X => Y): Box[Y] = + ((bx: Box[X]) => new Box(f(bx.x)))(this) +} + +object Test { + def map2[X, Y](self: Box[X], f: X => Y): Box[Y] = + ((bx: Box[X]) => new Box(f(bx.x)))(self) + + def main(args: Array[String]) { + val f = (x: Int) => x + 1 + val g = (x: String) => x + x + + map2(new Box(42), f) + new Box("abc") map g + } +} diff --git a/test/files/neg/t6385.check b/test/files/neg/t6385.check new file mode 100644 index 0000000000..93e51e8927 --- /dev/null +++ b/test/files/neg/t6385.check @@ -0,0 +1,7 @@ +t6385.scala:12: error: bridge generated for member method x: ()C[T] in class C +which overrides method x: ()C[T] in trait AA +clashes with definition of the member itself; +both have erased type ()Object + def x = this + ^ +one error found diff --git a/test/files/neg/t6385.scala b/test/files/neg/t6385.scala new file mode 100644 index 0000000000..cec58eec9e --- /dev/null +++ b/test/files/neg/t6385.scala @@ -0,0 +1,13 @@ +object N { + def main(args: Array[String]) { + val y: AA[Int] = C(2) + val c: Int = y.x.y + println(c) + } +} +trait AA[T] extends Any { + def x: C[T] +} +case class C[T](val y: T) extends AnyVal with AA[T] { + def x = this +} diff --git a/test/files/neg/valueclasses-pavlov.check b/test/files/neg/valueclasses-pavlov.check new file mode 100644 index 0000000000..031589edad --- /dev/null +++ b/test/files/neg/valueclasses-pavlov.check @@ -0,0 +1,7 @@ +valueclasses-pavlov.scala:8: error: double definition: +method foo:(x: Box2)String and +method foo:(x: String)String at line 7 +have same type after erasure: (x: String)String + def foo(x: Box2) = "foo(Box2): ok" + ^ +one error found diff --git a/test/files/neg/valueclasses-pavlov.scala b/test/files/neg/valueclasses-pavlov.scala new file mode 100644 index 0000000000..a5858b2cf0 --- /dev/null +++ b/test/files/neg/valueclasses-pavlov.scala @@ -0,0 +1,23 @@ +trait Foo[T <: AnyVal] extends Any { + def foo(x: String): String + def foo(x: T): String +} + +class Box1(val value: String) extends AnyVal with Foo[Box2] { + def foo(x: String) = "foo(String): ok" + def foo(x: Box2) = "foo(Box2): ok" +} + +class Box2(val value: String) extends AnyVal + + +object test2a { + + def main(args: Array[String]) { + val b1 = new Box1(null) + val b2 = new Box2(null) + val f: Foo[Box2] = b1 + println(f.foo("")) + println(f.foo(b2)) + } +} diff --git a/test/files/pos/t6294.scala b/test/files/pos/t6294.scala deleted file mode 100644 index c6d39a9cc8..0000000000 --- a/test/files/pos/t6294.scala +++ /dev/null @@ -1,14 +0,0 @@ - - - -object A { - @annotation.static final val x = 123 -} - - -object B { - println(A.x) -} - - - diff --git a/test/files/pos/typetags.scala b/test/files/pos/typetags.scala index 33390d7b89..239a9b32ec 100644 --- a/test/files/pos/typetags.scala +++ b/test/files/pos/typetags.scala @@ -1,12 +1,16 @@ -import scala.reflect.{basis => rb} -import scala.reflect.runtime.{universe => ru} +// TODO come up with a non-trivial universe different from ru +// an rewrite this test, so that it makes sure that cross-universe implicit searches work +// +// import scala.reflect.{basis => rb} +// import scala.reflect.runtime.{universe => ru} +// object Test { +// def main(args: Array[String]) { +// def foo(implicit t: rb.TypeTag[List[Int]]) { +// println(t) +// val t2: ru.TypeTag[_] = t in ru.rootMirror +// println(t2) +// } +// } +// } -object Test { - def main(args: Array[String]) { - def foo(implicit t: rb.TypeTag[List[Int]]) { - println(t) - val t2: ru.TypeTag[_] = t in ru.rootMirror - println(t2) - } - } -} +object Test extends App
\ No newline at end of file diff --git a/test/files/run/Meter.scala b/test/files/run/Meter.scala index d94f338ca9..a0c04cc2a7 100644 --- a/test/files/run/Meter.scala +++ b/test/files/run/Meter.scala @@ -2,7 +2,7 @@ package a { class Meter(val underlying: Double) extends AnyVal with _root_.b.Printable { def + (other: Meter): Meter = new Meter(this.underlying + other.underlying) - def / (other: Meter): Double = this.underlying / other.underlying + def / (other: Meter)(implicit dummy: Meter.MeterArg = null): Double = this.underlying / other.underlying def / (factor: Double): Meter = new Meter(this.underlying / factor) def < (other: Meter): Boolean = this.underlying < other.underlying def toFoot: Foot = new Foot(this.underlying * 0.3048) @@ -12,6 +12,8 @@ package a { object Meter extends (Double => Meter) { + private[a] trait MeterArg + def apply(x: Double): Meter = new Meter(x) implicit val boxings = new BoxingConversions[Meter, Double] { @@ -80,7 +82,7 @@ object Test extends App { println(m) foo(arr) } - // + // // { println("testing wrapped arrays") // import collection.mutable.FlatArray // val arr = FlatArray(x, y + x) diff --git a/test/files/run/MeterCaseClass.scala b/test/files/run/MeterCaseClass.scala index e5979cf761..18f8e23f89 100644 --- a/test/files/run/MeterCaseClass.scala +++ b/test/files/run/MeterCaseClass.scala @@ -2,7 +2,7 @@ package a { case class Meter(underlying: Double) extends AnyVal with _root_.b.Printable { def + (other: Meter): Meter = new Meter(this.underlying + other.underlying) - def / (other: Meter): Double = this.underlying / other.underlying + def / (other: Meter)(implicit dummy: Meter.MeterArg = null): Double = this.underlying / other.underlying def / (factor: Double): Meter = new Meter(this.underlying / factor) def < (other: Meter): Boolean = this.underlying < other.underlying def toFoot: Foot = new Foot(this.underlying * 0.3048) @@ -11,6 +11,8 @@ package a { object Meter extends (Double => Meter) { + private[a] trait MeterArg + implicit val boxings = new BoxingConversions[Meter, Double] { def box(x: Double) = new Meter(x) def unbox(m: Meter) = m.underlying @@ -77,7 +79,7 @@ object Test extends App { println(m) foo(arr) } - // + // // { println("testing wrapped arrays") // import collection.mutable.FlatArray // val arr = FlatArray(x, y + x) diff --git a/test/files/run/abstypetags_serialize.scala b/test/files/run/abstypetags_serialize.scala index 38a7aba325..93fb5dcd06 100644 --- a/test/files/run/abstypetags_serialize.scala +++ b/test/files/run/abstypetags_serialize.scala @@ -1,5 +1,6 @@ import java.io._ import scala.reflect.runtime.universe._ +import scala.reflect.runtime.{universe => ru} import scala.reflect.runtime.{currentMirror => cm} object Test extends App { @@ -13,7 +14,7 @@ object Test extends App { val fin = new ByteArrayInputStream(fout.toByteArray) val in = new ObjectInputStream(fin) - val retag = in.readObject().asInstanceOf[scala.reflect.basis.WeakTypeTag[_]].in(cm) + val retag = in.readObject().asInstanceOf[ru.WeakTypeTag[_]].in(cm) in.close() fin.close() diff --git a/test/files/run/collections.check b/test/files/run/collections.check index b87a5998c5..c24150b24d 100644 --- a/test/files/run/collections.check +++ b/test/files/run/collections.check @@ -2,6 +2,10 @@ test1: 14005 test2: 25005003, iters = 5000 test3: 25005003 +***** mutable.LinkedHashSet: +test1: 14005 +test2: 25005003, iters = 5000 +test3: 25005003 ***** immutable.Set: test1: 14005 test2: 25005003, iters = 5000 @@ -18,6 +22,10 @@ test3: 25005003 test1: 14005 test2: 25005003, iters = 5000 test3: 25005003 +***** mutable.LinkedHashMap: +test1: 14005 +test2: 25005003, iters = 5000 +test3: 25005003 ***** immutable.Map: test1: 14005 test2: 25005003, iters = 5000 diff --git a/test/files/run/collections.scala b/test/files/run/collections.scala index 60f0765e6a..69c40fae80 100644 --- a/test/files/run/collections.scala +++ b/test/files/run/collections.scala @@ -106,10 +106,12 @@ object Test extends App { } test("mutable.HashSet", new mutable.HashSet[Int], 5000) + test("mutable.LinkedHashSet", new mutable.LinkedHashSet[Int], 5000) test("immutable.Set", immutable.Set[Int](), 5000) test("immutable.ListSet", new immutable.ListSet[Int], 5000) test("immutable.TreeSet", new immutable.TreeSet[Int], 5000) test("mutable.HashMap", new mutable.HashMap[Int, Int], 5000) + test("mutable.LinkedHashMap", new mutable.LinkedHashMap[Int, Int], 5000) test("immutable.Map", immutable.Map[Int, Int](), 5000) test("immutable.TreeMap", new immutable.TreeMap[Int, Int], 5000) test("immutable.ListMap", new immutable.ListMap[Int, Int], 3000) diff --git a/test/files/run/colltest.check b/test/files/run/colltest.check index 1ad81a1350..e5bb013ed7 100644 --- a/test/files/run/colltest.check +++ b/test/files/run/colltest.check @@ -5,3 +5,4 @@ false true false succeeded for 10 iterations. +succeeded for 10 iterations. diff --git a/test/files/run/colltest.scala b/test/files/run/colltest.scala index ecd234bdd1..703e94a3c7 100644 --- a/test/files/run/colltest.scala +++ b/test/files/run/colltest.scala @@ -61,5 +61,6 @@ object Test extends App { } t3954 - new TestSet(HashSet.empty, new scala.collection.mutable.LinkedHashSet) + new TestSet(HashSet.empty, new LinkedHashSet) + new TestSet(new ImmutableSetAdaptor(collection.immutable.Set.empty[Int]), new LinkedHashSet) } diff --git a/test/files/run/colltest1.check b/test/files/run/colltest1.check index 7377174281..5ec6286d9e 100644 --- a/test/files/run/colltest1.check +++ b/test/files/run/colltest1.check @@ -107,3 +107,5 @@ List((A,A), (B,B), (C,C), (D,D), (E,E), (F,F), (G,G), (H,H), (I,I), (J,J), (K,K) List((A,A), (B,B), (C,C), (D,D), (E,E), (F,F), (G,G), (H,H), (I,I), (J,J), (K,K), (L,L), (M,M), (N,N), (O,O), (P,P), (Q,Q), (R,R), (S,S), (T,T), (U,U), (V,V), (W,W), (X,X), (Y,Y), (Z,Z)) List((A,A), (B,B), (C,C), (D,D), (E,E), (F,F), (G,G), (H,H), (I,I), (J,J), (K,K), (L,L), (M,M), (N,N), (O,O), (P,P), (Q,Q), (R,R), (S,S), (T,T), (U,U), (V,V), (W,W), (X,X), (Y,Y), (Z,Z)) List((A,A), (B,B), (C,C), (D,D), (E,E), (F,F), (G,G), (H,H), (I,I), (J,J), (K,K), (L,L), (M,M), (N,N), (O,O), (P,P), (Q,Q), (R,R), (S,S), (T,T), (U,U), (V,V), (W,W), (X,X), (Y,Y), (Z,Z)) +List((A,A), (B,B), (C,C), (D,D), (E,E), (F,F), (G,G), (H,H), (I,I), (J,J), (K,K), (L,L), (M,M), (N,N), (O,O), (P,P), (Q,Q), (R,R), (S,S), (T,T), (U,U), (V,V), (W,W), (X,X), (Y,Y), (Z,Z)) +List((A,A), (B,B), (C,C), (D,D), (E,E), (F,F), (G,G), (H,H), (I,I), (J,J), (K,K), (L,L), (M,M), (N,N), (O,O), (P,P), (Q,Q), (R,R), (S,S), (T,T), (U,U), (V,V), (W,W), (X,X), (Y,Y), (Z,Z)) diff --git a/test/files/run/colltest1.scala b/test/files/run/colltest1.scala index 1cbd932222..54adeb7cda 100644 --- a/test/files/run/colltest1.scala +++ b/test/files/run/colltest1.scala @@ -226,6 +226,7 @@ object Test extends App { setTest(mutable.Set()) setTest(immutable.Set()) setTest(mutable.HashSet()) + setTest(mutable.LinkedHashSet()) setTest(immutable.HashSet()) mapTest(Map()) @@ -233,5 +234,6 @@ object Test extends App { mapTest(immutable.Map()) mapTest(immutable.TreeMap()) mutableMapTest(mutable.HashMap()) + mutableMapTest(mutable.LinkedHashMap()) mapTest(immutable.HashMap()) } diff --git a/test/files/run/exprs_serialize.scala b/test/files/run/exprs_serialize.scala index 075c902a34..c4310b0fe1 100644 --- a/test/files/run/exprs_serialize.scala +++ b/test/files/run/exprs_serialize.scala @@ -1,5 +1,6 @@ import java.io._ import scala.reflect.runtime.universe._ +import scala.reflect.runtime.{universe => ru} import scala.reflect.runtime.{currentMirror => cm} object Test extends App { @@ -13,7 +14,7 @@ object Test extends App { val fin = new ByteArrayInputStream(fout.toByteArray) val in = new ObjectInputStream(fin) - val reexpr = in.readObject().asInstanceOf[scala.reflect.basis.Expr[_]].in(cm) + val reexpr = in.readObject().asInstanceOf[ru.Expr[_]].in(cm) in.close() fin.close() diff --git a/test/files/run/macro-expand-implicit-argument/Macros_1.scala b/test/files/run/macro-expand-implicit-argument/Macros_1.scala index 86c4198870..b1665256cd 100644 --- a/test/files/run/macro-expand-implicit-argument/Macros_1.scala +++ b/test/files/run/macro-expand-implicit-argument/Macros_1.scala @@ -4,7 +4,7 @@ import scala.{specialized => spec} import language.experimental.macros -import scala.reflect.{ClassTag, TypeTag} +import scala.reflect.ClassTag import scala.reflect.macros.Context object Macros { diff --git a/test/files/run/macro-typecheck-macrosdisabled.check b/test/files/run/macro-typecheck-macrosdisabled.check index c560b0e4b5..c88d33b48e 100644 --- a/test/files/run/macro-typecheck-macrosdisabled.check +++ b/test/files/run/macro-typecheck-macrosdisabled.check @@ -7,7 +7,7 @@ $treecreator1.super.<init>();
()
};
- def apply[U >: Nothing <: scala.reflect.base.Universe with Singleton]($m$untyped: scala.reflect.base.MirrorOf[U]): U#Tree = {
+ def apply[U >: Nothing <: scala.reflect.api.Universe with Singleton]($m$untyped: scala.reflect.api.MirrorOf[U]): U#Tree = {
val $u: U = $m$untyped.universe;
val $m: $u.Mirror = $m$untyped.asInstanceOf[$u.Mirror];
$u.Literal.apply($u.Constant.apply(2))
@@ -20,7 +20,7 @@ $typecreator2.super.<init>();
()
};
- def apply[U >: Nothing <: scala.reflect.base.Universe with Singleton]($m$untyped: scala.reflect.base.MirrorOf[U]): U#Type = {
+ def apply[U >: Nothing <: scala.reflect.api.Universe with Singleton]($m$untyped: scala.reflect.api.MirrorOf[U]): U#Type = {
val $u: U = $m$untyped.universe;
val $m: $u.Mirror = $m$untyped.asInstanceOf[$u.Mirror];
$u.ConstantType.apply($u.Constant.apply(2))
diff --git a/test/files/run/macro-typecheck-macrosdisabled2.check b/test/files/run/macro-typecheck-macrosdisabled2.check index 55e7913250..469f41aa94 100644 --- a/test/files/run/macro-typecheck-macrosdisabled2.check +++ b/test/files/run/macro-typecheck-macrosdisabled2.check @@ -7,7 +7,7 @@ $treecreator1.super.<init>();
()
};
- def apply[U >: Nothing <: scala.reflect.base.Universe with Singleton]($m$untyped: scala.reflect.base.MirrorOf[U]): U#Tree = {
+ def apply[U >: Nothing <: scala.reflect.api.Universe with Singleton]($m$untyped: scala.reflect.api.MirrorOf[U]): U#Tree = {
val $u: U = $m$untyped.universe;
val $m: $u.Mirror = $m$untyped.asInstanceOf[$u.Mirror];
$u.Apply.apply($u.Select.apply($u.Select.apply($u.build.Ident($m.staticPackage("scala")), $u.newTermName("Array")), $u.newTermName("apply")), scala.collection.immutable.List.apply[$u.Literal]($u.Literal.apply($u.Constant.apply(2))))
@@ -20,7 +20,7 @@ $typecreator2.super.<init>();
()
};
- def apply[U >: Nothing <: scala.reflect.base.Universe with Singleton]($m$untyped: scala.reflect.base.MirrorOf[U]): U#Type = {
+ def apply[U >: Nothing <: scala.reflect.api.Universe with Singleton]($m$untyped: scala.reflect.api.MirrorOf[U]): U#Type = {
val $u: U = $m$untyped.universe;
val $m: $u.Mirror = $m$untyped.asInstanceOf[$u.Mirror];
$u.TypeRef.apply($u.ThisType.apply($m.staticPackage("scala").asModule.moduleClass), $m.staticClass("scala.Array"), scala.collection.immutable.List.apply[$u.Type]($m.staticClass("scala.Int").asType.toTypeConstructor))
diff --git a/test/files/run/newTags.check b/test/files/run/newTags.check index 2cbc265d7a..0c1bd95eb2 100644 --- a/test/files/run/newTags.check +++ b/test/files/run/newTags.check @@ -1,5 +1,3 @@ -TypeRef(SingleType(SingleType(SingleType(NoPrefix,class <root>),module scala),module package),class List,List(TypeRef(ThisType(class scala),class Int,List())))
List[Int]
-TypeRef(SingleType(ThisType(class scala),module Predef),class Map,List(TypeRef(SingleType(ThisType(class scala),module Predef),class String,List()), TypeRef(SingleType(ThisType(class scala),module Predef),class String,List())))
Map[String,String]
-TypeTag[TypeRef(SingleType(ThisType(class scala),module Predef),class Map,List(TypeRef(SingleType(ThisType(class scala),module Predef),class String,List()), TypeRef(SingleType(ThisType(class scala),module Predef),class String,List())))]
+TypeTag[Map[String,String]]
diff --git a/test/files/run/newTags.scala b/test/files/run/newTags.scala index a758599515..c5199d4e55 100644 --- a/test/files/run/newTags.scala +++ b/test/files/run/newTags.scala @@ -1,14 +1,11 @@ -import scala.reflect.base.{Universe => BaseUniverse} -import scala.reflect.{basis => rb} +import scala.reflect.api.{Universe => ApiUniverse} import scala.reflect.runtime.{universe => ru} object Test extends App { - println(rb.typeOf[List[Int]]) println(ru.typeOf[List[Int]]) - def foo[T: rb.TypeTag] = { - println(rb.typeOf[T]) + def foo[T: ru.TypeTag] = { println(ru.typeOf[T]) - println(implicitly[BaseUniverse#TypeTag[T]]) + println(implicitly[ApiUniverse#TypeTag[T]]) } foo[Map[String, String]] }
\ No newline at end of file diff --git a/test/files/run/reflection-java-annotations.check b/test/files/run/reflection-java-annotations.check index 84cfd03358..53c53cfbcc 100644 --- a/test/files/run/reflection-java-annotations.check +++ b/test/files/run/reflection-java-annotations.check @@ -1,22 +1 @@ -Type in expressions to have them evaluated.
-Type :help for more information.
-
-scala>
-
-scala> import scala.reflect.runtime.universe._
-import scala.reflect.runtime.universe._
-
-scala> val sym = typeOf[Foo].typeSymbol
-sym: reflect.runtime.universe.Symbol = class Foo
-
-scala> sym.typeSignature
-res0: reflect.runtime.universe.Type = java.lang.Object{def <init>(): Foo}
-
-scala> sym.getAnnotations foreach (_.javaArgs)
-
-scala> println(sym.getAnnotations)
-List(ComplexAnnotation(v1 = 1, v10 = "hello", v101 = [101, 101], v102 = [102, 102], v103 = ['g', 'g'], v104 = [104, 104], v105 = [105L, 105L], v106 = [106.0, 106.0], v107 = [107.0, 107.0], v108 = [false, true], v11 = classOf[Foo], v110 = ["hello", "world"], v111 = [classOf[SimpleAnnotation], classOf[ComplexAnnotation]], v113 = [SimpleAnnotation(v1 = 21, v10 = "world2", v11 = classOf[ComplexAnnotation], v2 = 22, v3 = '\027', v4 = 24, v5 = 25L, v6 = 26.0, v7 = 27.0, v8 = false)], v13 = SimpleAnnotation(v1 = 11, v10 = "world1", v11 = classOf[SimpleAnnotation], v2 = 12, v3 = '\r', v4 = 14, v5 = 15L, v6 = 16.0, v7 = 17.0, v8 = false), v2 = 2, v3 = '\03', v4 = 4, v5 = 5L, v6 = 6.0, v7 = 7.0, v8 = false))
-
-scala>
-
-scala>
+List(JavaComplexAnnotation(v1 = 1, v10 = "hello", v101 = [101, 101], v102 = [102, 102], v103 = ['g', 'g'], v104 = [104, 104], v105 = [105L, 105L], v106 = [106.0, 106.0], v107 = [107.0, 107.0], v108 = [false, true], v11 = classOf[JavaAnnottee], v110 = ["hello", "world"], v111 = [classOf[JavaSimpleAnnotation], classOf[JavaComplexAnnotation]], v112 = [FOO, BAR], v113 = [JavaSimpleAnnotation(v1 = 21, v10 = "world2", v11 = classOf[JavaComplexAnnotation], v12 = BAR, v2 = 22, v3 = '\027', v4 = 24, v5 = 25L, v6 = 26.0, v7 = 27.0, v8 = false)], v12 = FOO, v13 = JavaSimpleAnnotation(v1 = 11, v10 = "world1", v11 = classOf[JavaSimpleAnnotation], v12 = FOO, v2 = 12, v3 = '\r', v4 = 14, v5 = 15L, v6 = 16.0, v7 = 17.0, v8 = false), v2 = 2, v3 = '\03', v4 = 4, v5 = 5L, v6 = 6.0, v7 = 7.0, v8 = false)) diff --git a/test/files/run/reflection-java-annotations.jar.desired.sha1 b/test/files/run/reflection-java-annotations.jar.desired.sha1 deleted file mode 100644 index 430e7626e6..0000000000 --- a/test/files/run/reflection-java-annotations.jar.desired.sha1 +++ /dev/null @@ -1 +0,0 @@ -c35876a529c6be33bdda7b3f48ac8ae800d2f36a ?reflection-java-annotations.jar diff --git a/test/files/run/reflection-java-annotations.scala b/test/files/run/reflection-java-annotations.scala index 4a4fe2572d..0b16c0d103 100644 --- a/test/files/run/reflection-java-annotations.scala +++ b/test/files/run/reflection-java-annotations.scala @@ -1,20 +1,7 @@ -import scala.tools.partest._ -import scala.tools.nsc.Settings - -object Test extends ReplTest { - def code = """ - import scala.reflect.runtime.universe._ - val sym = typeOf[Foo].typeSymbol - sym.typeSignature - sym.getAnnotations foreach (_.javaArgs) - println(sym.getAnnotations) - """ - - override def transformSettings(settings: Settings): Settings = { - val thisFile = testPath.jfile.getAbsolutePath - val javaCompiledAnnotationsJar = (thisFile stripSuffix "scala") + "jar" - val classpath = List(sys.props("partest.lib"), sys.props("partest.reflect"), sys.props("partest.comp"), javaCompiledAnnotationsJar) mkString sys.props("path.separator") - settings.processArguments(List("-cp", classpath), true) - settings - } +object Test extends App { + import scala.reflect.runtime.universe._ + val sym = typeOf[JavaAnnottee].typeSymbol + sym.typeSignature + sym.getAnnotations foreach (_.javaArgs) + println(sym.getAnnotations) }
\ No newline at end of file diff --git a/test/files/run/reflection-java-crtp.check b/test/files/run/reflection-java-crtp.check new file mode 100644 index 0000000000..3e5a77e93a --- /dev/null +++ b/test/files/run/reflection-java-crtp.check @@ -0,0 +1 @@ +(type E,type E,true) diff --git a/test/files/run/reflection-java-crtp.scala b/test/files/run/reflection-java-crtp.scala new file mode 100644 index 0000000000..260d3540dc --- /dev/null +++ b/test/files/run/reflection-java-crtp.scala @@ -0,0 +1,8 @@ +object Test extends App { + import scala.reflect.runtime.universe._ + val enum = typeOf[JavaSimpleEnumeration].baseClasses(1).asClass + // make sure that the E's in Enum<E extends Enum<E>> are represented by the same symbol + val e1 = enum.typeParams(0).asType + val TypeBounds(_, TypeRef(_, _, List(TypeRef(_, e2: TypeSymbol, _)))) = e1.typeSignature + println(e1, e2, e1 eq e2) +}
\ No newline at end of file diff --git a/test/files/run/reflection-magicsymbols-invoke.check b/test/files/run/reflection-magicsymbols-invoke.check index 674716adfe..bef492eb54 100644 --- a/test/files/run/reflection-magicsymbols-invoke.check +++ b/test/files/run/reflection-magicsymbols-invoke.check @@ -121,4 +121,4 @@ testing String.+: 23 CTM
testing Predef.classOf: class scala.ScalaReflectionException: Predef.classOf is a compile-time function, it cannot be invoked with mirrors
testing Predef.classOf: class scala.ScalaReflectionException: scala.Predef.classOf[T]: Class[T] takes 0 arguments
-testing Universe.reify: class scala.ScalaReflectionException: scala.reflect.base.Universe.reify is a macro, i.e. a compile-time function, it cannot be invoked with mirrors
+testing Universe.reify: class scala.ScalaReflectionException: scala.reflect.api.Universe.reify is a macro, i.e. a compile-time function, it cannot be invoked with mirrors
diff --git a/test/files/run/reflection-magicsymbols-invoke.scala b/test/files/run/reflection-magicsymbols-invoke.scala index 61ecc6458d..b38d1be7b2 100644 --- a/test/files/run/reflection-magicsymbols-invoke.scala +++ b/test/files/run/reflection-magicsymbols-invoke.scala @@ -90,5 +90,5 @@ object Test extends App { println("============\nCTM") test(PredefModule.moduleClass.typeSignature, Predef, "classOf") test(PredefModule.moduleClass.typeSignature, Predef, "classOf", typeOf[String]) - test(typeOf[scala.reflect.base.Universe], scala.reflect.runtime.universe, "reify", "2") + test(typeOf[scala.reflect.api.Universe], scala.reflect.runtime.universe, "reify", "2") }
\ No newline at end of file diff --git a/test/files/run/static-annot-repl.check b/test/files/run/static-annot-repl.check deleted file mode 100644 index 3a1532b823..0000000000 --- a/test/files/run/static-annot-repl.check +++ /dev/null @@ -1,38 +0,0 @@ -Type in expressions to have them evaluated. -Type :help for more information. - -scala> - -scala> import annotation.static -import annotation.static - -scala> @static var x1 = 42 -x1: Int = 42 - -scala> @static val x2 = 43 -x2: Int = 43 - -scala> @static def x3 = 44 -<console>:8: error: The @static annotation is not allowed on method definitions. - @static def x3 = 44 - ^ - -scala> x1 -res0: Int = 42 - -scala> x2 -res1: Int = 43 - -scala> x3 -<console>:9: error: not found: value x3 - x3 - ^ - -scala> class Test { - @static def x = 42 -} -<console>:9: error: The @static annotation is not allowed on method definitions. - @static def x = 42 - ^ - -scala>
\ No newline at end of file diff --git a/test/files/run/static-annot-repl.scala b/test/files/run/static-annot-repl.scala deleted file mode 100644 index 1d2e9b2d7e..0000000000 --- a/test/files/run/static-annot-repl.scala +++ /dev/null @@ -1,22 +0,0 @@ - - - -import scala.tools.partest.ReplTest - - - -object Test extends ReplTest { - def code = """ -import annotation.static -@static var x1 = 42 -@static val x2 = 43 -@static def x3 = 44 -x1 -x2 -x3 -class Test { - @static def x = 42 -} -""" - -} diff --git a/test/files/run/static-annot/field.scala b/test/files/run/static-annot/field.scala deleted file mode 100644 index 8408a51800..0000000000 --- a/test/files/run/static-annot/field.scala +++ /dev/null @@ -1,252 +0,0 @@ - - - -import java.lang.reflect.Modifier -import annotation.static -import reflect._ - - - -/* TEST 1 */ - -/* A @static-annotated field in the companion object should yield - * a static field in its companion class. - */ -object Foo { - @static val bar = 17 -} - - -class Foo - - -trait Check { - def checkStatic(cls: Class[_]) { - cls.getDeclaredFields.find(_.getName == "bar") match { - case Some(f) => - assert(Modifier.isStatic(f.getModifiers), "no static modifier") - case None => - assert(false, "no static field bar in class") - } - } - - def test(): Unit -} - - -object Test1 extends Check { - def test() { - checkStatic(classOf[Foo]) - assert(Foo.bar == 17, "Companion object field should be 17.") - } -} - - -/* TEST 2 */ - -class Foo2 - - -/** The order of declaring the class and its companion is inverted now. */ -object Foo2 { - @static val bar = 199 -} - - -object Test2 extends Check { - def test() { - checkStatic(Class.forName("Foo3")) - assert(Foo3.bar == 1984, "Companion object field should be 1984.") - } -} - - -/* TEST 3 */ - -/** The case where there is no explicit companion class */ -object Foo3 { - @static val bar = 1984 -} - - -object Test3 extends Check { - def test() { - checkStatic(Class.forName("Foo3")) - assert(Foo3.bar == 1984, "Companion object field should be 1984.") - } -} - - -/* TEST 4 */ - -/** We want to be able to generate atomic reference field updaters on the companion object - * so that they are created only once per class declaration, but we want them to actually - * be initialize __in the static initializer of the class itself__. - * This is extremely important, because otherwise the creation of the ARFU fails, since it uses - * trickery to detect the caller and compare it to the owner of the field being modified. - * Previously, this used to be circumvented through the use of Java base classes. A pain. - */ -class ArfuTarget { - @volatile var strfield = ArfuTarget.STR - - def CAS(ov: String, nv: String): Boolean = { - ArfuTarget.arfu.compareAndSet(this, ov, nv) - } -} - - -object ArfuTarget { - @static val arfu = java.util.concurrent.atomic.AtomicReferenceFieldUpdater.newUpdater(classOf[ArfuTarget], classOf[String], "strfield") - val STR = "Some string" -} - - -object Test4 extends Check { - def checkArfu() { - val at = new ArfuTarget - assert(at.strfield == ArfuTarget.STR) - at.CAS(ArfuTarget.STR, null) - assert(at.strfield == null) - } - - def test() { - checkArfu() - } -} - - -/* TEST 5 */ - -/** Although our main use-case is to use final static fields, we should be able to use non-final too. - * Here we set the static field of the class by using the setters in the companion object. - * It is legal to do so using the reference to `Foo` directly (in which case the callsites - * are rewritten to access the static field directly), or through an interface `Var` (in - * which case the getter and the setter for `field` access the static field in `Var`). - */ -trait Var { - var field: Int -} - -object VarHolder extends Var { - @static var field = 1 -} - - -object Test5 extends Check { - def test() { - assert(VarHolder.field == 1) - VarHolder.field = 2 - assert(VarHolder.field == 2) - val vh: Var = VarHolder - vh.field = 3 - assert(vh.field == 3) - } -} - - -/* TEST 6 */ - -/** Here we test flattening the static ctor body and changing the owners of local definitions. */ -object Foo6 { - var companionField = 101 - @static val staticField = { - val intermediate = companionField + 1 - intermediate * 2 - } -} - - -object Test6 extends Check { - def test() { - assert(Foo6.staticField == 204) - } -} - - - -/* TEST 7 */ - -/** Here we test objects nested in top-level objects */ -object Foo7 { - object AndHisFriend { - @static val bar = "string" - } - class AndHisFriend - - object AndHisLonelyFriend { - @static val bar = "another" - } -} - - -object Test7 extends Check { - def test() { - checkStatic(classOf[Foo7.AndHisFriend]) - assert(Foo7.AndHisFriend.bar == "string") - - checkStatic(Class.forName("Foo7$AndHisLonelyFriend")) - assert(Foo7.AndHisLonelyFriend.bar == "another") - } -} - - - -/* TEST 8 */ - -object Foo8 { - @static val field = 7 - - val function: () => Int = () => { - field + 1 - } - - val anon = new Runnable { - def run() { - assert(field == 7, "runnable asserting field is 7") - } - } - - @static var mutable = 10 - - val mutation: () => Unit = () => { - mutable += 1 - } -} - -object Test8 { - def test() { - assert(Foo8.function() == 8, "function must return 8") - Foo8.anon.run() - assert(Foo8.mutable == 10, "mutable is 10") - Foo8.mutation() - assert(Foo8.mutable == 11, "mutable is 11") - Foo8.mutation() - assert(Foo8.mutable == 12, "mutable is 12") - } -} - - - - -/* main */ - -object Test { - - def main(args: Array[String]) { - Test1.test() - Test2.test() - Test3.test() - Test4.test() - Test5.test() - Test6.test() - Test7.test() - Test8.test() - } - -} - - - - - - diff --git a/test/files/run/t5418a.check b/test/files/run/t5418a.check new file mode 100644 index 0000000000..ee0e80e11f --- /dev/null +++ b/test/files/run/t5418a.check @@ -0,0 +1 @@ +Expr[Class[_ <: java.lang.Object]](new Object().getClass())
diff --git a/test/files/run/t5418a.scala b/test/files/run/t5418a.scala new file mode 100644 index 0000000000..90bc542be6 --- /dev/null +++ b/test/files/run/t5418a.scala @@ -0,0 +1,3 @@ +object Test extends App { + println(scala.reflect.runtime.universe.reify(new Object().getClass)) +}
\ No newline at end of file diff --git a/test/files/run/t5418b.check b/test/files/run/t5418b.check new file mode 100644 index 0000000000..875ad08435 --- /dev/null +++ b/test/files/run/t5418b.check @@ -0,0 +1,2 @@ +new Object().getClass()
+TypeRef(ThisType(java.lang), java.lang.Class, List(TypeRef(NoPrefix, newTypeName("?0"), List())))
diff --git a/test/files/run/t5418b.scala b/test/files/run/t5418b.scala new file mode 100644 index 0000000000..08e8bb163b --- /dev/null +++ b/test/files/run/t5418b.scala @@ -0,0 +1,11 @@ +import scala.reflect.runtime.universe._ +import scala.reflect.runtime.{currentMirror => cm} +import scala.tools.reflect.ToolBox + +object Test extends App { + val tb = cm.mkToolBox() + val untyped = reify(new Object().getClass).tree + val typed = tb.typeCheck(untyped) + println(typed) + println(showRaw(typed.tpe)) +}
\ No newline at end of file diff --git a/test/files/run/t5770.check b/test/files/run/t5770.check new file mode 100644 index 0000000000..eeb1d55321 --- /dev/null +++ b/test/files/run/t5770.check @@ -0,0 +1,10 @@ +1
+2
+3
+4
+5
+6
+7
+8
+9
+10
diff --git a/test/files/run/t5770.scala b/test/files/run/t5770.scala new file mode 100644 index 0000000000..b6c9236844 --- /dev/null +++ b/test/files/run/t5770.scala @@ -0,0 +1,25 @@ +import scala.reflect.runtime.universe._ +import scala.reflect.runtime.{currentMirror => cm} +import scala.tools.reflect._ + +object Test extends App { + var i = 0 + val action = reify { i += 1; println(i) }.tree + + val tb1 = cm.mkToolBox() + tb1.eval(action) + tb1.eval(action) + tb1.eval(action) + tb1.frontEnd.reset() + tb1.eval(action) + tb1.eval(action) + + val tb2 = cm.mkToolBox() + tb2.eval(action) + tb2.frontEnd.reset() + tb2.eval(action) + tb2.eval(action) + tb2.frontEnd.reset() + tb2.eval(action) + tb2.eval(action) +} diff --git a/test/files/neg/t4581.check b/test/files/run/t5942.check index e69de29bb2..e69de29bb2 100644 --- a/test/files/neg/t4581.check +++ b/test/files/run/t5942.check diff --git a/test/files/run/t5942.scala b/test/files/run/t5942.scala new file mode 100644 index 0000000000..44a8be93f6 --- /dev/null +++ b/test/files/run/t5942.scala @@ -0,0 +1,10 @@ +import scala.reflect.runtime.universe._ +import scala.reflect.runtime.{currentMirror => cm} +import scala.tools.reflect._ + +object Test extends App { + val tb = cm.mkToolBox() + tb.parse("def x = {}") + try { tb.parse("def x = {") } catch { case _ => } + tb.parse("def x = {}") +} diff --git a/test/files/run/t5943a1.check b/test/files/run/t5943a1.check new file mode 100644 index 0000000000..9b3d7a049f --- /dev/null +++ b/test/files/run/t5943a1.check @@ -0,0 +1 @@ +scala.this.Predef.intWrapper(1).to(3).map[Int, scala.collection.immutable.IndexedSeq[Int]](((x$1: Int) => x$1.+(1)))(immutable.this.IndexedSeq.canBuildFrom[Int])
diff --git a/test/files/run/t5943a1.scala b/test/files/run/t5943a1.scala new file mode 100644 index 0000000000..00f4afa808 --- /dev/null +++ b/test/files/run/t5943a1.scala @@ -0,0 +1,9 @@ +import scala.reflect.runtime.universe._ +import scala.reflect.runtime.{currentMirror => cm} +import scala.tools.reflect.ToolBox + +object Test extends App { + val tb = cm.mkToolBox() + val expr = tb.parse("1 to 3 map (_+1)") + println(tb.typeCheck(expr)) +}
\ No newline at end of file diff --git a/test/files/run/t5943a2.check b/test/files/run/t5943a2.check new file mode 100644 index 0000000000..90e88e2997 --- /dev/null +++ b/test/files/run/t5943a2.check @@ -0,0 +1 @@ +Vector(2, 3, 4)
diff --git a/test/files/run/t5943a2.scala b/test/files/run/t5943a2.scala new file mode 100644 index 0000000000..fda800852d --- /dev/null +++ b/test/files/run/t5943a2.scala @@ -0,0 +1,9 @@ +import scala.reflect.runtime.universe._ +import scala.reflect.runtime.{currentMirror => cm} +import scala.tools.reflect.ToolBox + +object Test extends App { + val tb = cm.mkToolBox() + val expr = tb.parse("1 to 3 map (_+1)") + println(tb.eval(expr)) +}
\ No newline at end of file diff --git a/test/files/run/t6236.check b/test/files/run/t6236.check deleted file mode 100644 index a0a2e88d0a..0000000000 --- a/test/files/run/t6236.check +++ /dev/null @@ -1,2 +0,0 @@ -353 -353
\ No newline at end of file diff --git a/test/files/run/t6236/file_1.scala b/test/files/run/t6236/file_1.scala deleted file mode 100644 index 92d22799fc..0000000000 --- a/test/files/run/t6236/file_1.scala +++ /dev/null @@ -1,9 +0,0 @@ - - -package p { - object y { - object x { - @scala.annotation.static val foo: Int = 353 - } - } -} diff --git a/test/files/run/t6236/file_2.scala b/test/files/run/t6236/file_2.scala deleted file mode 100644 index 51823004ca..0000000000 --- a/test/files/run/t6236/file_2.scala +++ /dev/null @@ -1,10 +0,0 @@ - - - -object Test { - def main(args: Array[String]): Unit = { - println(p.y.x.foo) - println(p.y.x.foo) - } -} - diff --git a/test/files/run/t6260.check b/test/files/run/t6260.check new file mode 100644 index 0000000000..54f98a10f0 --- /dev/null +++ b/test/files/run/t6260.check @@ -0,0 +1 @@ +Box(abcabc) diff --git a/test/files/run/t6260.scala b/test/files/run/t6260.scala new file mode 100644 index 0000000000..cfe9e1e640 --- /dev/null +++ b/test/files/run/t6260.scala @@ -0,0 +1,12 @@ +class Box[X <: CharSequence](val x: X) extends AnyVal { + def map[Y <: CharSequence](f: X => Y): Box[Y] = + ((bx: Box[X]) => new Box(f(bx.x)))(this) + override def toString = s"Box($x)" +} + +object Test { + def main(args: Array[String]) { + val g = (x: String) => x + x + println(new Box("abc") map g) + } +} diff --git a/test/files/run/t6287.check b/test/files/run/t6287.check new file mode 100644 index 0000000000..2a783704a2 --- /dev/null +++ b/test/files/run/t6287.check @@ -0,0 +1,3 @@ +Vector(2, 3, 4)
+Vector(2, 3, 4)
+Vector(2, 3, 4)
diff --git a/test/files/run/t6287.scala b/test/files/run/t6287.scala new file mode 100644 index 0000000000..0c75d1081b --- /dev/null +++ b/test/files/run/t6287.scala @@ -0,0 +1,11 @@ +import scala.reflect.runtime.universe._ +import scala.reflect.runtime.{currentMirror => cm} +import scala.tools.reflect._ + +object Test extends App { + val tb = cm.mkToolBox() + val t1 = tb.parse("1 to 3 map (_+1)") + println(tb.eval(t1)) + println(tb.eval(t1)) + println(tb.eval(t1)) +}
\ No newline at end of file diff --git a/test/files/run/t6337a.scala b/test/files/run/t6337a.scala new file mode 100644 index 0000000000..f5490f5cf0 --- /dev/null +++ b/test/files/run/t6337a.scala @@ -0,0 +1,16 @@ +object Test { + def main(args: Array[String]) { + val x = X(XX(3)) + assert(x.q.x.x + 9 == 13) + } +} +trait Q extends Any { + def x: Int + def inc: XX +} +case class X(val x: Q) extends AnyVal { + def q = X(x.inc) +} +case class XX(val x: Int) extends AnyVal with Q { + def inc = XX(x + 1) +} diff --git a/test/files/run/t6392a.check b/test/files/run/t6392a.check new file mode 100644 index 0000000000..ec969b5b93 --- /dev/null +++ b/test/files/run/t6392a.check @@ -0,0 +1 @@ +()
diff --git a/test/files/run/t6392a.scala b/test/files/run/t6392a.scala new file mode 100644 index 0000000000..3a4f9fd0a5 --- /dev/null +++ b/test/files/run/t6392a.scala @@ -0,0 +1,9 @@ +import scala.reflect.runtime.universe._ +import scala.reflect.runtime.{currentMirror => cm} +import scala.tools.reflect.ToolBox + +object Test extends App { + val tb = cm.mkToolBox() + val c = tb.parse("object C") + println(tb.eval(c)) +}
\ No newline at end of file diff --git a/test/files/run/t6392b.check b/test/files/run/t6392b.check new file mode 100644 index 0000000000..ee19836b95 --- /dev/null +++ b/test/files/run/t6392b.check @@ -0,0 +1 @@ +ModuleDef(Modifiers(), newTermName("C"), Template(List(Select(Ident(scala#PK), newTypeName("AnyRef")#TPE)), emptyValDef, List(DefDef(Modifiers(), nme.CONSTRUCTOR, List(), List(List()), TypeTree(), Block(List(Apply(Select(Super(This(newTypeName("C")), tpnme.EMPTY), nme.CONSTRUCTOR#PCTOR), List())), Literal(Constant(())))))))
diff --git a/test/files/run/t6392b.scala b/test/files/run/t6392b.scala new file mode 100644 index 0000000000..f69a5aaf45 --- /dev/null +++ b/test/files/run/t6392b.scala @@ -0,0 +1,9 @@ +import scala.reflect.runtime.universe._ +import scala.reflect.runtime.{currentMirror => cm} +import scala.tools.reflect.ToolBox + +object Test extends App { + val tb = cm.mkToolBox() + val c = tb.parse("object C") + println(showRaw(tb.typeCheck(c), printKinds = true)) +}
\ No newline at end of file diff --git a/test/files/run/t6394b.check b/test/files/run/t6394b.check new file mode 100644 index 0000000000..34997f71e3 --- /dev/null +++ b/test/files/run/t6394b.check @@ -0,0 +1 @@ +TEST
diff --git a/test/files/run/t6394b.flags b/test/files/run/t6394b.flags new file mode 100644 index 0000000000..cd66464f2f --- /dev/null +++ b/test/files/run/t6394b.flags @@ -0,0 +1 @@ +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/t6394b/Macros_1.scala b/test/files/run/t6394b/Macros_1.scala new file mode 100644 index 0000000000..5d93e1cda8 --- /dev/null +++ b/test/files/run/t6394b/Macros_1.scala @@ -0,0 +1,12 @@ +import scala.reflect.macros.Context + +object Macros { + def impl(c:Context): c.Expr[Any] = { + import c.universe._ + + val selfTree = This(tpnme.EMPTY) + c.Expr[AnyRef](selfTree) + } + + def foo: Any = macro impl +}
\ No newline at end of file diff --git a/test/files/run/t6394b/Test_2.scala b/test/files/run/t6394b/Test_2.scala new file mode 100644 index 0000000000..75e84f0e38 --- /dev/null +++ b/test/files/run/t6394b/Test_2.scala @@ -0,0 +1,4 @@ +object Test extends App { + println(Macros.foo) + override def toString = "TEST" +}
\ No newline at end of file diff --git a/test/files/run/toolbox_typecheck_macrosdisabled.check b/test/files/run/toolbox_typecheck_macrosdisabled.check index 4d253f31fc..49e25bd0e7 100644 --- a/test/files/run/toolbox_typecheck_macrosdisabled.check +++ b/test/files/run/toolbox_typecheck_macrosdisabled.check @@ -1,41 +1,41 @@ -{ - val $u: ru.type = ru; - val $m: $u.Mirror = ru.runtimeMirror({ - final class $anon extends scala.AnyRef { - def <init>(): anonymous class $anon = { - $anon.super.<init>(); - () - }; - () - }; - new $anon() -}.getClass().getClassLoader()); - $u.Expr.apply[Int(2)]($m, { - final class $treecreator1 extends TreeCreator { - def <init>(): $treecreator1 = { - $treecreator1.super.<init>(); - () - }; - def apply[U <: scala.reflect.base.Universe with Singleton]($m$untyped: scala.reflect.base.MirrorOf[U]): U#Tree = { - val $u: U = $m$untyped.universe; - val $m: $u.Mirror = $m$untyped.asInstanceOf[$u.Mirror]; - $u.Literal.apply($u.Constant.apply(2)) - } - }; - new $treecreator1() - })($u.TypeTag.apply[Int(2)]($m, { - final class $typecreator2 extends TypeCreator { - def <init>(): $typecreator2 = { - $typecreator2.super.<init>(); - () - }; - def apply[U <: scala.reflect.base.Universe with Singleton]($m$untyped: scala.reflect.base.MirrorOf[U]): U#Type = { - val $u: U = $m$untyped.universe; - val $m: $u.Mirror = $m$untyped.asInstanceOf[$u.Mirror]; - $u.ConstantType.apply($u.Constant.apply(2)) - } - }; - new $typecreator2() - })) -} -ru.reify[Int](2) +{
+ val $u: ru.type = ru;
+ val $m: $u.Mirror = ru.runtimeMirror({
+ final class $anon extends scala.AnyRef {
+ def <init>(): anonymous class $anon = {
+ $anon.super.<init>();
+ ()
+ };
+ ()
+ };
+ new $anon()
+}.getClass().getClassLoader());
+ $u.Expr.apply[Int(2)]($m, {
+ final class $treecreator1 extends TreeCreator {
+ def <init>(): $treecreator1 = {
+ $treecreator1.super.<init>();
+ ()
+ };
+ def apply[U <: scala.reflect.api.Universe with Singleton]($m$untyped: scala.reflect.api.MirrorOf[U]): U#Tree = {
+ val $u: U = $m$untyped.universe;
+ val $m: $u.Mirror = $m$untyped.asInstanceOf[$u.Mirror];
+ $u.Literal.apply($u.Constant.apply(2))
+ }
+ };
+ new $treecreator1()
+ })($u.TypeTag.apply[Int(2)]($m, {
+ final class $typecreator2 extends TypeCreator {
+ def <init>(): $typecreator2 = {
+ $typecreator2.super.<init>();
+ ()
+ };
+ def apply[U <: scala.reflect.api.Universe with Singleton]($m$untyped: scala.reflect.api.MirrorOf[U]): U#Type = {
+ val $u: U = $m$untyped.universe;
+ val $m: $u.Mirror = $m$untyped.asInstanceOf[$u.Mirror];
+ $u.ConstantType.apply($u.Constant.apply(2))
+ }
+ };
+ new $typecreator2()
+ }))
+}
+ru.reify[Int](2)
diff --git a/test/files/run/toolbox_typecheck_macrosdisabled2.check b/test/files/run/toolbox_typecheck_macrosdisabled2.check index 149c3def12..8bbe65e21b 100644 --- a/test/files/run/toolbox_typecheck_macrosdisabled2.check +++ b/test/files/run/toolbox_typecheck_macrosdisabled2.check @@ -1,41 +1,41 @@ -{ - val $u: ru.type = ru; - val $m: $u.Mirror = ru.runtimeMirror({ - final class $anon extends scala.AnyRef { - def <init>(): anonymous class $anon = { - $anon.super.<init>(); - () - }; - () - }; - new $anon() -}.getClass().getClassLoader()); - $u.Expr.apply[Array[Int]]($m, { - final class $treecreator1 extends TreeCreator { - def <init>(): $treecreator1 = { - $treecreator1.super.<init>(); - () - }; - def apply[U <: scala.reflect.base.Universe with Singleton]($m$untyped: scala.reflect.base.MirrorOf[U]): U#Tree = { - val $u: U = $m$untyped.universe; - val $m: $u.Mirror = $m$untyped.asInstanceOf[$u.Mirror]; - $u.Apply.apply($u.Select.apply($u.Select.apply($u.build.Ident($m.staticPackage("scala")), $u.newTermName("Array")), $u.newTermName("apply")), scala.collection.immutable.List.apply[$u.Literal]($u.Literal.apply($u.Constant.apply(2)))) - } - }; - new $treecreator1() - })($u.TypeTag.apply[Array[Int]]($m, { - final class $typecreator2 extends TypeCreator { - def <init>(): $typecreator2 = { - $typecreator2.super.<init>(); - () - }; - def apply[U <: scala.reflect.base.Universe with Singleton]($m$untyped: scala.reflect.base.MirrorOf[U]): U#Type = { - val $u: U = $m$untyped.universe; - val $m: $u.Mirror = $m$untyped.asInstanceOf[$u.Mirror]; - $u.TypeRef.apply($u.ThisType.apply($m.staticPackage("scala").asModule.moduleClass), $m.staticClass("scala.Array"), scala.collection.immutable.List.apply[$u.Type]($m.staticClass("scala.Int").asType.toTypeConstructor)) - } - }; - new $typecreator2() - })) -} -ru.reify[Array[Int]](scala.Array.apply(2)) +{
+ val $u: ru.type = ru;
+ val $m: $u.Mirror = ru.runtimeMirror({
+ final class $anon extends scala.AnyRef {
+ def <init>(): anonymous class $anon = {
+ $anon.super.<init>();
+ ()
+ };
+ ()
+ };
+ new $anon()
+}.getClass().getClassLoader());
+ $u.Expr.apply[Array[Int]]($m, {
+ final class $treecreator1 extends TreeCreator {
+ def <init>(): $treecreator1 = {
+ $treecreator1.super.<init>();
+ ()
+ };
+ def apply[U <: scala.reflect.api.Universe with Singleton]($m$untyped: scala.reflect.api.MirrorOf[U]): U#Tree = {
+ val $u: U = $m$untyped.universe;
+ val $m: $u.Mirror = $m$untyped.asInstanceOf[$u.Mirror];
+ $u.Apply.apply($u.Select.apply($u.Select.apply($u.build.Ident($m.staticPackage("scala")), $u.newTermName("Array")), $u.newTermName("apply")), scala.collection.immutable.List.apply[$u.Literal]($u.Literal.apply($u.Constant.apply(2))))
+ }
+ };
+ new $treecreator1()
+ })($u.TypeTag.apply[Array[Int]]($m, {
+ final class $typecreator2 extends TypeCreator {
+ def <init>(): $typecreator2 = {
+ $typecreator2.super.<init>();
+ ()
+ };
+ def apply[U <: scala.reflect.api.Universe with Singleton]($m$untyped: scala.reflect.api.MirrorOf[U]): U#Type = {
+ val $u: U = $m$untyped.universe;
+ val $m: $u.Mirror = $m$untyped.asInstanceOf[$u.Mirror];
+ $u.TypeRef.apply($u.ThisType.apply($m.staticPackage("scala").asModule.moduleClass), $m.staticClass("scala.Array"), scala.collection.immutable.List.apply[$u.Type]($m.staticClass("scala.Int").asType.toTypeConstructor))
+ }
+ };
+ new $typecreator2()
+ }))
+}
+ru.reify[Array[Int]](scala.Array.apply(2))
diff --git a/test/files/run/typetags_serialize.check b/test/files/run/typetags_serialize.check index 1b898250fb..30952113f6 100644 --- a/test/files/run/typetags_serialize.check +++ b/test/files/run/typetags_serialize.check @@ -1,2 +1,2 @@ -java.io.NotSerializableException: scala.reflect.base.TypeTags$PredefTypeCreator
+java.io.NotSerializableException: scala.reflect.api.TypeTags$PredefTypeCreator
java.io.NotSerializableException: Test$$typecreator1$1
diff --git a/test/files/run/typetags_serialize.scala b/test/files/run/typetags_serialize.scala index 3917b69a93..3c842e6cc9 100644 --- a/test/files/run/typetags_serialize.scala +++ b/test/files/run/typetags_serialize.scala @@ -1,5 +1,6 @@ import java.io._ import scala.reflect.runtime.universe._ +import scala.reflect.runtime.{universe => ru} import scala.reflect.runtime.{currentMirror => cm} object Test extends App { @@ -13,7 +14,7 @@ object Test extends App { val fin = new ByteArrayInputStream(fout.toByteArray) val in = new ObjectInputStream(fin) - val retag = in.readObject().asInstanceOf[scala.reflect.basis.TypeTag[_]].in(cm) + val retag = in.readObject().asInstanceOf[ru.TypeTag[_]].in(cm) in.close() fin.close() diff --git a/test/files/run/typetags_without_scala_reflect_manifest_lookup.check b/test/files/run/typetags_without_scala_reflect_manifest_lookup.check new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/files/run/typetags_without_scala_reflect_manifest_lookup.check diff --git a/test/files/run/typetags_without_scala_reflect_manifest_lookup.scala b/test/files/run/typetags_without_scala_reflect_manifest_lookup.scala new file mode 100644 index 0000000000..37047e7884 --- /dev/null +++ b/test/files/run/typetags_without_scala_reflect_manifest_lookup.scala @@ -0,0 +1,29 @@ +import scala.tools.partest._ +import scala.tools.nsc.Settings + +object Test extends DirectTest { + override def extraSettings = "-cp " + sys.props("partest.lib") + + def code = """ + object Test extends App { + // manifest lookup also involves type tag lookup + // because we support manifest <-> typetag convertability + // + // however when scala-reflect.jar (the home of type tags) is not on the classpath + // we need to omit the type tag lookup, because we lack the necessary symbols + // to do implicit search and tag materialization + // (such missing symbols are e.g. ApiUniverseClass and TypeTagsClass) + // + // the test case you're looking at checks exactly this + // we establish a classpath that only includes scala-library.jar + // and then force scalac to perform implicit search for a manifest + // if type tag lookup is not disabled, the compiler will crash + // if it is disabled, then the compilation will succeed + // http://groups.google.com/group/scala-internals/browse_thread/thread/166ce4b71b7c46bb + def foo[T: Manifest] = () + foo[List[Int]] + } + """ + + def show = compile() +}
\ No newline at end of file diff --git a/test/files/run/typetags_without_scala_reflect_typetag_lookup.check b/test/files/run/typetags_without_scala_reflect_typetag_lookup.check new file mode 100644 index 0000000000..f6b82c33f6 --- /dev/null +++ b/test/files/run/typetags_without_scala_reflect_typetag_lookup.check @@ -0,0 +1,3 @@ +newSource1:9: error: could not find implicit value for evidence parameter of type reflect.runtime.package.universe.TypeTag[Int]
+ Library.foo[Int]
+ ^
diff --git a/test/files/run/typetags_without_scala_reflect_typetag_lookup.scala b/test/files/run/typetags_without_scala_reflect_typetag_lookup.scala new file mode 100644 index 0000000000..e51ecdb180 --- /dev/null +++ b/test/files/run/typetags_without_scala_reflect_typetag_lookup.scala @@ -0,0 +1,45 @@ +import scala.tools.partest._ + +object Test extends DirectTest { + def code = ??? + + def library = """ + import scala.reflect.runtime.universe._ + + object Library { + def foo[T: TypeTag] = () + } + """ + def compileLibrary() = { + val classpath = List(sys.props("partest.lib"), sys.props("partest.reflect")) mkString sys.props("path.separator") + compileString(newCompiler("-cp", classpath, "-d", testOutput.path))(library) + } + + def app = """ + object Test extends App { + // tries to materialize a type tag not having scala-reflect.jar on the classpath + // even though it's easy to materialize a type tag of Int, this line will fail + // because materialization involves classes from scala-reflect.jar + // + // in this test we make sure that the compiler doesn't crash + // but just displays several missing class file errors and an unavailable implicit message + Library.foo[Int] + } + """ + def compileApp() = { + val classpath = List(sys.props("partest.lib"), testOutput.path) mkString sys.props("path.separator") + compileString(newCompiler("-cp", classpath, "-d", testOutput.path))(app) + } + + def show(): Unit = { + val prevErr = System.err + val baos = new java.io.ByteArrayOutputStream(); + System.setErr(new java.io.PrintStream(baos)); + compileLibrary(); + compileApp(); + // we should get bad symbolic reference errors, because we're trying to call a method that can't be unpickled + // but we don't know the number of these errors and their order, so I just ignore them all + baos.toString.split("\n") filter (!_.startsWith("error: bad symbolic reference")) foreach println + System.setErr(prevErr) + } +}
\ No newline at end of file diff --git a/test/files/run/typetags_without_scala_reflect_typetag_manifest_interop.check b/test/files/run/typetags_without_scala_reflect_typetag_manifest_interop.check new file mode 100644 index 0000000000..34f1d84299 --- /dev/null +++ b/test/files/run/typetags_without_scala_reflect_typetag_manifest_interop.check @@ -0,0 +1,3 @@ +newSource1:9: error: No Manifest available for App.this.T.
+ manifest[T]
+ ^
diff --git a/test/files/run/typetags_without_scala_reflect_typetag_manifest_interop.scala b/test/files/run/typetags_without_scala_reflect_typetag_manifest_interop.scala new file mode 100644 index 0000000000..e984127583 --- /dev/null +++ b/test/files/run/typetags_without_scala_reflect_typetag_manifest_interop.scala @@ -0,0 +1,46 @@ +import scala.tools.partest._ + +object Test extends DirectTest { + def code = ??? + + def library = """ + import scala.reflect.runtime.universe._ + + trait Library { + type T + implicit val tt: TypeTag[T] + } + """ + def compileLibrary() = { + val classpath = List(sys.props("partest.lib"), sys.props("partest.reflect")) mkString sys.props("path.separator") + compileString(newCompiler("-cp", classpath, "-d", testOutput.path))(library) + } + + def app = """ + trait App extends Library { + // tries to create a manifest from a type tag without having scala-reflect.jar on the classpath + // even though it's possible to convert a type tag into a manifest, this will fail + // because conversion requires classes from scala-reflect.jar + // + // in this test we make sure that the compiler doesn't crash + // but just displays several missing class file errors and an unavailable implicit message + manifest[T] + } + """ + def compileApp() = { + val classpath = List(sys.props("partest.lib"), testOutput.path) mkString sys.props("path.separator") + compileString(newCompiler("-cp", classpath, "-d", testOutput.path))(app) + } + + def show(): Unit = { + val prevErr = System.err + val baos = new java.io.ByteArrayOutputStream(); + System.setErr(new java.io.PrintStream(baos)); + compileLibrary(); + compileApp(); + // we should get bad symbolic reference errors, because we're trying to use an implicit that can't be unpickled + // but we don't know the number of these errors and their order, so I just ignore them all + baos.toString.split("\n") filter (!_.startsWith("error: bad symbolic reference")) foreach println + System.setErr(prevErr) + } +}
\ No newline at end of file diff --git a/test/files/run/valueclasses-pavlov.check b/test/files/run/valueclasses-pavlov.check new file mode 100644 index 0000000000..b112e5507e --- /dev/null +++ b/test/files/run/valueclasses-pavlov.check @@ -0,0 +1,2 @@ +box1: ok +box2: ok diff --git a/test/files/run/valueclasses-pavlov.scala b/test/files/run/valueclasses-pavlov.scala new file mode 100644 index 0000000000..e73897f653 --- /dev/null +++ b/test/files/run/valueclasses-pavlov.scala @@ -0,0 +1,26 @@ +trait Foo extends Any { + def box1(x: Box1): String + def box2(x: Box2): String +} + +class Box1(val value: String) extends AnyVal + +class Box2(val value: String) extends AnyVal with Foo { + def box1(x: Box1) = "box1: ok" + def box2(x: Box2) = "box2: ok" +} + +class C(x: String) { + def this() = this("") +} + +object Test { + + def main(args: Array[String]) { + val b1 = new Box1("") + val b2 = new Box2("") + val f: Foo = b2 + println(f.box1(b1)) + println(f.box2(b2)) + } +} diff --git a/test/files/scalacheck/redblacktree.scala b/test/files/scalacheck/redblacktree.scala index e2609fa200..bc7f92aa1b 100644 --- a/test/files/scalacheck/redblacktree.scala +++ b/test/files/scalacheck/redblacktree.scala @@ -205,6 +205,45 @@ package scala.collection.immutable.redblacktree { filteredTree == keysIterator(newTree).toList } } + + object TestDrop extends RedBlackTreeTest with RedBlackTreeInvariants { + import RB._ + + override type ModifyParm = Int + override def genParm(tree: Tree[String, Int]): Gen[ModifyParm] = choose(0, iterator(tree).size) + override def modify(tree: Tree[String, Int], parm: ModifyParm): Tree[String, Int] = drop(tree, parm) + + property("drop") = forAll(genInput) { case (tree, parm, newTree) => + iterator(tree).drop(parm).toList == iterator(newTree).toList + } + } + + object TestTake extends RedBlackTreeTest with RedBlackTreeInvariants { + import RB._ + + override type ModifyParm = Int + override def genParm(tree: Tree[String, Int]): Gen[ModifyParm] = choose(0, iterator(tree).size) + override def modify(tree: Tree[String, Int], parm: ModifyParm): Tree[String, Int] = take(tree, parm) + + property("take") = forAll(genInput) { case (tree, parm, newTree) => + iterator(tree).take(parm).toList == iterator(newTree).toList + } + } + + object TestSlice extends RedBlackTreeTest with RedBlackTreeInvariants { + import RB._ + + override type ModifyParm = (Int, Int) + override def genParm(tree: Tree[String, Int]): Gen[ModifyParm] = for { + from <- choose(0, iterator(tree).size) + to <- choose(from, iterator(tree).size) + } yield (from, to) + override def modify(tree: Tree[String, Int], parm: ModifyParm): Tree[String, Int] = slice(tree, parm._1, parm._2) + + property("slice") = forAll(genInput) { case (tree, parm, newTree) => + iterator(tree).slice(parm._1, parm._2).toList == iterator(newTree).toList + } + } } object Test extends Properties("RedBlackTree") { @@ -213,4 +252,7 @@ object Test extends Properties("RedBlackTree") { include(TestModify) include(TestDelete) include(TestRange) + include(TestDrop) + include(TestTake) + include(TestSlice) } |