diff options
Diffstat (limited to 'test/files/run')
338 files changed, 3624 insertions, 840 deletions
diff --git a/test/files/run/analyzerPlugins.check b/test/files/run/analyzerPlugins.check index 7d8d181306..0788086459 100644 --- a/test/files/run/analyzerPlugins.check +++ b/test/files/run/analyzerPlugins.check @@ -22,12 +22,12 @@ pluginsPt(?, Trees$Annotated) [7] pluginsPt(?, Trees$Apply) [8] pluginsPt(?, Trees$ApplyImplicitView) [2] pluginsPt(?, Trees$Assign) [7] -pluginsPt(?, Trees$Block) [7] +pluginsPt(?, Trees$Block) [4] pluginsPt(?, Trees$ClassDef) [2] pluginsPt(?, Trees$DefDef) [14] -pluginsPt(?, Trees$Ident) [49] +pluginsPt(?, Trees$Ident) [51] pluginsPt(?, Trees$If) [2] -pluginsPt(?, Trees$Literal) [20] +pluginsPt(?, Trees$Literal) [16] pluginsPt(?, Trees$New) [5] pluginsPt(?, Trees$PackageDef) [1] pluginsPt(?, Trees$Return) [1] @@ -37,9 +37,9 @@ pluginsPt(?, Trees$This) [20] pluginsPt(?, Trees$TypeApply) [3] pluginsPt(?, Trees$TypeBoundsTree) [2] pluginsPt(?, Trees$TypeDef) [1] -pluginsPt(?, Trees$TypeTree) [37] +pluginsPt(?, Trees$TypeTree) [38] pluginsPt(?, Trees$Typed) [1] -pluginsPt(?, Trees$ValDef) [23] +pluginsPt(?, Trees$ValDef) [21] pluginsPt(Any, Trees$Literal) [2] pluginsPt(Any, Trees$Typed) [1] pluginsPt(Array[Any], Trees$ArrayValue) [1] @@ -53,7 +53,7 @@ pluginsPt(Int @testAnn, Trees$Literal) [1] pluginsPt(Int, Trees$Apply) [1] pluginsPt(Int, Trees$Ident) [2] pluginsPt(Int, Trees$If) [1] -pluginsPt(Int, Trees$Literal) [6] +pluginsPt(Int, Trees$Literal) [5] pluginsPt(Int, Trees$Select) [3] pluginsPt(List, Trees$Apply) [1] pluginsPt(List[Any], Trees$Select) [1] @@ -65,7 +65,7 @@ pluginsPt(String, Trees$Literal) [1] pluginsPt(String, Trees$Select) [1] pluginsPt(String, Trees$Typed) [1] pluginsPt(Unit, Trees$Assign) [1] -pluginsPt(scala.annotation.Annotation, Trees$Apply) [5] +pluginsPt(testAnn, Trees$Apply) [5] pluginsTypeSig(<none>, Trees$Template) [2] pluginsTypeSig(class A, Trees$ClassDef) [1] pluginsTypeSig(class testAnn, Trees$ClassDef) [1] @@ -82,8 +82,8 @@ pluginsTypeSig(value lub1, Trees$ValDef) [2] pluginsTypeSig(value lub2, Trees$ValDef) [2] pluginsTypeSig(value param, Trees$ValDef) [2] pluginsTypeSig(value str, Trees$ValDef) [1] -pluginsTypeSig(value x, Trees$ValDef) [5] -pluginsTypeSig(value y, Trees$ValDef) [5] +pluginsTypeSig(value x, Trees$ValDef) [4] +pluginsTypeSig(value y, Trees$ValDef) [4] pluginsTypeSig(variable count, Trees$ValDef) [3] pluginsTypeSigAccessor(value annotField) [1] pluginsTypeSigAccessor(value inferField) [1] @@ -110,7 +110,7 @@ pluginsTyped(<notype>, Trees$ClassDef) [2] pluginsTyped(<notype>, Trees$DefDef) [14] pluginsTyped(<notype>, Trees$PackageDef) [1] pluginsTyped(<notype>, Trees$TypeDef) [1] -pluginsTyped(<notype>, Trees$ValDef) [23] +pluginsTyped(<notype>, Trees$ValDef) [21] pluginsTyped(<root>, Trees$Ident) [1] pluginsTyped(=> Boolean @testAnn, Trees$Select) [1] pluginsTyped(=> Double, Trees$Select) [4] @@ -124,7 +124,7 @@ pluginsTyped(A, Trees$TypeTree) [4] pluginsTyped(A.super.type, Trees$Super) [1] pluginsTyped(A.this.type, Trees$This) [11] pluginsTyped(Any, Trees$TypeTree) [1] -pluginsTyped(AnyRef, Trees$Select) [2] +pluginsTyped(AnyRef, Trees$Select) [4] pluginsTyped(Array[Any], Trees$ArrayValue) [1] pluginsTyped(Boolean @testAnn, Trees$Select) [1] pluginsTyped(Boolean @testAnn, Trees$TypeTree) [4] @@ -137,12 +137,12 @@ pluginsTyped(Int @testAnn, Trees$TypeTree) [2] pluginsTyped(Int @testAnn, Trees$Typed) [2] pluginsTyped(Int(0), Trees$Literal) [3] pluginsTyped(Int(1) @testAnn, Trees$Typed) [1] -pluginsTyped(Int(1), Trees$Literal) [9] +pluginsTyped(Int(1), Trees$Literal) [8] pluginsTyped(Int(2), Trees$Literal) [1] pluginsTyped(Int, Trees$Apply) [1] pluginsTyped(Int, Trees$Ident) [2] pluginsTyped(Int, Trees$If) [2] -pluginsTyped(Int, Trees$Select) [17] +pluginsTyped(Int, Trees$Select) [15] pluginsTyped(Int, Trees$TypeTree) [13] pluginsTyped(List, Trees$Apply) [1] pluginsTyped(List, Trees$Select) [1] @@ -160,26 +160,27 @@ pluginsTyped(String("huhu"), Trees$Literal) [1] pluginsTyped(String("str") @testAnn, Trees$Typed) [1] pluginsTyped(String("str"), Trees$Literal) [1] pluginsTyped(String("str"), Trees$Typed) [1] -pluginsTyped(String("two"), Trees$Literal) [3] +pluginsTyped(String("two"), Trees$Literal) [2] pluginsTyped(String, Trees$Apply) [2] pluginsTyped(String, Trees$Block) [2] pluginsTyped(String, Trees$Ident) [1] pluginsTyped(String, Trees$Select) [9] -pluginsTyped(String, Trees$TypeTree) [8] +pluginsTyped(String, Trees$TypeTree) [7] pluginsTyped(Unit, Trees$Apply) [2] pluginsTyped(Unit, Trees$Assign) [8] -pluginsTyped(Unit, Trees$Block) [7] +pluginsTyped(Unit, Trees$Block) [4] pluginsTyped(Unit, Trees$If) [1] -pluginsTyped(Unit, Trees$Literal) [8] +pluginsTyped(Unit, Trees$Literal) [5] pluginsTyped(Unit, Trees$TypeTree) [1] pluginsTyped([A](xs: A*)List[A], Trees$Select) [1] pluginsTyped([T <: Int]=> Int, Trees$Select) [1] -pluginsTyped([T0 >: ? <: ?]()T0, Trees$Select) [1] +pluginsTyped([T0]()T0, Trees$Select) [1] pluginsTyped([T](xs: Array[T])scala.collection.mutable.WrappedArray[T], Trees$Select) [1] -pluginsTyped(annotation.type, Trees$Select) [2] +pluginsTyped(annotation.type, Trees$Select) [4] pluginsTyped(math.type, Trees$Select) [9] pluginsTyped(scala.annotation.Annotation, Trees$Apply) [1] pluginsTyped(scala.annotation.TypeConstraint, Trees$Select) [4] +pluginsTyped(scala.annotation.TypeConstraint, Trees$TypeTree) [2] pluginsTyped(scala.collection.immutable.List.type, Trees$Select) [2] pluginsTyped(scala.collection.immutable.StringOps, Trees$ApplyImplicitView) [2] pluginsTyped(scala.collection.mutable.WrappedArray[Any], Trees$Apply) [1] diff --git a/test/files/run/analyzerPlugins.scala b/test/files/run/analyzerPlugins.scala index daef83fa30..b20a734fe6 100644 --- a/test/files/run/analyzerPlugins.scala +++ b/test/files/run/analyzerPlugins.scala @@ -77,12 +77,12 @@ object Test extends DirectTest { object analyzerPlugin extends AnalyzerPlugin { def treeClass(t: Tree) = t.getClass.toString.split('.').last - override def pluginsPt(pt: Type, typer: Typer, tree: Tree, mode: Int): Type = { + override def pluginsPt(pt: Type, typer: Typer, tree: Tree, mode: Mode): Type = { output += s"pluginsPt($pt, ${treeClass(tree)})" pt } - override def pluginsTyped(tpe: Type, typer: Typer, tree: Tree, mode: Int, pt: Type): Type = { + override def pluginsTyped(tpe: Type, typer: Typer, tree: Tree, mode: Mode, pt: Type): Type = { output += s"pluginsTyped($tpe, ${treeClass(tree)})" tpe } @@ -98,7 +98,7 @@ object Test extends DirectTest { } - override def canAdaptAnnotations(tree: Tree, typer: Typer, mode: Int, pt: Type): Boolean = { + override def canAdaptAnnotations(tree: Tree, typer: Typer, mode: Mode, pt: Type): Boolean = { output += s"canAdaptAnnotations(${treeClass(tree)}, $pt)" false } diff --git a/test/files/run/array-addition.check b/test/files/run/array-addition.check new file mode 100644 index 0000000000..7bfbd9c711 --- /dev/null +++ b/test/files/run/array-addition.check @@ -0,0 +1,4 @@ +Array(1, 2, 3, 4) +Array(1, 2, 3, 4) +Array(1) +Array(1) diff --git a/test/files/run/array-addition.scala b/test/files/run/array-addition.scala new file mode 100644 index 0000000000..8def48e85c --- /dev/null +++ b/test/files/run/array-addition.scala @@ -0,0 +1,11 @@ +object Test { + def prettyPrintArray(x: Array[_]) = println("Array(" + x.mkString(", ") + ")") + + def main(args: Array[String]): Unit = { + prettyPrintArray(Array(1,2,3) :+ 4) + prettyPrintArray(1 +: Array(2,3,4)) + prettyPrintArray(Array() :+ 1) + prettyPrintArray(1 +: Array()) + } +} + diff --git a/test/files/run/bitsets.scala b/test/files/run/bitsets.scala index 27395683b4..bdeb1fd811 100644 --- a/test/files/run/bitsets.scala +++ b/test/files/run/bitsets.scala @@ -85,8 +85,8 @@ object TestImmutable { import scala.collection.immutable.BitSet val is0 = BitSet() - val is1 = BitSet.fromArray(Array()) - val is2 = BitSet.fromArray(Array(4)) + val is1 = BitSet.fromBitMask(Array()) + val is2 = BitSet.fromBitMask(Array(4)) val is3 = BitSet.empty Console.println("is0 = " + is0) diff --git a/test/files/run/caseclasses.scala b/test/files/run/caseclasses.scala index 5aafea59e3..668c984f3d 100644 --- a/test/files/run/caseclasses.scala +++ b/test/files/run/caseclasses.scala @@ -1,6 +1,6 @@ case class Foo(x: Int)(y: Int) -case class Bar +case class Bar() abstract class Base abstract case class Abs(x: Int) extends Base diff --git a/test/files/run/class-symbol-contravariant.check b/test/files/run/class-symbol-contravariant.check new file mode 100644 index 0000000000..987f215bca --- /dev/null +++ b/test/files/run/class-symbol-contravariant.check @@ -0,0 +1,36 @@ +Type in expressions to have them evaluated. +Type :help for more information. + +scala> :power +** Power User mode enabled - BEEP WHIR GYVE ** +** :phase has been set to 'typer'. ** +** scala.tools.nsc._ has been imported ** +** global._, definitions._ also imported ** +** Try :help, :vals, power.<tab> ** + +scala> val u = rootMirror.universe +u: $r.intp.global.type = <global> + +scala> import u._, scala.reflect.internal.Flags +import u._ +import scala.reflect.internal.Flags + +scala> class C +defined class C + +scala> val sym = u.typeOf[C].typeSymbol +sym: u.Symbol = class C + +scala> sym.isContravariant +res0: Boolean = false + +scala> sym setFlag Flags.INCONSTRUCTOR +res1: sym.type = class C + +scala> sym.isClassLocalToConstructor +res2: Boolean = true + +scala> sym.isContravariant // was true +res3: Boolean = false + +scala> diff --git a/test/files/run/class-symbol-contravariant.scala b/test/files/run/class-symbol-contravariant.scala new file mode 100644 index 0000000000..6a84944e3b --- /dev/null +++ b/test/files/run/class-symbol-contravariant.scala @@ -0,0 +1,15 @@ +import scala.tools.partest.ReplTest + +object Test extends ReplTest { + override def code = """ + |:power + |val u = rootMirror.universe + |import u._, scala.reflect.internal.Flags + |class C + |val sym = u.typeOf[C].typeSymbol + |sym.isContravariant + |sym setFlag Flags.INCONSTRUCTOR + |sym.isClassLocalToConstructor + |sym.isContravariant // was true + |""".stripMargin.trim +}
\ No newline at end of file diff --git a/test/files/run/collection-stacks.check b/test/files/run/collection-stacks.check new file mode 100644 index 0000000000..aa25cd1fa6 --- /dev/null +++ b/test/files/run/collection-stacks.check @@ -0,0 +1,14 @@ +3-2-1: true +3-2-1: true +apply +3: true +3: true +1: true +1: true +top +3: true +3: true +pop +2-1: true +3: true +2-1: true diff --git a/test/files/run/collection-stacks.scala b/test/files/run/collection-stacks.scala new file mode 100644 index 0000000000..be9fbbf1ae --- /dev/null +++ b/test/files/run/collection-stacks.scala @@ -0,0 +1,38 @@ +import scala.collection.{ immutable, mutable } + +object Test extends App { + def mutableStack[T](xs: T*): mutable.Stack[T] = { + val s = new mutable.Stack[T] + s.pushAll(xs) + s + } + + def immutableStack[T](xs: T*): immutable.Stack[T] = { + immutable.Stack.empty[T] pushAll xs + } + + def check[T](expected: T, got: T) { + println(got + ": " + (expected == got)) + } + + // check #957 + check("3-2-1", immutableStack(1, 2, 3).iterator.mkString("-")) + check("3-2-1", mutableStack(1, 2, 3).iterator.mkString("-")) + + println("apply") + check(3, immutableStack(1, 2, 3).apply(0)) + check(3, mutableStack(1, 2, 3).apply(0)) + check(1, immutableStack(1, 2, 3).apply(2)) + check(1, mutableStack(1, 2, 3).apply(2)) + + println("top") + check(3, immutableStack(1, 2, 3).top) + check(3, mutableStack(1, 2, 3).top) + + println("pop") + check("2-1", immutableStack(1, 2, 3).pop.mkString("-")) + check(3, mutableStack(1, 2, 3).pop()) + check("2-1", { val s = mutableStack(1, 2, 3); s.pop(); s.toList.mkString("-") }) +} + +// vim: set ts=2 sw=2 et: diff --git a/test/files/run/compiler-asSeenFrom.scala b/test/files/run/compiler-asSeenFrom.scala index 19feb45101..0d4b504d3c 100644 --- a/test/files/run/compiler-asSeenFrom.scala +++ b/test/files/run/compiler-asSeenFrom.scala @@ -47,10 +47,10 @@ package ll { for (p <- typeRefPrefixes ; c <- classes filter (isPossibleEnclosure(p.typeSymbol, _)) ; a <- targs) yield typeRef(p, c, List(a)) ) - + val wfmt = "%-" + 25 + "s" def to_s(x: Any): String = wfmt.format(x.toString.replaceAll("""\bll\.""", "")) - + def fmt(args: Any*): String = { (args map to_s mkString " ").replaceAll("""\s+$""", "") } @@ -61,7 +61,7 @@ package ll { } def permuteAsSeenFrom(targs: List[Type]) = ( - for { + for { tp <- typeRefs(targs filterNot (_ eq NoType)) prefix <- asSeenPrefixes if tp.prefix != prefix @@ -72,11 +72,11 @@ package ll { } yield ((site, tp, prefix, seen)) ) - + def block(label: Any)(lines: List[String]): List[String] = { val first = "" + label + " {" val last = "}" - + first +: lines.map(" " + _) :+ last } @@ -84,7 +84,7 @@ package ll { permuteAsSeenFrom(targs).groupBy(_._1).toList.sortBy(_._1.toString) flatMap { case (site, xs) => block(fmt(site)) { - fmt("type", "seen from prefix", "is") :: + fmt("type", "seen from prefix", "is") :: fmt("----", "----------------", "--") :: { xs.groupBy(_._2).toList.sortBy(_._1.toString) flatMap { case (tp, ys) => @@ -95,7 +95,7 @@ package ll { } } } - + def pretty(xs: List[_]) = if (xs.isEmpty) "" else xs.mkString("\n ", "\n ", "\n") def signaturesIn(info: Type): List[String] = ( @@ -103,11 +103,11 @@ package ll { filterNot (s => s.isType || s.owner == ObjectClass || s.owner == AnyClass || s.isConstructor) map (_.defString) ) - + def check(source: String, unit: global.CompilationUnit) = { import syms._ - afterTyper { + exitingTyper { val typeArgs = List[Type](IntClass.tpe, ListClass[Int]) ++ tparams.map(_.tpe) permute(typeArgs) foreach println } diff --git a/test/files/run/constant-type.check b/test/files/run/constant-type.check index dfd8be5297..4eededb8ba 100644 --- a/test/files/run/constant-type.check +++ b/test/files/run/constant-type.check @@ -13,16 +13,16 @@ scala> :power scala> val s = transformedType(StringClass.toType).asInstanceOf[Type] s: $r.intp.global.Type = String -scala> { println(afterPhase(currentRun.erasurePhase)(ConstantType(Constant(s)))) } +scala> { println(exitingPhase(currentRun.erasurePhase)(ConstantType(Constant(s)))) } Class[String](classOf[java.lang.String]) -scala> { afterPhase(currentRun.erasurePhase)(println(ConstantType(Constant(s)))) } +scala> { exitingPhase(currentRun.erasurePhase)(println(ConstantType(Constant(s)))) } Class(classOf[java.lang.String]) -scala> { ConstantType(Constant(s)); println(afterPhase(currentRun.erasurePhase)(ConstantType(Constant(s)))); } +scala> { ConstantType(Constant(s)); println(exitingPhase(currentRun.erasurePhase)(ConstantType(Constant(s)))); } Class[String](classOf[java.lang.String]) -scala> { ConstantType(Constant(s)); afterPhase(currentRun.erasurePhase)(println(ConstantType(Constant(s)))); } +scala> { ConstantType(Constant(s)); exitingPhase(currentRun.erasurePhase)(println(ConstantType(Constant(s)))); } Class(classOf[java.lang.String]) scala> diff --git a/test/files/run/constant-type.scala b/test/files/run/constant-type.scala index 84539e2895..373746af4a 100644 --- a/test/files/run/constant-type.scala +++ b/test/files/run/constant-type.scala @@ -9,9 +9,9 @@ object Test extends ReplTest { def code = """ :power val s = transformedType(StringClass.toType).asInstanceOf[Type] -{ println(afterPhase(currentRun.erasurePhase)(ConstantType(Constant(s)))) } -{ afterPhase(currentRun.erasurePhase)(println(ConstantType(Constant(s)))) } -{ ConstantType(Constant(s)); println(afterPhase(currentRun.erasurePhase)(ConstantType(Constant(s)))); } -{ ConstantType(Constant(s)); afterPhase(currentRun.erasurePhase)(println(ConstantType(Constant(s)))); } +{ println(exitingPhase(currentRun.erasurePhase)(ConstantType(Constant(s)))) } +{ exitingPhase(currentRun.erasurePhase)(println(ConstantType(Constant(s)))) } +{ ConstantType(Constant(s)); println(exitingPhase(currentRun.erasurePhase)(ConstantType(Constant(s)))); } +{ ConstantType(Constant(s)); exitingPhase(currentRun.erasurePhase)(println(ConstantType(Constant(s)))); } """ } diff --git a/test/files/run/constrained-types.check b/test/files/run/constrained-types.check index da97a378e6..d4b8692fa3 100644 --- a/test/files/run/constrained-types.check +++ b/test/files/run/constrained-types.check @@ -37,7 +37,7 @@ scala> object Stuff { val x = "hello" val y : Int @Annot(x) = 10 } -defined module Stuff +defined object Stuff scala> @@ -127,7 +127,7 @@ defined class rep scala> scala> object A { val x = "hello" : String @ rep } -defined module A +defined object A warning: previously defined class A is not a companion to object A. Companions must be defined together; you may wish to use :paste mode for this. diff --git a/test/files/run/ctries-new/iterator.scala b/test/files/run/ctries-new/iterator.scala index b953a40e00..bb1175e61b 100644 --- a/test/files/run/ctries-new/iterator.scala +++ b/test/files/run/ctries-new/iterator.scala @@ -1,144 +1,134 @@ - - - - import collection._ import collection.concurrent.TrieMap - - object IteratorSpec extends Spec { - + def test() { "work for an empty trie" in { val ct = new TrieMap val it = ct.iterator - + it.hasNext shouldEqual (false) evaluating { it.next() }.shouldProduce [NoSuchElementException] } - + def nonEmptyIteratorCheck(sz: Int) { val ct = new TrieMap[Wrap, Int] for (i <- 0 until sz) ct.put(new Wrap(i), i) - + val it = ct.iterator val tracker = mutable.Map[Wrap, Int]() for (i <- 0 until sz) { assert(it.hasNext == true) tracker += it.next } - + it.hasNext shouldEqual (false) evaluating { it.next() }.shouldProduce [NoSuchElementException] tracker.size shouldEqual (sz) tracker shouldEqual (ct) } - + "work for a 1 element trie" in { nonEmptyIteratorCheck(1) } - + "work for a 2 element trie" in { nonEmptyIteratorCheck(2) } - + "work for a 3 element trie" in { nonEmptyIteratorCheck(3) } - + "work for a 5 element trie" in { nonEmptyIteratorCheck(5) } - + "work for a 10 element trie" in { nonEmptyIteratorCheck(10) } - + "work for a 20 element trie" in { nonEmptyIteratorCheck(20) } - + "work for a 50 element trie" in { nonEmptyIteratorCheck(50) } - + "work for a 100 element trie" in { nonEmptyIteratorCheck(100) } - + "work for a 1k element trie" in { nonEmptyIteratorCheck(1000) } - + "work for a 5k element trie" in { nonEmptyIteratorCheck(5000) } - + "work for a 75k element trie" in { nonEmptyIteratorCheck(75000) } - + "work for a 250k element trie" in { nonEmptyIteratorCheck(500000) } - + def nonEmptyCollideCheck(sz: Int) { val ct = new TrieMap[DumbHash, Int] for (i <- 0 until sz) ct.put(new DumbHash(i), i) - + val it = ct.iterator val tracker = mutable.Map[DumbHash, Int]() for (i <- 0 until sz) { assert(it.hasNext == true) tracker += it.next } - + it.hasNext shouldEqual (false) evaluating { it.next() }.shouldProduce [NoSuchElementException] tracker.size shouldEqual (sz) tracker shouldEqual (ct) } - + "work for colliding hashcodes, 2 element trie" in { nonEmptyCollideCheck(2) } - + "work for colliding hashcodes, 3 element trie" in { nonEmptyCollideCheck(3) } - + "work for colliding hashcodes, 5 element trie" in { nonEmptyCollideCheck(5) } - + "work for colliding hashcodes, 10 element trie" in { nonEmptyCollideCheck(10) } - + "work for colliding hashcodes, 100 element trie" in { nonEmptyCollideCheck(100) } - + "work for colliding hashcodes, 500 element trie" in { nonEmptyCollideCheck(500) } - + "work for colliding hashcodes, 5k element trie" in { nonEmptyCollideCheck(5000) } - + def assertEqual(a: Map[Wrap, Int], b: Map[Wrap, Int]) { if (a != b) { println(a.size + " vs " + b.size) - // println(a) - // println(b) - // println(a.toSeq.sortBy((x: (Wrap, Int)) => x._1.i)) - // println(b.toSeq.sortBy((x: (Wrap, Int)) => x._1.i)) } assert(a == b) } - + "be consistent when taken with concurrent modifications" in { val sz = 25000 val W = 15 @@ -146,40 +136,40 @@ object IteratorSpec extends Spec { val checks = 5 val ct = new TrieMap[Wrap, Int] for (i <- 0 until sz) ct.put(new Wrap(i), i) - + class Modifier extends Thread { override def run() { for (i <- 0 until sz) ct.putIfAbsent(new Wrap(i), i) match { case Some(_) => ct.remove(new Wrap(i)) - case None => + case None => } } } - + def consistentIteration(ct: TrieMap[Wrap, Int], checks: Int) { class Iter extends Thread { override def run() { val snap = ct.readOnlySnapshot() val initial = mutable.Map[Wrap, Int]() for (kv <- snap) initial += kv - + for (i <- 0 until checks) { assertEqual(snap.iterator.toMap, initial) } } } - + val iter = new Iter iter.start() iter.join() } - + val threads = for (_ <- 0 until W) yield new Modifier threads.foreach(_.start()) for (_ <- 0 until S) consistentIteration(ct, checks) threads.foreach(_.join()) } - + "be consistent with a concurrent removal with a well defined order" in { val sz = 150000 val sgroupsize = 10 @@ -187,17 +177,16 @@ object IteratorSpec extends Spec { val removerslowdown = 50 val ct = new TrieMap[Wrap, Int] for (i <- 0 until sz) ct.put(new Wrap(i), i) - + class Remover extends Thread { override def run() { for (i <- 0 until sz) { assert(ct.remove(new Wrap(i)) == Some(i)) for (i <- 0 until removerslowdown) ct.get(new Wrap(i)) // slow down, mate } - //println("done removing") } } - + def consistentIteration(it: Iterator[(Wrap, Int)]) = { class Iter extends Thread { override def run() { @@ -210,7 +199,7 @@ object IteratorSpec extends Spec { } new Iter } - + val remover = new Remover remover.start() for (_ <- 0 until sgroupnum) { @@ -218,27 +207,25 @@ object IteratorSpec extends Spec { iters.foreach(_.start()) iters.foreach(_.join()) } - //println("done with iterators") remover.join() } - + "be consistent with a concurrent insertion with a well defined order" in { val sz = 150000 val sgroupsize = 10 val sgroupnum = 10 val inserterslowdown = 50 val ct = new TrieMap[Wrap, Int] - + class Inserter extends Thread { override def run() { for (i <- 0 until sz) { assert(ct.put(new Wrap(i), i) == None) for (i <- 0 until inserterslowdown) ct.get(new Wrap(i)) // slow down, mate } - //println("done inserting") } } - + def consistentIteration(it: Iterator[(Wrap, Int)]) = { class Iter extends Thread { override def run() { @@ -251,7 +238,7 @@ object IteratorSpec extends Spec { } new Iter } - + val inserter = new Inserter inserter.start() for (_ <- 0 until sgroupnum) { @@ -259,31 +246,30 @@ object IteratorSpec extends Spec { iters.foreach(_.start()) iters.foreach(_.join()) } - //println("done with iterators") inserter.join() } - + "work on a yet unevaluated snapshot" in { val sz = 50000 val ct = new TrieMap[Wrap, Int] for (i <- 0 until sz) ct.update(new Wrap(i), i) - + val snap = ct.snapshot() val it = snap.iterator - + while (it.hasNext) it.next() } - + "be duplicated" in { val sz = 50 val ct = collection.parallel.mutable.ParTrieMap((0 until sz) zip (0 until sz): _*) val it = ct.splitter for (_ <- 0 until (sz / 2)) it.next() val dupit = it.dup - + it.toList shouldEqual dupit.toList } - + } - + } diff --git a/test/files/run/deeps.check b/test/files/run/deeps.check new file mode 100644 index 0000000000..a68e474f62 --- /dev/null +++ b/test/files/run/deeps.check @@ -0,0 +1,87 @@ +testEquals1 +false +false +true + +testEquals2 +false +false +true + +testEquals3 +x=Array(1) +y=Array(1) +false +false +true + +x=Array(Array(1), Array(1)) +y=Array(Array(1), Array(1)) +false +false +true + +x=Array(Array(Array(1), Array(1)), Array(Array(1), Array(1))) +y=Array(Array(Array(1), Array(1)), Array(Array(1), Array(1))) +false +false +true + +testEquals4 +false +false +true +false +false +true +Array(true, false) +Array(true, false) +[true;false] +true;false + +Array(Array(true, false), Array(true, false)) +Array(Array(true, false), Array(true, false)) +[Array(true, false);Array(true, false)] +Array(true, false);Array(true, false) + +Array(Array(Array(true, false), Array(true, false)), Array(Array(true, false), Array(true, false))) +Array(Array(Array(true, false), Array(true, false)), Array(Array(true, false), Array(true, false))) +[Array(Array(true, false), Array(true, false));Array(Array(true, false), Array(true, false))] +Array(Array(true, false), Array(true, false));Array(Array(true, false), Array(true, false)) + +Array(1.0, 0.0) +Array(1.0, 0.0) +[1.0;0.0] +1.0;0.0 + +Array(Array(1.0, 0.0), Array(1.0, 0.0)) +Array(Array(1.0, 0.0), Array(1.0, 0.0)) +[Array(1.0, 0.0);Array(1.0, 0.0)] +Array(1.0, 0.0);Array(1.0, 0.0) + +Array(Array(Array(1.0, 0.0), Array(1.0, 0.0)), Array(Array(1.0, 0.0), Array(1.0, 0.0))) +Array(Array(Array(1.0, 0.0), Array(1.0, 0.0)), Array(Array(1.0, 0.0), Array(1.0, 0.0))) +[Array(Array(1.0, 0.0), Array(1.0, 0.0));Array(Array(1.0, 0.0), Array(1.0, 0.0))] +Array(Array(1.0, 0.0), Array(1.0, 0.0));Array(Array(1.0, 0.0), Array(1.0, 0.0)) + +Array(a, b) +Array(a, b) +[a;b] +a;b + +Array(Array(a, b), Array(a, b)) +Array(Array(a, b), Array(a, b)) +[Array(a, b);Array(a, b)] +Array(a, b);Array(a, b) + +Array(Array(Array(a, b), Array(a, b)), Array(Array(a, b), Array(a, b))) +Array(Array(Array(a, b), Array(a, b)), Array(Array(a, b), Array(a, b))) +[Array(Array(a, b), Array(a, b));Array(Array(a, b), Array(a, b))] +Array(Array(a, b), Array(a, b));Array(Array(a, b), Array(a, b)) + +[Array(true, false); Array(false)] +[Array(1, 2); Array(3)] +[Array(1, 2); Array(3)] + +Array(boo, and, foo) +Array(a) diff --git a/test/files/run/deeps.scala b/test/files/run/deeps.scala new file mode 100644 index 0000000000..6049cc6024 --- /dev/null +++ b/test/files/run/deeps.scala @@ -0,0 +1,114 @@ +//############################################################################ +// deepEquals / deep.toString +//############################################################################ + +//############################################################################ +// need to revisit array equqality +object Test { + + def testEquals1 { + println(Array(1) == Array(1)) + println(Array(1) equals Array(1)) + println(Array(1).deep == Array(1).deep) + println + } + + def testEquals2 { + println(Array(Array(1), Array(2)) == Array(Array(1), Array(2))) + println(Array(Array(1), Array(2)) equals Array(Array(1), Array(2))) + println(Array(Array(1), Array(2)).deep equals Array(Array(1), Array(2)).deep) + println + } + + def testEquals3 { + val a1 = Array(1) + val b1 = Array(1) + val a2 = Array(a1, b1) + val b2 = Array(a1, b1) + val a3 = Array(a2, b2) + val b3 = Array(a2, b2) + def test[T](x: Array[T], y: Array[T]) { + println("x=" + x.deep.toString) + println("y=" + y.deep.toString) + println(x == y) + println(x equals y) + println(x.deep == y.deep) + println + } + test(a1, b1) + test(a2, b2) + test(a3, b3) + } + + def testEquals4 { + println("boo:and:foo".split(':') == "boo:and:foo".split(':')) + println("boo:and:foo".split(':') equals "boo:and:foo".split(':')) + println("boo:and:foo".split(':').deep == "boo:and:foo".split(':').deep) + + val xs = new java.util.ArrayList[String](); xs.add("a") + val ys = new java.util.ArrayList[String](); ys.add("a") + println(xs.toArray == ys.toArray) + println(xs.toArray equals ys.toArray) + println(xs.toArray.deep == ys.toArray.deep) + } + + def testToString1 { + def sweep(s: String) = ( + s.replaceAll("D@[0-9a-fA-F]+", "D@0000000") + .replaceAll("Z@[0-9a-fA-F]+", "Z@0000000") + .replaceAll(";@[0-9a-fA-F]+", ";@0000000") + ) + def test[T](a: Array[T]) { + println(sweep(a.deep.toString)) + println(a.deep.toString) + println(a.deep.mkString("[", ";", "]")) + println(a.deep.mkString(";")) + println + } + + val ba1 = Array(true, false) + val ba2 = Array(ba1, ba1) + val ba3 = Array(ba2, ba2) + test(ba1) + test(ba2) + test(ba3) + + val da1 = Array(1.0d, 0.0d) + val da2 = Array(da1, da1) + val da3 = Array(da2, da2) + test(da1) + test(da2) + test(da3) + + val sa1 = Array("a", "b") + val sa2 = Array(sa1, sa1) + val sa3 = Array(sa2, sa2) + test(sa1) + test(sa2) + test(sa3) + } + + def testToString2 { + println(Array(Array(true, false), Array(false)).deep.mkString("[", "; ", "]")) + println(Array(Array('1', '2'), Array('3')).deep.mkString("[", "; ", "]")) + println(Array(Array(1, 2), Array(3)).deep.mkString("[", "; ", "]")) + println + } + + def testToString3 { + println("boo:and:foo".split(':').deep.toString) + + val xs = new java.util.ArrayList[String](); xs.add("a") + println(xs.toArray.deep.toString) + } + + def main(args: Array[String]): Unit = { + println("testEquals1") ; testEquals1 + println("testEquals2") ; testEquals2 + println("testEquals3") ; testEquals3 + println("testEquals4") ; testEquals4 + testToString1 + testToString2 + testToString3 + } +} diff --git a/test/files/run/enums.scala b/test/files/run/enums.scala index 9cdeed2691..3aad7ec320 100644 --- a/test/files/run/enums.scala +++ b/test/files/run/enums.scala @@ -36,8 +36,11 @@ object Test2 { object Test3 { - object Direction extends Enumeration("North", "South", "East", "West") { - val North, South, East, West = Value; + object Direction extends Enumeration { + val North = Value("North") + val South = Value("South") + val East = Value("East") + val West = Value("West") } def run: Int = { @@ -48,8 +51,11 @@ object Test3 { object Test4 { - object Direction extends Enumeration("North", "South", "East", "West") { - val North, South, East, West = Value; + object Direction extends Enumeration { + val North = Value("North") + val South = Value("South") + val East = Value("East") + val West = Value("West") } def run: Int = { diff --git a/test/files/run/existentials-in-compiler.check b/test/files/run/existentials-in-compiler.check index 0d7a9298b4..b0d852865d 100644 --- a/test/files/run/existentials-in-compiler.check +++ b/test/files/run/existentials-in-compiler.check @@ -8,22 +8,22 @@ abstract trait BippyLike[A <: AnyRef, B <: List[A], This <: extest.BippyLike[A,B extest.BippyLike[A,B,This] forSome { A <: AnyRef; B <: List[A]; This <: extest.BippyLike[A,B,This] with extest.Bippy[A,B] } abstract trait Contra[-A >: AnyRef, -B] extends AnyRef - extest.Contra[_ >: AnyRef, _] + extest.Contra[AnyRef, _] abstract trait ContraLike[-A >: AnyRef, -B >: List[A]] extends AnyRef extest.ContraLike[A,B] forSome { -A >: AnyRef; -B >: List[A] } abstract trait Cov01[+A <: AnyRef, +B] extends AnyRef - extest.Cov01[_ <: AnyRef, _] + extest.Cov01[AnyRef,Any] abstract trait Cov02[+A <: AnyRef, B] extends AnyRef - extest.Cov02[_ <: AnyRef, _] + extest.Cov02[AnyRef, _] abstract trait Cov03[+A <: AnyRef, -B] extends AnyRef - extest.Cov03[_ <: AnyRef, _] + extest.Cov03[AnyRef, _] abstract trait Cov04[A <: AnyRef, +B] extends AnyRef - extest.Cov04[_ <: AnyRef, _] + extest.Cov04[_ <: AnyRef, Any] abstract trait Cov05[A <: AnyRef, B] extends AnyRef extest.Cov05[_ <: AnyRef, _] @@ -32,7 +32,7 @@ abstract trait Cov06[A <: AnyRef, -B] extends AnyRef extest.Cov06[_ <: AnyRef, _] abstract trait Cov07[-A <: AnyRef, +B] extends AnyRef - extest.Cov07[_ <: AnyRef, _] + extest.Cov07[_ <: AnyRef, Any] abstract trait Cov08[-A <: AnyRef, B] extends AnyRef extest.Cov08[_ <: AnyRef, _] @@ -41,16 +41,16 @@ abstract trait Cov09[-A <: AnyRef, -B] extends AnyRef extest.Cov09[_ <: AnyRef, _] abstract trait Cov11[+A <: AnyRef, +B <: List[_]] extends AnyRef - extest.Cov11[_ <: AnyRef, _ <: List[_]] + extest.Cov11[AnyRef,List[_]] abstract trait Cov12[+A <: AnyRef, B <: List[_]] extends AnyRef - extest.Cov12[_ <: AnyRef, _ <: List[_]] + extest.Cov12[AnyRef, _ <: List[_]] abstract trait Cov13[+A <: AnyRef, -B <: List[_]] extends AnyRef - extest.Cov13[_ <: AnyRef, _ <: List[_]] + extest.Cov13[AnyRef, _ <: List[_]] abstract trait Cov14[A <: AnyRef, +B <: List[_]] extends AnyRef - extest.Cov14[_ <: AnyRef, _ <: List[_]] + extest.Cov14[_ <: AnyRef, List[_]] abstract trait Cov15[A <: AnyRef, B <: List[_]] extends AnyRef extest.Cov15[_ <: AnyRef, _ <: List[_]] @@ -59,7 +59,7 @@ abstract trait Cov16[A <: AnyRef, -B <: List[_]] extends AnyRef extest.Cov16[_ <: AnyRef, _ <: List[_]] abstract trait Cov17[-A <: AnyRef, +B <: List[_]] extends AnyRef - extest.Cov17[_ <: AnyRef, _ <: List[_]] + extest.Cov17[_ <: AnyRef, List[_]] abstract trait Cov18[-A <: AnyRef, B <: List[_]] extends AnyRef extest.Cov18[_ <: AnyRef, _ <: List[_]] @@ -68,16 +68,16 @@ abstract trait Cov19[-A <: AnyRef, -B <: List[_]] extends AnyRef extest.Cov19[_ <: AnyRef, _ <: List[_]] abstract trait Cov21[+A, +B] extends AnyRef - extest.Cov21[_, _] + extest.Cov21[Any,Any] abstract trait Cov22[+A, B] extends AnyRef - extest.Cov22[_, _] + extest.Cov22[Any, _] abstract trait Cov23[+A, -B] extends AnyRef - extest.Cov23[_, _] + extest.Cov23[Any, _] abstract trait Cov24[A, +B] extends AnyRef - extest.Cov24[_, _] + extest.Cov24[_, Any] abstract trait Cov25[A, B] extends AnyRef extest.Cov25[_, _] @@ -86,7 +86,7 @@ abstract trait Cov26[A, -B] extends AnyRef extest.Cov26[_, _] abstract trait Cov27[-A, +B] extends AnyRef - extest.Cov27[_, _] + extest.Cov27[_, Any] abstract trait Cov28[-A, B] extends AnyRef extest.Cov28[_, _] @@ -122,16 +122,16 @@ abstract trait Cov39[-A, -B, C <: Tuple2[_, _]] extends AnyRef extest.Cov39[_, _, _ <: Tuple2[_, _]] abstract trait Cov41[+A >: Null, +B] extends AnyRef - extest.Cov41[_ >: Null, _] + extest.Cov41[Any,Any] abstract trait Cov42[+A >: Null, B] extends AnyRef - extest.Cov42[_ >: Null, _] + extest.Cov42[Any, _] abstract trait Cov43[+A >: Null, -B] extends AnyRef - extest.Cov43[_ >: Null, _] + extest.Cov43[Any, _] abstract trait Cov44[A >: Null, +B] extends AnyRef - extest.Cov44[_ >: Null, _] + extest.Cov44[_ >: Null, Any] abstract trait Cov45[A >: Null, B] extends AnyRef extest.Cov45[_ >: Null, _] @@ -140,7 +140,7 @@ abstract trait Cov46[A >: Null, -B] extends AnyRef extest.Cov46[_ >: Null, _] abstract trait Cov47[-A >: Null, +B] extends AnyRef - extest.Cov47[_ >: Null, _] + extest.Cov47[_ >: Null, Any] abstract trait Cov48[-A >: Null, B] extends AnyRef extest.Cov48[_ >: Null, _] @@ -149,7 +149,7 @@ abstract trait Cov49[-A >: Null, -B] extends AnyRef extest.Cov49[_ >: Null, _] abstract trait Covariant[+A <: AnyRef, +B] extends AnyRef - extest.Covariant[_ <: AnyRef, _] + extest.Covariant[AnyRef,Any] abstract trait CovariantLike[+A <: AnyRef, +B <: List[A], +This <: extest.CovariantLike[A,B,This] with extest.Covariant[A,B]] extends AnyRef extest.CovariantLike[A,B,This] forSome { +A <: AnyRef; +B <: List[A]; +This <: extest.CovariantLike[A,B,This] with extest.Covariant[A,B] } diff --git a/test/files/run/existentials-in-compiler.scala b/test/files/run/existentials-in-compiler.scala index c69d1217fd..14c25849cb 100644 --- a/test/files/run/existentials-in-compiler.scala +++ b/test/files/run/existentials-in-compiler.scala @@ -73,7 +73,7 @@ package extest { def check(source: String, unit: global.CompilationUnit) = { getRequiredPackage("extest").moduleClass.info.decls.toList.filter(_.isType).map(_.initialize).sortBy(_.name.toString) foreach { clazz => - afterTyper { + exitingTyper { clazz.info println(clazz.defString) println(" " + classExistentialType(clazz) + "\n") diff --git a/test/files/run/hashset.check b/test/files/run/hashset.check new file mode 100644 index 0000000000..9542a1ff48 --- /dev/null +++ b/test/files/run/hashset.check @@ -0,0 +1,26 @@ +*** HashSet primitives +0 true,1 true,10 true,11 true,12 true,13 true,14 true,15 true,16 true,17 true,18 true,19 true,2 true,3 true,4 true,5 true,6 true,7 true,8 true,9 true +20 false,21 false,22 false,23 false,24 false,25 false,26 false,27 false,28 false,29 false,30 false,31 false,32 false,33 false,34 false,35 false,36 false,37 false,38 false,39 false +0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19 + +*** HashSet Strings with null +null true +0 true,1 true,10 true,11 true,12 true,13 true,14 true,15 true,16 true,17 true,18 true,19 true,2 true,3 true,4 true,5 true,6 true,7 true,8 true,9 true +20 false,21 false,22 false,23 false,24 false,25 false,26 false,27 false,28 false,29 false,30 false,31 false,32 false,33 false,34 false,35 false,36 false,37 false,38 false,39 false +0,1,10,11,12,13,14,15,16,17,18,19,2,3,4,5,6,7,8,9,null +null false +0 false,1 true,10 true,11 true,12 true,13 true,14 true,15 true,16 true,17 true,18 true,19 true,2 true,3 true,4 true,5 true,6 true,7 true,8 true,9 true + +*** ParHashSet primitives +0 true,1 true,10 true,11 true,12 true,13 true,14 true,15 true,16 true,17 true,18 true,19 true,2 true,3 true,4 true,5 true,6 true,7 true,8 true,9 true +20 false,21 false,22 false,23 false,24 false,25 false,26 false,27 false,28 false,29 false,30 false,31 false,32 false,33 false,34 false,35 false,36 false,37 false,38 false,39 false +0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19 + +*** ParHashSet Strings with null +null true +0 true,1 true,10 true,11 true,12 true,13 true,14 true,15 true,16 true,17 true,18 true,19 true,2 true,3 true,4 true,5 true,6 true,7 true,8 true,9 true +20 false,21 false,22 false,23 false,24 false,25 false,26 false,27 false,28 false,29 false,30 false,31 false,32 false,33 false,34 false,35 false,36 false,37 false,38 false,39 false +0,1,10,11,12,13,14,15,16,17,18,19,2,3,4,5,6,7,8,9,null +null false +0 false,1 true,10 true,11 true,12 true,13 true,14 true,15 true,16 true,17 true,18 true,19 true,2 true,3 true,4 true,5 true,6 true,7 true,8 true,9 true + diff --git a/test/files/run/hashset.scala b/test/files/run/hashset.scala new file mode 100644 index 0000000000..299dce3aec --- /dev/null +++ b/test/files/run/hashset.scala @@ -0,0 +1,48 @@ +import scala.collection.generic.{Growable, Shrinkable} +import scala.collection.GenSet +import scala.collection.mutable.FlatHashTable +import scala.collection.mutable.HashSet +import scala.collection.parallel.mutable.ParHashSet + +object Test extends App { + test(new Creator{ + def create[A] = new HashSet[A] + def hashSetType = "HashSet" + }) + + test(new Creator{ + def create[A] = new ParHashSet[A] + def hashSetType = "ParHashSet" + }) + + + def test(creator : Creator) { + println("*** " + creator.hashSetType + " primitives") + val h1 = creator.create[Int] + for (i <- 0 until 20) h1 += i + println((for (i <- 0 until 20) yield i + " " + (h1 contains i)).toList.sorted mkString(",")) + println((for (i <- 20 until 40) yield i + " " + (h1 contains i)).toList.sorted mkString(",")) + println(h1.toList.sorted mkString ",") + println + + println("*** " + creator.hashSetType + " Strings with null") + val h2 = creator.create[String] + h2 += null + for (i <- 0 until 20) h2 += "" + i + println("null " + (h2 contains null)) + println((for (i <- 0 until 20) yield i + " " + (h2 contains ("" + i))).toList.sorted mkString(",")) + println((for (i <- 20 until 40) yield i + " " + (h2 contains ("" + i))).toList.sorted mkString(",")) + println((h2.toList map {x => "" + x}).sorted mkString ",") + + h2 -= null + h2 -= "" + 0 + println("null " + (h2 contains null)) + println((for (i <- 0 until 20) yield i + " " + (h2 contains ("" + i))).toList.sorted mkString(",")) + println + } + + trait Creator { + def create[A] : GenSet[A] with Cloneable with FlatHashTable[A] with Growable[A] with Shrinkable[A] + def hashSetType : String + } +}
\ No newline at end of file diff --git a/test/files/run/hashsetremove.check b/test/files/run/hashsetremove.check new file mode 100644 index 0000000000..8de9826895 --- /dev/null +++ b/test/files/run/hashsetremove.check @@ -0,0 +1,6 @@ +remove 0 should be false, was false +contains 1 should be true, was true +remove 1 should be true, was true +contains 1 should be false, was false +remove 1 should be false, was false +contains 1 should be false, was false diff --git a/test/files/run/hashsetremove.scala b/test/files/run/hashsetremove.scala new file mode 100644 index 0000000000..7b82a9909b --- /dev/null +++ b/test/files/run/hashsetremove.scala @@ -0,0 +1,13 @@ +import scala.collection.mutable.HashSet + + +object Test extends App { + val h = new HashSet[Int] + h += 1 + println(s"remove 0 should be false, was ${h remove 0}") + println(s"contains 1 should be true, was ${h contains 1}") + println(s"remove 1 should be true, was ${h remove 1}") + println(s"contains 1 should be false, was ${h contains 1}") + println(s"remove 1 should be false, was ${h remove 1}") + println(s"contains 1 should be false, was ${h contains 1}") + }
\ No newline at end of file diff --git a/test/files/run/idempotency-this.check b/test/files/run/idempotency-this.check index 08738c4565..efabaf1ec4 100644 --- a/test/files/run/idempotency-this.check +++ b/test/files/run/idempotency-this.check @@ -1,4 +1,4 @@ List() immutable.this.List.apply[String]("") -Apply(TypeApply(Select(Select(This(newTypeName("immutable")), scala.collection.immutable.List), newTermName("apply")), List(TypeTree().setOriginal(Ident(newTypeName("String"))))), List(Literal(Constant("")))) +Apply(TypeApply(Select(Select(This(TypeName("immutable")), scala.collection.immutable.List), TermName("apply")), List(TypeTree().setOriginal(Ident(TypeName("String"))))), List(Literal(Constant("")))) error! diff --git a/test/files/run/inline-ex-handlers.scala b/test/files/run/inline-ex-handlers.scala index a96b938e13..33e794b940 100644 --- a/test/files/run/inline-ex-handlers.scala +++ b/test/files/run/inline-ex-handlers.scala @@ -1,7 +1,7 @@ import scala.tools.partest.IcodeTest object Test extends IcodeTest { - override def printIcodeAfterPhase = "inlineExceptionHandlers" + override def printIcodeAfterPhase = "inlinehandlers" } import scala.util.Random._ diff --git a/test/files/run/lazy-locals.scala b/test/files/run/lazy-locals.scala index aca15d0357..8d4c61be8c 100644 --- a/test/files/run/lazy-locals.scala +++ b/test/files/run/lazy-locals.scala @@ -120,7 +120,7 @@ object Test extends App { t } - /** test recursive method with lazy vals and a all vals forced */ + /** test recursive method with lazy vals and all vals forced */ def testLazyRecMany(n: Int): Int = { lazy val t = { println("forced lazy val t at n = " + n); 42 } if (n > 0) { diff --git a/test/files/run/longmap.check b/test/files/run/longmap.check new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/files/run/longmap.check diff --git a/test/files/run/longmap.scala b/test/files/run/longmap.scala new file mode 100644 index 0000000000..1f18eebd31 --- /dev/null +++ b/test/files/run/longmap.scala @@ -0,0 +1,8 @@ +object Test extends App{ + import scala.collection.immutable.LongMap; + + val it = LongMap(8L -> 2, 11L -> 3, 1L -> 2, 7L -> 13); + + assert(it.firstKey == 1L); + assert(it.lastKey == 11L); +} diff --git a/test/files/run/lub-visibility.check b/test/files/run/lub-visibility.check index 3461d1bf6b..f3a6bef215 100644 --- a/test/files/run/lub-visibility.check +++ b/test/files/run/lub-visibility.check @@ -8,7 +8,7 @@ scala> // should infer List[scala.collection.immutable.Seq[Nothing]] scala> // but reverted that for SI-5534. scala> val x = List(List(), Vector()) -x: List[scala.collection.immutable.Seq[Nothing] with scala.collection.AbstractSeq[Nothing]{def companion: scala.collection.generic.GenericCompanion[scala.collection.immutable.Seq with scala.collection.AbstractSeq{def dropRight(n: Int): scala.collection.immutable.Seq[Any] with scala.collection.AbstractSeq[Any]; def takeRight(n: Int): scala.collection.immutable.Seq[Any] with scala.collection.AbstractSeq[Any]; def drop(n: Int): scala.collection.immutable.Seq[Any] with scala.collection.AbstractSeq[Any]; def take(n: Int): scala.collection.immutable.Seq[Any] with scala.collection.AbstractSeq[Any]; def slice(from: Int,until: Int): scala.collection.immutable.Seq[Any] with scala.collection.AbstractSeq[Any]}]; def dropRight(n: Int): scala.collection.immutable.Seq[Nothing] with scala.collection.Ab... +x: List[scala.collection.immutable.Seq[Nothing] with scala.collection.AbstractSeq[Nothing]{def companion: scala.collection.generic.GenericCompanion[scala.collection.immutable.Seq with scala.collection.AbstractSeq]; def dropRight(n: Int): scala.collection.immutable.Seq[Nothing] with scala.collection.AbstractSeq[Nothing]{def companion: scala.collection.generic.GenericCompanion[scala.collection.immutable.Seq with scala.collection.AbstractSeq]; def dropRight(n: Int): scala.collection.immutable.Seq[Nothing] with scala.collection.AbstractSeq[Nothing]{def dropRight(n: Int): scala.collection.immutable.Seq[Nothing] with scala.collection.AbstractSeq[Nothing]; def takeRight(n: Int): scala.collection.immutable.Seq[Nothing] with scala.collection.AbstractSeq[Nothing]; def drop(n: Int): scala.collecti... scala> scala> diff --git a/test/files/run/macro-abort-fresh/Macros_1.scala b/test/files/run/macro-abort-fresh/Macros_1.scala index af1e292588..415b76852f 100644 --- a/test/files/run/macro-abort-fresh/Macros_1.scala +++ b/test/files/run/macro-abort-fresh/Macros_1.scala @@ -5,7 +5,7 @@ object Impls { import c.universe._ println(c.fresh()) println(c.fresh("qwe")) - println(c.fresh(newTypeName("qwe"))) + println(c.fresh(TypeName("qwe"))) c.abort(NoPosition, "blargh") } } diff --git a/test/files/run/macro-abort-fresh/Test_2.scala b/test/files/run/macro-abort-fresh/Test_2.scala index 0b9986e9f6..61f0bdfadc 100644 --- a/test/files/run/macro-abort-fresh/Test_2.scala +++ b/test/files/run/macro-abort-fresh/Test_2.scala @@ -2,7 +2,7 @@ object Test extends App { import scala.reflect.runtime.universe._ import scala.reflect.runtime.{currentMirror => cm} import scala.tools.reflect.ToolBox - val tree = Select(Ident(newTermName("Macros")), newTermName("foo")) + val tree = Select(Ident(TermName("Macros")), TermName("foo")) try cm.mkToolBox().eval(tree) catch { case ex: Throwable => println(ex.getMessage) } }
\ No newline at end of file diff --git a/test/files/run/macro-basic-ma-md-mi/Impls_1.scala b/test/files/run/macro-basic-ma-md-mi/Impls_1.scala index 646634c972..ce30366c61 100644 --- a/test/files/run/macro-basic-ma-md-mi/Impls_1.scala +++ b/test/files/run/macro-basic-ma-md-mi/Impls_1.scala @@ -3,19 +3,19 @@ import scala.reflect.macros.{Context => Ctx} object Impls { def foo(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = { import c.universe._ - val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(1)))) + val body = Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(1)))) c.Expr[Int](body) } def bar(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = { import c.universe._ - val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(2)))) + val body = Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(2)))) c.Expr[Int](body) } def quux(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = { import c.universe._ - val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(3)))) + val body = Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(3)))) c.Expr[Int](body) } }
\ No newline at end of file diff --git a/test/files/run/macro-basic-ma-mdmi/Impls_Macros_1.scala b/test/files/run/macro-basic-ma-mdmi/Impls_Macros_1.scala index aa1e52e4aa..a601af6dde 100644 --- a/test/files/run/macro-basic-ma-mdmi/Impls_Macros_1.scala +++ b/test/files/run/macro-basic-ma-mdmi/Impls_Macros_1.scala @@ -3,19 +3,19 @@ import scala.reflect.macros.{Context => Ctx} object Impls { def foo(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = { import c.universe._ - val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(1)))) + val body = Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(1)))) c.Expr[Int](body) } def bar(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = { import c.universe._ - val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(2)))) + val body = Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(2)))) c.Expr[Int](body) } def quux(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = { import c.universe._ - val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(3)))) + val body = Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(3)))) c.Expr[Int](body) } } diff --git a/test/files/run/macro-basic-mamd-mi/Impls_1.scala b/test/files/run/macro-basic-mamd-mi/Impls_1.scala index 061aa2d4a3..6e5983bdec 100644 --- a/test/files/run/macro-basic-mamd-mi/Impls_1.scala +++ b/test/files/run/macro-basic-mamd-mi/Impls_1.scala @@ -3,17 +3,17 @@ import scala.reflect.macros.{Context => Ctx} object Impls { def foo(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = { import c.universe._ - c.Expr(Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(1))))) + c.Expr(Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(1))))) } def bar(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = { import c.universe._ - c.Expr(Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(2))))) + c.Expr(Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(2))))) } def quux(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = { import c.universe._ - val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(3)))) + val body = Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(3)))) c.Expr[Int](body) } }
\ No newline at end of file diff --git a/test/files/run/macro-bodyexpandstoimpl/Impls_1.scala b/test/files/run/macro-bodyexpandstoimpl/Impls_1.scala index 0ca0be5a48..9c1e4ee46d 100644 --- a/test/files/run/macro-bodyexpandstoimpl/Impls_1.scala +++ b/test/files/run/macro-bodyexpandstoimpl/Impls_1.scala @@ -6,7 +6,7 @@ object Impls { def refToFoo(dummy: Int) = macro refToFoo_impl def refToFoo_impl(c: Ctx)(dummy: c.Expr[Int]) = { import c.universe._ - val body = Select(Ident(newTermName("Impls")), newTermName("foo")) + val body = Select(Ident(TermName("Impls")), TermName("foo")) c.Expr[Int](body) } }
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-annotation/Impls_1.scala b/test/files/run/macro-declared-in-annotation/Impls_1.scala index a11ee2907a..1ea06de679 100644 --- a/test/files/run/macro-declared-in-annotation/Impls_1.scala +++ b/test/files/run/macro-declared-in-annotation/Impls_1.scala @@ -4,7 +4,7 @@ object Impls { def foo(c: Ctx) = { import c.{prefix => prefix} import c.universe._ - val printPrefix = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("prefix = " + prefix)))) + val printPrefix = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("prefix = " + prefix)))) val body = Block(List(printPrefix), Literal(Constant("this is deprecated"))) c.Expr[String](body) } diff --git a/test/files/run/macro-declared-in-anonymous/Impls_1.scala b/test/files/run/macro-declared-in-anonymous/Impls_1.scala index 6f06f6d3f0..348f3420f2 100644 --- a/test/files/run/macro-declared-in-anonymous/Impls_1.scala +++ b/test/files/run/macro-declared-in-anonymous/Impls_1.scala @@ -4,8 +4,8 @@ object Impls { def foo(c: Ctx) = { import c.{prefix => prefix} import c.universe._ - val printPrefix = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("prefix = " + prefix)))) - val body = Block(List(printPrefix), Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("it works"))))) + val printPrefix = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("prefix = " + prefix)))) + val body = Block(List(printPrefix), Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("it works"))))) c.Expr[Unit](body) } }
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-block/Impls_1.scala b/test/files/run/macro-declared-in-block/Impls_1.scala index 6f06f6d3f0..348f3420f2 100644 --- a/test/files/run/macro-declared-in-block/Impls_1.scala +++ b/test/files/run/macro-declared-in-block/Impls_1.scala @@ -4,8 +4,8 @@ object Impls { def foo(c: Ctx) = { import c.{prefix => prefix} import c.universe._ - val printPrefix = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("prefix = " + prefix)))) - val body = Block(List(printPrefix), Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("it works"))))) + val printPrefix = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("prefix = " + prefix)))) + val body = Block(List(printPrefix), Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("it works"))))) c.Expr[Unit](body) } }
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-class-class/Impls_1.scala b/test/files/run/macro-declared-in-class-class/Impls_1.scala index 6f06f6d3f0..348f3420f2 100644 --- a/test/files/run/macro-declared-in-class-class/Impls_1.scala +++ b/test/files/run/macro-declared-in-class-class/Impls_1.scala @@ -4,8 +4,8 @@ object Impls { def foo(c: Ctx) = { import c.{prefix => prefix} import c.universe._ - val printPrefix = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("prefix = " + prefix)))) - val body = Block(List(printPrefix), Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("it works"))))) + val printPrefix = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("prefix = " + prefix)))) + val body = Block(List(printPrefix), Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("it works"))))) c.Expr[Unit](body) } }
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-class-object/Impls_1.scala b/test/files/run/macro-declared-in-class-object/Impls_1.scala index 6f06f6d3f0..348f3420f2 100644 --- a/test/files/run/macro-declared-in-class-object/Impls_1.scala +++ b/test/files/run/macro-declared-in-class-object/Impls_1.scala @@ -4,8 +4,8 @@ object Impls { def foo(c: Ctx) = { import c.{prefix => prefix} import c.universe._ - val printPrefix = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("prefix = " + prefix)))) - val body = Block(List(printPrefix), Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("it works"))))) + val printPrefix = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("prefix = " + prefix)))) + val body = Block(List(printPrefix), Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("it works"))))) c.Expr[Unit](body) } }
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-class/Impls_1.scala b/test/files/run/macro-declared-in-class/Impls_1.scala index 6f06f6d3f0..348f3420f2 100644 --- a/test/files/run/macro-declared-in-class/Impls_1.scala +++ b/test/files/run/macro-declared-in-class/Impls_1.scala @@ -4,8 +4,8 @@ object Impls { def foo(c: Ctx) = { import c.{prefix => prefix} import c.universe._ - val printPrefix = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("prefix = " + prefix)))) - val body = Block(List(printPrefix), Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("it works"))))) + val printPrefix = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("prefix = " + prefix)))) + val body = Block(List(printPrefix), Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("it works"))))) c.Expr[Unit](body) } }
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-default-param/Impls_1.scala b/test/files/run/macro-declared-in-default-param/Impls_1.scala index db1e5c7435..4380f40b04 100644 --- a/test/files/run/macro-declared-in-default-param/Impls_1.scala +++ b/test/files/run/macro-declared-in-default-param/Impls_1.scala @@ -4,7 +4,7 @@ object Impls { def foo(c: Ctx) = { import c.{prefix => prefix} import c.universe._ - val printPrefix = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("prefix = " + prefix)))) + val printPrefix = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("prefix = " + prefix)))) val body = Block(List(printPrefix), Literal(Constant("it works"))) c.Expr[String](body) } diff --git a/test/files/run/macro-declared-in-implicit-class/Impls_Macros_1.scala b/test/files/run/macro-declared-in-implicit-class/Impls_Macros_1.scala index 837b306976..4c009cc367 100644 --- a/test/files/run/macro-declared-in-implicit-class/Impls_Macros_1.scala +++ b/test/files/run/macro-declared-in-implicit-class/Impls_Macros_1.scala @@ -4,8 +4,8 @@ object Impls { def toOptionOfInt(c: Ctx) = { import c.{prefix => prefix} import c.universe._ - val printPrefix = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("prefix = " + prefix)))) - val body = Block(List(printPrefix), Apply(Ident(definitions.SomeModule), List(Select(Select(prefix.tree, newTermName("x")), newTermName("toInt"))))) + val printPrefix = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("prefix = " + prefix)))) + val body = Block(List(printPrefix), Apply(Ident(definitions.SomeModule), List(Select(Select(prefix.tree, TermName("x")), TermName("toInt"))))) c.Expr[Option[Int]](body) } } diff --git a/test/files/run/macro-declared-in-method/Impls_1.scala b/test/files/run/macro-declared-in-method/Impls_1.scala index 6f06f6d3f0..348f3420f2 100644 --- a/test/files/run/macro-declared-in-method/Impls_1.scala +++ b/test/files/run/macro-declared-in-method/Impls_1.scala @@ -4,8 +4,8 @@ object Impls { def foo(c: Ctx) = { import c.{prefix => prefix} import c.universe._ - val printPrefix = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("prefix = " + prefix)))) - val body = Block(List(printPrefix), Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("it works"))))) + val printPrefix = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("prefix = " + prefix)))) + val body = Block(List(printPrefix), Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("it works"))))) c.Expr[Unit](body) } }
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-object-class/Impls_1.scala b/test/files/run/macro-declared-in-object-class/Impls_1.scala index 6f06f6d3f0..348f3420f2 100644 --- a/test/files/run/macro-declared-in-object-class/Impls_1.scala +++ b/test/files/run/macro-declared-in-object-class/Impls_1.scala @@ -4,8 +4,8 @@ object Impls { def foo(c: Ctx) = { import c.{prefix => prefix} import c.universe._ - val printPrefix = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("prefix = " + prefix)))) - val body = Block(List(printPrefix), Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("it works"))))) + val printPrefix = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("prefix = " + prefix)))) + val body = Block(List(printPrefix), Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("it works"))))) c.Expr[Unit](body) } }
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-object-object/Impls_1.scala b/test/files/run/macro-declared-in-object-object/Impls_1.scala index 6f06f6d3f0..348f3420f2 100644 --- a/test/files/run/macro-declared-in-object-object/Impls_1.scala +++ b/test/files/run/macro-declared-in-object-object/Impls_1.scala @@ -4,8 +4,8 @@ object Impls { def foo(c: Ctx) = { import c.{prefix => prefix} import c.universe._ - val printPrefix = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("prefix = " + prefix)))) - val body = Block(List(printPrefix), Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("it works"))))) + val printPrefix = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("prefix = " + prefix)))) + val body = Block(List(printPrefix), Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("it works"))))) c.Expr[Unit](body) } }
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-object/Impls_1.scala b/test/files/run/macro-declared-in-object/Impls_1.scala index 6f06f6d3f0..348f3420f2 100644 --- a/test/files/run/macro-declared-in-object/Impls_1.scala +++ b/test/files/run/macro-declared-in-object/Impls_1.scala @@ -4,8 +4,8 @@ object Impls { def foo(c: Ctx) = { import c.{prefix => prefix} import c.universe._ - val printPrefix = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("prefix = " + prefix)))) - val body = Block(List(printPrefix), Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("it works"))))) + val printPrefix = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("prefix = " + prefix)))) + val body = Block(List(printPrefix), Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("it works"))))) c.Expr[Unit](body) } }
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-package-object/Impls_1.scala b/test/files/run/macro-declared-in-package-object/Impls_1.scala index 6f06f6d3f0..348f3420f2 100644 --- a/test/files/run/macro-declared-in-package-object/Impls_1.scala +++ b/test/files/run/macro-declared-in-package-object/Impls_1.scala @@ -4,8 +4,8 @@ object Impls { def foo(c: Ctx) = { import c.{prefix => prefix} import c.universe._ - val printPrefix = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("prefix = " + prefix)))) - val body = Block(List(printPrefix), Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("it works"))))) + val printPrefix = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("prefix = " + prefix)))) + val body = Block(List(printPrefix), Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("it works"))))) c.Expr[Unit](body) } }
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-refinement/Impls_1.scala b/test/files/run/macro-declared-in-refinement/Impls_1.scala index 6f06f6d3f0..348f3420f2 100644 --- a/test/files/run/macro-declared-in-refinement/Impls_1.scala +++ b/test/files/run/macro-declared-in-refinement/Impls_1.scala @@ -4,8 +4,8 @@ object Impls { def foo(c: Ctx) = { import c.{prefix => prefix} import c.universe._ - val printPrefix = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("prefix = " + prefix)))) - val body = Block(List(printPrefix), Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("it works"))))) + val printPrefix = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("prefix = " + prefix)))) + val body = Block(List(printPrefix), Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("it works"))))) c.Expr[Unit](body) } }
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-trait/Impls_1.scala b/test/files/run/macro-declared-in-trait/Impls_1.scala index 6f06f6d3f0..348f3420f2 100644 --- a/test/files/run/macro-declared-in-trait/Impls_1.scala +++ b/test/files/run/macro-declared-in-trait/Impls_1.scala @@ -4,8 +4,8 @@ object Impls { def foo(c: Ctx) = { import c.{prefix => prefix} import c.universe._ - val printPrefix = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("prefix = " + prefix)))) - val body = Block(List(printPrefix), Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("it works"))))) + val printPrefix = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("prefix = " + prefix)))) + val body = Block(List(printPrefix), Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("it works"))))) c.Expr[Unit](body) } }
\ No newline at end of file diff --git a/test/files/run/macro-def-infer-return-type-b/Test_2.scala b/test/files/run/macro-def-infer-return-type-b/Test_2.scala index ea0fd4bbff..9e57b90b57 100644 --- a/test/files/run/macro-def-infer-return-type-b/Test_2.scala +++ b/test/files/run/macro-def-infer-return-type-b/Test_2.scala @@ -2,7 +2,7 @@ object Test extends App { import scala.reflect.runtime.universe._ import scala.reflect.runtime.{currentMirror => cm} import scala.tools.reflect.ToolBox - val tree = Apply(Select(Ident(newTermName("Macros")), newTermName("foo")), List(Literal(Constant(42)))) + val tree = Apply(Select(Ident(TermName("Macros")), TermName("foo")), List(Literal(Constant(42)))) try cm.mkToolBox().eval(tree) catch { case ex: Throwable => println(ex.getMessage) } } diff --git a/test/files/run/macro-duplicate.check b/test/files/run/macro-duplicate.check new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/files/run/macro-duplicate.check diff --git a/test/files/run/macro-duplicate.flags b/test/files/run/macro-duplicate.flags new file mode 100644 index 0000000000..cd66464f2f --- /dev/null +++ b/test/files/run/macro-duplicate.flags @@ -0,0 +1 @@ +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-duplicate/Impls_Macros_1.scala b/test/files/run/macro-duplicate/Impls_Macros_1.scala new file mode 100644 index 0000000000..af80147a90 --- /dev/null +++ b/test/files/run/macro-duplicate/Impls_Macros_1.scala @@ -0,0 +1,29 @@ +import scala.reflect.macros.Context + +object Macros { + def impl(c: Context) = { + import c.universe._ + val Expr(Block((cdef: ClassDef) :: Nil, _)) = reify { class C { def x = 2 } } + val cdef1 = + new Transformer { + override def transform(tree: Tree): Tree = tree match { + case Template(_, _, ctor :: defs) => + val defs1 = defs collect { + case ddef @ DefDef(mods, name, tparams, vparamss, tpt, body) => + val future = Select(Select(Select(Ident(TermName("scala")), TermName("concurrent")), TermName("package")), TermName("future")) + val Future = Select(Select(Ident(TermName("scala")), TermName("concurrent")), TypeName("Future")) + val tpt1 = if (tpt.isEmpty) tpt else AppliedTypeTree(Future, List(tpt)) + val body1 = Apply(future, List(body)) + val name1 = TermName("async" + name.toString.capitalize) + DefDef(mods, name1, tparams, vparamss, tpt1, body1) + } + Template(Nil, emptyValDef, ctor +: defs ::: defs1) + case _ => + super.transform(tree) + } + } transform cdef + c.Expr[Unit](Block(cdef1 :: Nil, Literal(Constant(())))) + } + + def foo = macro impl +}
\ No newline at end of file diff --git a/test/files/run/macro-duplicate/Test_2.scala b/test/files/run/macro-duplicate/Test_2.scala new file mode 100644 index 0000000000..6dbd4382d3 --- /dev/null +++ b/test/files/run/macro-duplicate/Test_2.scala @@ -0,0 +1,6 @@ +import scala.concurrent._ +import ExecutionContext.Implicits.global + +object Test extends App { + Macros.foo +}
\ No newline at end of file diff --git a/test/files/run/macro-enclosures.check b/test/files/run/macro-enclosures.check new file mode 100644 index 0000000000..36bb67e194 --- /dev/null +++ b/test/files/run/macro-enclosures.check @@ -0,0 +1,32 @@ +enclosingPackage = package test { + object Test extends scala.AnyRef { + def <init>() = { + super.<init>(); + () + }; + def test = Macros.foo + } +} +enclosingClass = object Test extends scala.AnyRef { + def <init>() = { + super.<init>(); + () + }; + def test = Macros.foo +} +enclosingImpl = object Test extends scala.AnyRef { + def <init>() = { + super.<init>(); + () + }; + def test = Macros.foo +} +enclosingTemplate = scala.AnyRef { + def <init>() = { + super.<init>(); + () + }; + def test = Macros.foo +} +enclosingMethod = def test = Macros.foo +enclosingDef = def test = Macros.foo diff --git a/test/files/run/macro-enclosures.flags b/test/files/run/macro-enclosures.flags new file mode 100644 index 0000000000..cd66464f2f --- /dev/null +++ b/test/files/run/macro-enclosures.flags @@ -0,0 +1 @@ +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-enclosures/Impls_Macros_1.scala b/test/files/run/macro-enclosures/Impls_Macros_1.scala new file mode 100644 index 0000000000..cd54028676 --- /dev/null +++ b/test/files/run/macro-enclosures/Impls_Macros_1.scala @@ -0,0 +1,14 @@ +import scala.reflect.macros.Context + +object Macros { + def impl(c: Context) = c.universe.reify { + println("enclosingPackage = " + c.literal(c.enclosingPackage.toString).splice) + println("enclosingClass = " + c.literal(c.enclosingClass.toString).splice) + println("enclosingImpl = " + c.literal(c.enclosingImpl.toString).splice) + println("enclosingTemplate = " + c.literal(c.enclosingTemplate.toString).splice) + println("enclosingMethod = " + c.literal(c.enclosingMethod.toString).splice) + println("enclosingDef = " + c.literal(c.enclosingDef.toString).splice) + } + + def foo = macro impl +}
\ No newline at end of file diff --git a/test/files/run/macro-enclosures/Test_2.scala b/test/files/run/macro-enclosures/Test_2.scala new file mode 100644 index 0000000000..779fe5211e --- /dev/null +++ b/test/files/run/macro-enclosures/Test_2.scala @@ -0,0 +1,11 @@ +object Test extends App { + test.Test.test +} + +package test { + object Test { + def test = { + Macros.foo + } + } +}
\ No newline at end of file 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 d9fd5b8cb0..b2c7b4d6ca 100644 --- a/test/files/run/macro-expand-implicit-argument/Macros_1.scala +++ b/test/files/run/macro-expand-implicit-argument/Macros_1.scala @@ -41,14 +41,14 @@ object Macros { def const(x:Int) = Literal(Constant(x)) val n = as.length - val arr = newTermName("arr") + val arr = TermName("arr") - val create = Apply(Select(ct.tree, newTermName("newArray")), List(const(n))) + val create = Apply(Select(ct.tree, TermName("newArray")), List(const(n))) val arrtpe = TypeTree(implicitly[c.WeakTypeTag[Array[A]]].tpe) val valdef = ValDef(Modifiers(), arr, arrtpe, create) val updates = (0 until n).map { - i => Apply(Select(Ident(arr), newTermName("update")), List(const(i), as(i).tree)) + i => Apply(Select(Ident(arr), TermName("update")), List(const(i), as(i).tree)) } val exprs = (Seq(valdef) ++ updates ++ Seq(Ident(arr))).toList diff --git a/test/files/run/macro-expand-implicit-macro-has-implicit/Impls_1.scala b/test/files/run/macro-expand-implicit-macro-has-implicit/Impls_1.scala index 082e6b2efe..ac1e55c9b2 100644 --- a/test/files/run/macro-expand-implicit-macro-has-implicit/Impls_1.scala +++ b/test/files/run/macro-expand-implicit-macro-has-implicit/Impls_1.scala @@ -3,7 +3,7 @@ import scala.reflect.macros.{Context => Ctx} object Impls { def foo(c: Ctx)(x: c.Expr[Int]) = { import c.universe._ - val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(x.tree)) + val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(x.tree)) c.Expr[Unit](body) } }
\ No newline at end of file diff --git a/test/files/run/macro-expand-implicit-macro-is-implicit/Impls_1.scala b/test/files/run/macro-expand-implicit-macro-is-implicit/Impls_1.scala index cceb038f05..aa1fc7a358 100644 --- a/test/files/run/macro-expand-implicit-macro-is-implicit/Impls_1.scala +++ b/test/files/run/macro-expand-implicit-macro-is-implicit/Impls_1.scala @@ -3,7 +3,7 @@ import scala.reflect.macros.{Context => Ctx} object Impls { def foo(c: Ctx)(x: c.Expr[String]): c.Expr[Option[Int]] = { import c.universe._ - val body = Apply(Ident(definitions.SomeModule), List(Select(x.tree, newTermName("toInt")))) + val body = Apply(Ident(definitions.SomeModule), List(Select(x.tree, TermName("toInt")))) c.Expr[Option[Int]](body) } }
\ No newline at end of file diff --git a/test/files/run/macro-expand-implicit-macro-is-view/Impls_1.scala b/test/files/run/macro-expand-implicit-macro-is-view/Impls_1.scala index cceb038f05..aa1fc7a358 100644 --- a/test/files/run/macro-expand-implicit-macro-is-view/Impls_1.scala +++ b/test/files/run/macro-expand-implicit-macro-is-view/Impls_1.scala @@ -3,7 +3,7 @@ import scala.reflect.macros.{Context => Ctx} object Impls { def foo(c: Ctx)(x: c.Expr[String]): c.Expr[Option[Int]] = { import c.universe._ - val body = Apply(Ident(definitions.SomeModule), List(Select(x.tree, newTermName("toInt")))) + val body = Apply(Ident(definitions.SomeModule), List(Select(x.tree, TermName("toInt")))) c.Expr[Option[Int]](body) } }
\ No newline at end of file diff --git a/test/files/run/macro-expand-multiple-arglists/Impls_1.scala b/test/files/run/macro-expand-multiple-arglists/Impls_1.scala index 11e07932c3..4fddc13d68 100644 --- a/test/files/run/macro-expand-multiple-arglists/Impls_1.scala +++ b/test/files/run/macro-expand-multiple-arglists/Impls_1.scala @@ -3,8 +3,8 @@ import scala.reflect.macros.{Context => Ctx} object Impls { def foo(c: Ctx)(x: c.Expr[Int])(y: c.Expr[Int]) = { import c.universe._ - val sum = Apply(Select(x.tree, newTermName("$minus")), List(y.tree)) - val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(sum)) + val sum = Apply(Select(x.tree, TermName("$minus")), List(y.tree)) + val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(sum)) c.Expr[Unit](body) } }
\ No newline at end of file diff --git a/test/files/run/macro-expand-nullary-generic/Impls_1.scala b/test/files/run/macro-expand-nullary-generic/Impls_1.scala index 1180c83a40..39a9db0e14 100644 --- a/test/files/run/macro-expand-nullary-generic/Impls_1.scala +++ b/test/files/run/macro-expand-nullary-generic/Impls_1.scala @@ -4,7 +4,7 @@ import scala.reflect.macros.{Context => Ctx} object Impls { def impl[T: c.WeakTypeTag](c: Ctx) = { import c.universe._ - val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("it works " + implicitly[c.WeakTypeTag[T]])))) + val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("it works " + implicitly[c.WeakTypeTag[T]])))) c.Expr[Unit](body) } diff --git a/test/files/run/macro-expand-nullary-nongeneric/Impls_1.scala b/test/files/run/macro-expand-nullary-nongeneric/Impls_1.scala index c6bd1cdbf1..41e50acc86 100644 --- a/test/files/run/macro-expand-nullary-nongeneric/Impls_1.scala +++ b/test/files/run/macro-expand-nullary-nongeneric/Impls_1.scala @@ -3,7 +3,7 @@ import scala.reflect.macros.{Context => Ctx} object Impls { def impl(c: Ctx) = { import c.universe._ - val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("it works")))) + val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("it works")))) c.Expr[Unit](body) } diff --git a/test/files/run/macro-expand-overload/Impls_1.scala b/test/files/run/macro-expand-overload/Impls_1.scala index f7c240d9ca..1c672f6040 100644 --- a/test/files/run/macro-expand-overload/Impls_1.scala +++ b/test/files/run/macro-expand-overload/Impls_1.scala @@ -4,7 +4,7 @@ object Impls { def impl(c: Ctx)(tag: String, x: c.Expr[_]) = { import c.{prefix => prefix} import c.universe._ - val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(tag)), Literal(Constant(prefix.toString)), x.tree)) + val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant(tag)), Literal(Constant(prefix.toString)), x.tree)) c.Expr[Unit](body) } diff --git a/test/files/run/macro-expand-override/Impls_1.scala b/test/files/run/macro-expand-override/Impls_1.scala index ec93dd4111..69ef57d18d 100644 --- a/test/files/run/macro-expand-override/Impls_1.scala +++ b/test/files/run/macro-expand-override/Impls_1.scala @@ -4,7 +4,7 @@ object Impls { def impl(c: Ctx)(tag: String, x: c.Expr[_]) = { import c.{prefix => prefix} import c.universe._ - val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(tag)), Literal(Constant(prefix.toString)), x.tree)) + val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant(tag)), Literal(Constant(prefix.toString)), x.tree)) c.Expr[Unit](body) } diff --git a/test/files/run/macro-expand-recursive/Impls_1.scala b/test/files/run/macro-expand-recursive/Impls_1.scala index 61db5c4a9b..47dd398454 100644 --- a/test/files/run/macro-expand-recursive/Impls_1.scala +++ b/test/files/run/macro-expand-recursive/Impls_1.scala @@ -3,13 +3,13 @@ import scala.reflect.macros.{Context => Ctx} object Impls { def foo(c: Ctx) = { import c.universe._ - val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("it works")))) + val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("it works")))) c.Expr[Unit](body) } def fooFoo(c: Ctx) = { import c.universe._ - val body = Select(Ident(newTermName("Macros")), newTermName("foo")) + val body = Select(Ident(TermName("Macros")), TermName("foo")) c.Expr[Unit](body) } }
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-explicit/Impls_1.scala b/test/files/run/macro-expand-tparams-explicit/Impls_1.scala index 72b420d92f..f748ab855f 100644 --- a/test/files/run/macro-expand-tparams-explicit/Impls_1.scala +++ b/test/files/run/macro-expand-tparams-explicit/Impls_1.scala @@ -5,7 +5,7 @@ object Impls { def foo[U: c.WeakTypeTag](c: Ctx) = { import c.universe._ val U = implicitly[c.WeakTypeTag[U]] - val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(U.toString)))) + val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant(U.toString)))) c.Expr[Unit](body) } }
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-implicit/Impls_1.scala b/test/files/run/macro-expand-tparams-implicit/Impls_1.scala index 33770516df..c729aada51 100644 --- a/test/files/run/macro-expand-tparams-implicit/Impls_1.scala +++ b/test/files/run/macro-expand-tparams-implicit/Impls_1.scala @@ -5,7 +5,7 @@ object Impls { def foo[U: c.WeakTypeTag](c: Ctx)(x: c.Expr[U]) = { import c.universe._ val U = implicitly[c.WeakTypeTag[U]] - val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(U.toString)))) + val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant(U.toString)))) c.Expr[Unit](body) } }
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-optional/Impls_1.scala b/test/files/run/macro-expand-tparams-optional/Impls_1.scala index 3b829e2e09..ace7a6cd26 100644 --- a/test/files/run/macro-expand-tparams-optional/Impls_1.scala +++ b/test/files/run/macro-expand-tparams-optional/Impls_1.scala @@ -3,7 +3,7 @@ import scala.reflect.macros.{Context => Ctx} object Impls { def foo[U](c: Ctx) = { import c.universe._ - val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("don't know U")))) + val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("don't know U")))) c.Expr[Unit](body) } }
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-prefix-a/Impls_1.scala b/test/files/run/macro-expand-tparams-prefix-a/Impls_1.scala index 33770516df..c729aada51 100644 --- a/test/files/run/macro-expand-tparams-prefix-a/Impls_1.scala +++ b/test/files/run/macro-expand-tparams-prefix-a/Impls_1.scala @@ -5,7 +5,7 @@ object Impls { def foo[U: c.WeakTypeTag](c: Ctx)(x: c.Expr[U]) = { import c.universe._ val U = implicitly[c.WeakTypeTag[U]] - val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(U.toString)))) + val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant(U.toString)))) c.Expr[Unit](body) } }
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-prefix-b/Impls_1.scala b/test/files/run/macro-expand-tparams-prefix-b/Impls_1.scala index 9378e67712..8880d13b04 100644 --- a/test/files/run/macro-expand-tparams-prefix-b/Impls_1.scala +++ b/test/files/run/macro-expand-tparams-prefix-b/Impls_1.scala @@ -6,7 +6,7 @@ object Impls { import c.universe._ val T = implicitly[c.WeakTypeTag[T]] val U = implicitly[c.WeakTypeTag[U]] - val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(T.toString + " " + U.toString)))) + val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant(T.toString + " " + U.toString)))) c.Expr[Unit](body) } }
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-prefix-c1/Impls_1.scala b/test/files/run/macro-expand-tparams-prefix-c1/Impls_1.scala index afdd7d4f7a..2df42e969f 100644 --- a/test/files/run/macro-expand-tparams-prefix-c1/Impls_1.scala +++ b/test/files/run/macro-expand-tparams-prefix-c1/Impls_1.scala @@ -5,9 +5,9 @@ object Impls { def foo[T, U: c.WeakTypeTag, V](c: Ctx)(implicit T: c.WeakTypeTag[T], V: c.WeakTypeTag[V]): c.Expr[Unit] = { import c.universe._ c.Expr(Block(List( - Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(T.toString)))), - Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(implicitly[c.WeakTypeTag[U]].toString)))), - Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(V.toString))))), + Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant(T.toString)))), + Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant(implicitly[c.WeakTypeTag[U]].toString)))), + Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant(V.toString))))), Literal(Constant(())))) } }
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-prefix-c2/Impls_Macros_1.scala b/test/files/run/macro-expand-tparams-prefix-c2/Impls_Macros_1.scala index 3c2838208a..08817708d4 100644 --- a/test/files/run/macro-expand-tparams-prefix-c2/Impls_Macros_1.scala +++ b/test/files/run/macro-expand-tparams-prefix-c2/Impls_Macros_1.scala @@ -5,9 +5,9 @@ object Impls { def foo[T, U: c.WeakTypeTag, V](c: Ctx)(implicit T: c.WeakTypeTag[T], V: c.WeakTypeTag[V]): c.Expr[Unit] = { import c.universe._ c.Expr(Block(List( - Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(T.toString)))), - Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(implicitly[c.WeakTypeTag[U]].toString)))), - Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(V.toString))))), + Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant(T.toString)))), + Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant(implicitly[c.WeakTypeTag[U]].toString)))), + Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant(V.toString))))), Literal(Constant(())))) } } diff --git a/test/files/run/macro-expand-tparams-prefix-d1/Impls_1.scala b/test/files/run/macro-expand-tparams-prefix-d1/Impls_1.scala index afdd7d4f7a..2df42e969f 100644 --- a/test/files/run/macro-expand-tparams-prefix-d1/Impls_1.scala +++ b/test/files/run/macro-expand-tparams-prefix-d1/Impls_1.scala @@ -5,9 +5,9 @@ object Impls { def foo[T, U: c.WeakTypeTag, V](c: Ctx)(implicit T: c.WeakTypeTag[T], V: c.WeakTypeTag[V]): c.Expr[Unit] = { import c.universe._ c.Expr(Block(List( - Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(T.toString)))), - Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(implicitly[c.WeakTypeTag[U]].toString)))), - Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(V.toString))))), + Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant(T.toString)))), + Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant(implicitly[c.WeakTypeTag[U]].toString)))), + Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant(V.toString))))), Literal(Constant(())))) } }
\ No newline at end of file diff --git a/test/files/run/macro-expand-unapply-a.check b/test/files/run/macro-expand-unapply-a.check new file mode 100644 index 0000000000..7c2976e51e --- /dev/null +++ b/test/files/run/macro-expand-unapply-a.check @@ -0,0 +1,2 @@ +(1,2) +(1,2,3) diff --git a/test/files/run/macro-expand-unapply-a.flags b/test/files/run/macro-expand-unapply-a.flags new file mode 100644 index 0000000000..cd66464f2f --- /dev/null +++ b/test/files/run/macro-expand-unapply-a.flags @@ -0,0 +1 @@ +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-expand-unapply-a/Impls_Macros_1.scala b/test/files/run/macro-expand-unapply-a/Impls_Macros_1.scala new file mode 100644 index 0000000000..61d6345f16 --- /dev/null +++ b/test/files/run/macro-expand-unapply-a/Impls_Macros_1.scala @@ -0,0 +1,15 @@ +import scala.reflect.macros.Context + +object Helper { + def unapplySeq[T](x: List[T]): Option[Seq[T]] = List.unapplySeq[T](x) +} + +object Macros { + def impl[T: c.WeakTypeTag](c: Context)(x: c.Expr[List[T]]) = { + c.universe.reify(Helper.unapplySeq(x.splice)) + } + + object UnapplyMacro { + def unapplySeq[T](x: List[T]): Option[Seq[T]] = macro impl[T] + } +}
\ No newline at end of file diff --git a/test/files/run/macro-expand-unapply-a/Test_2.scala b/test/files/run/macro-expand-unapply-a/Test_2.scala new file mode 100644 index 0000000000..6169d86b19 --- /dev/null +++ b/test/files/run/macro-expand-unapply-a/Test_2.scala @@ -0,0 +1,6 @@ +import Macros._ + +object Test extends App { + List(1, 2) match { case UnapplyMacro(x, y) => println((x, y)) } + List(1, 2, 3) match { case UnapplyMacro(x, y, z) => println((x, y, z)) } +}
\ No newline at end of file diff --git a/test/files/run/macro-expand-unapply-b.check b/test/files/run/macro-expand-unapply-b.check new file mode 100644 index 0000000000..5272f0d00a --- /dev/null +++ b/test/files/run/macro-expand-unapply-b.check @@ -0,0 +1,2 @@ +(1,List(2)) +List(1) diff --git a/test/files/run/macro-expand-unapply-b.flags b/test/files/run/macro-expand-unapply-b.flags new file mode 100644 index 0000000000..cd66464f2f --- /dev/null +++ b/test/files/run/macro-expand-unapply-b.flags @@ -0,0 +1 @@ +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-expand-unapply-b/Impls_Macros_1.scala b/test/files/run/macro-expand-unapply-b/Impls_Macros_1.scala new file mode 100644 index 0000000000..d0300bdf7e --- /dev/null +++ b/test/files/run/macro-expand-unapply-b/Impls_Macros_1.scala @@ -0,0 +1,37 @@ +import language.experimental.macros +import scala.reflect.macros.Context + +object Macros { + implicit class ContextExtensions(c: StringContext) { + object q { + def unapply(x: Any): Option[Any] = macro impl + } + } + + def impl(c: Context)(x: c.Expr[Any]): c.Expr[Option[Any]] = { + import c.universe._ + import Flag._ + + // parts here will be string literals - static parts of the string interpolation + // e.g. for q"$x, $y" parts will be Literal(Constant("")), Literal(Constant(", ")) and Literal(Constant("")) + val Apply(Select(Select(Apply(_, List(Apply(_, parts))), _), _), _) = c.macroApplication + val nresults = parts.length - 1 + + def results() = + ((1 to (nresults - 1)).toList map (i => Literal(Constant(i)))) :+ // (n - 1) results of type Int + Apply(Ident(TermName("List")), List(Literal(Constant(nresults)))) // and also one result of a different type + def extractorBody() = + if (nresults == 0) Literal(Constant(true)) + else if (nresults == 1) Apply(Ident(TermName("Some")), results()) + else Apply(Ident(TermName("Some")), List(Apply(Ident(TermName("Tuple" + nresults)), results()))) + + val name = TermName(java.util.UUID.randomUUID().toString.replace("-", "")) + val mdef = ModuleDef(NoMods, name, Template(List(Select(Ident(TermName("scala")), TypeName("AnyRef"))), emptyValDef, List( + DefDef(Modifiers(), nme.CONSTRUCTOR, List(), List(List()), TypeTree(), + Block(List(pendingSuperCall), Literal(Constant(())))), + DefDef(Modifiers(), TermName("unapply"), List(), List(List(ValDef(Modifiers(PARAM), TermName("x"), Ident(TypeName("Any")), EmptyTree))), TypeTree(), + extractorBody())))) + c.introduceTopLevel(nme.EMPTY_PACKAGE_NAME.toString, mdef) + c.Expr[Option[Any]](Apply(Select(Ident(name), TermName("unapply")), List(x.tree))) + } +}
\ No newline at end of file diff --git a/test/files/run/macro-expand-unapply-b/Test_2.scala b/test/files/run/macro-expand-unapply-b/Test_2.scala new file mode 100644 index 0000000000..5352160dfe --- /dev/null +++ b/test/files/run/macro-expand-unapply-b/Test_2.scala @@ -0,0 +1,8 @@ +object Test extends App { + import Macros._ + def whatever() = null + val q"$x1, $y1" = whatever() + println(x1, y1) + val q"$x2" = whatever() + println(x2) +} diff --git a/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-bad/Impls_1.scala b/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-bad/Impls_1.scala index 2ef8f04be9..f6c1d27d54 100644 --- a/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-bad/Impls_1.scala +++ b/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-bad/Impls_1.scala @@ -3,7 +3,7 @@ import scala.reflect.macros.{Context => Ctx} object Impls { def foo(c: Ctx)(xs: c.Expr[Int]*) = { import c.universe._ - val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), xs.map(_.tree).toList) + val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), xs.map(_.tree).toList) c.Expr[Unit](body) } }
\ No newline at end of file diff --git a/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-bad/Macros_Test_2.scala b/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-bad/Macros_Test_2.scala index c832826d64..b844012d53 100644 --- a/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-bad/Macros_Test_2.scala +++ b/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-bad/Macros_Test_2.scala @@ -6,7 +6,7 @@ object Test extends App { import scala.reflect.runtime.universe._ import scala.reflect.runtime.{currentMirror => cm} import scala.tools.reflect.ToolBox - val tree = Apply(Select(Ident(newTermName("Macros")), newTermName("foo")), List(Typed(Apply(Ident(definitions.ListModule), List(Literal(Constant(1)), Literal(Constant(2)))), Ident(tpnme.WILDCARD_STAR)))) + val tree = Apply(Select(Ident(TermName("Macros")), TermName("foo")), List(Typed(Apply(Ident(definitions.ListModule), List(Literal(Constant(1)), Literal(Constant(2)))), Ident(tpnme.WILDCARD_STAR)))) try cm.mkToolBox().eval(tree) catch { case ex: Throwable => println(ex.getMessage) } }
\ No newline at end of file diff --git a/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-good/Impls_1.scala b/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-good/Impls_1.scala index 3c7f94f605..363ff0e0aa 100644 --- a/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-good/Impls_1.scala +++ b/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-good/Impls_1.scala @@ -7,7 +7,7 @@ object Impls { case List(Typed(stripped, Ident(wildstar))) if wildstar == tpnme.WILDCARD_STAR => List(stripped) case _ => ??? } - val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), stripped_xs) + val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), stripped_xs) c.Expr[Unit](body) } }
\ No newline at end of file diff --git a/test/files/run/macro-expand-varargs-explicit-over-varargs/Impls_1.scala b/test/files/run/macro-expand-varargs-explicit-over-varargs/Impls_1.scala index 2066893bdc..0b61ab2f9b 100644 --- a/test/files/run/macro-expand-varargs-explicit-over-varargs/Impls_1.scala +++ b/test/files/run/macro-expand-varargs-explicit-over-varargs/Impls_1.scala @@ -7,7 +7,7 @@ object Impls { def foo(c: Ctx)(xs: c.Expr[Int]*) = { import c.universe._ - val body = Apply(Select(Ident(newTermName("Impls")), newTermName("myprintln")), xs.map(_.tree).toList) + val body = Apply(Select(Ident(TermName("Impls")), TermName("myprintln")), xs.map(_.tree).toList) c.Expr[Unit](body) } }
\ No newline at end of file diff --git a/test/files/run/macro-expand-varargs-implicit-over-nonvarargs/Impls_1.scala b/test/files/run/macro-expand-varargs-implicit-over-nonvarargs/Impls_1.scala index 2ef8f04be9..f6c1d27d54 100644 --- a/test/files/run/macro-expand-varargs-implicit-over-nonvarargs/Impls_1.scala +++ b/test/files/run/macro-expand-varargs-implicit-over-nonvarargs/Impls_1.scala @@ -3,7 +3,7 @@ import scala.reflect.macros.{Context => Ctx} object Impls { def foo(c: Ctx)(xs: c.Expr[Int]*) = { import c.universe._ - val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), xs.map(_.tree).toList) + val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), xs.map(_.tree).toList) c.Expr[Unit](body) } }
\ No newline at end of file diff --git a/test/files/run/macro-expand-varargs-implicit-over-varargs/Impls_1.scala b/test/files/run/macro-expand-varargs-implicit-over-varargs/Impls_1.scala index 2066893bdc..0b61ab2f9b 100644 --- a/test/files/run/macro-expand-varargs-implicit-over-varargs/Impls_1.scala +++ b/test/files/run/macro-expand-varargs-implicit-over-varargs/Impls_1.scala @@ -7,7 +7,7 @@ object Impls { def foo(c: Ctx)(xs: c.Expr[Int]*) = { import c.universe._ - val body = Apply(Select(Ident(newTermName("Impls")), newTermName("myprintln")), xs.map(_.tree).toList) + val body = Apply(Select(Ident(TermName("Impls")), TermName("myprintln")), xs.map(_.tree).toList) c.Expr[Unit](body) } }
\ No newline at end of file diff --git a/test/files/run/macro-impl-default-params/Impls_Macros_1.scala b/test/files/run/macro-impl-default-params/Impls_Macros_1.scala index 7c40045c0f..95d746980e 100644 --- a/test/files/run/macro-impl-default-params/Impls_Macros_1.scala +++ b/test/files/run/macro-impl-default-params/Impls_Macros_1.scala @@ -7,10 +7,10 @@ object Impls { import c.universe._ val U = implicitly[c.WeakTypeTag[U]] val body = Block(List( - Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("invoking foo_targs...")))), - Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("type of prefix is: " + prefix.staticType)))), - Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("type of prefix tree is: " + prefix.tree.tpe)))), - Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("U is: " + U.tpe))))), + Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("invoking foo_targs...")))), + Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("type of prefix is: " + prefix.staticType)))), + Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("type of prefix tree is: " + prefix.tree.tpe)))), + Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("U is: " + U.tpe))))), Literal(Constant(()))) c.Expr[Unit](body) } diff --git a/test/files/run/macro-impl-rename-context/Impls_Macros_1.scala b/test/files/run/macro-impl-rename-context/Impls_Macros_1.scala index 56c23f5faf..738c88bbc8 100644 --- a/test/files/run/macro-impl-rename-context/Impls_Macros_1.scala +++ b/test/files/run/macro-impl-rename-context/Impls_Macros_1.scala @@ -4,7 +4,7 @@ object Impls { def foo(unconventionalName: Ctx)(x: unconventionalName.Expr[Int]) = { import unconventionalName.universe._ val body = Block(List( - Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("invoking foo..."))))), + Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("invoking foo..."))))), Literal(Constant(()))) unconventionalName.Expr[Unit](body) } diff --git a/test/files/run/macro-invalidret-doesnt-conform-to-def-rettype/Test_2.scala b/test/files/run/macro-invalidret-doesnt-conform-to-def-rettype/Test_2.scala index 0b9986e9f6..61f0bdfadc 100644 --- a/test/files/run/macro-invalidret-doesnt-conform-to-def-rettype/Test_2.scala +++ b/test/files/run/macro-invalidret-doesnt-conform-to-def-rettype/Test_2.scala @@ -2,7 +2,7 @@ object Test extends App { import scala.reflect.runtime.universe._ import scala.reflect.runtime.{currentMirror => cm} import scala.tools.reflect.ToolBox - val tree = Select(Ident(newTermName("Macros")), newTermName("foo")) + val tree = Select(Ident(TermName("Macros")), TermName("foo")) try cm.mkToolBox().eval(tree) catch { case ex: Throwable => println(ex.getMessage) } }
\ No newline at end of file diff --git a/test/files/run/macro-invalidret-nontypeable/Impls_Macros_1.scala b/test/files/run/macro-invalidret-nontypeable/Impls_Macros_1.scala index fb0d55208c..869a5a41fa 100644 --- a/test/files/run/macro-invalidret-nontypeable/Impls_Macros_1.scala +++ b/test/files/run/macro-invalidret-nontypeable/Impls_Macros_1.scala @@ -3,7 +3,7 @@ import scala.reflect.macros.{Context => Ctx} object Impls { def foo(c: Ctx) = { import c.universe._ - val body = Ident(newTermName("IDoNotExist")) + val body = Ident(TermName("IDoNotExist")) c.Expr[Int](body) } } diff --git a/test/files/run/macro-invalidret-nontypeable/Test_2.scala b/test/files/run/macro-invalidret-nontypeable/Test_2.scala index 0daee49a08..7cd474ff52 100644 --- a/test/files/run/macro-invalidret-nontypeable/Test_2.scala +++ b/test/files/run/macro-invalidret-nontypeable/Test_2.scala @@ -2,7 +2,7 @@ import scala.reflect.runtime.universe._ import scala.reflect.runtime.{currentMirror => cm} import scala.tools.reflect.ToolBox - val tree = Select(Ident(newTermName("Macros")), newTermName("foo")) + val tree = Select(Ident(TermName("Macros")), TermName("foo")) try cm.mkToolBox().eval(tree) catch { case ex: Throwable => println(ex.getMessage) } }
\ No newline at end of file diff --git a/test/files/run/macro-invalidusage-badret/Test_2.scala b/test/files/run/macro-invalidusage-badret/Test_2.scala index 5cb0be5ddd..fc71353f54 100644 --- a/test/files/run/macro-invalidusage-badret/Test_2.scala +++ b/test/files/run/macro-invalidusage-badret/Test_2.scala @@ -2,7 +2,7 @@ object Test extends App { import scala.reflect.runtime.universe._ import scala.reflect.runtime.{currentMirror => cm} import scala.tools.reflect.ToolBox - val tree = Typed(Apply(Select(Ident(newTermName("Macros")), newTermName("foo")), List(Literal(Constant(42)))), Ident(newTypeName("String"))) + val tree = Typed(Apply(Select(Ident(TermName("Macros")), TermName("foo")), List(Literal(Constant(42)))), Ident(TypeName("String"))) try cm.mkToolBox().eval(tree) catch { case ex: Throwable => println(ex.getMessage) } } diff --git a/test/files/run/macro-invalidusage-partialapplication-with-tparams/Impls_Macros_1.scala b/test/files/run/macro-invalidusage-partialapplication-with-tparams/Impls_Macros_1.scala index 4583a726cf..8a93161af5 100644 --- a/test/files/run/macro-invalidusage-partialapplication-with-tparams/Impls_Macros_1.scala +++ b/test/files/run/macro-invalidusage-partialapplication-with-tparams/Impls_Macros_1.scala @@ -3,7 +3,7 @@ import scala.reflect.macros.{Context => Ctx} object Impls { def foo[T: c.WeakTypeTag](c: Ctx)(x: c.Expr[T]) = { import c.universe._ - val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(x.tree.toString)))) + val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant(x.tree.toString)))) c.Expr[Unit](body) } } diff --git a/test/files/run/macro-invalidusage-partialapplication-with-tparams/Test_2.scala b/test/files/run/macro-invalidusage-partialapplication-with-tparams/Test_2.scala index e453d0b70c..9a34c62e0f 100644 --- a/test/files/run/macro-invalidusage-partialapplication-with-tparams/Test_2.scala +++ b/test/files/run/macro-invalidusage-partialapplication-with-tparams/Test_2.scala @@ -2,7 +2,7 @@ object Test extends App { import scala.reflect.runtime.universe._ import scala.reflect.runtime.{currentMirror => cm} import scala.tools.reflect.ToolBox - val tree = Select(Ident(newTermName("Macros")), newTermName("foo")) + val tree = Select(Ident(TermName("Macros")), TermName("foo")) try cm.mkToolBox().eval(tree) catch { case ex: Throwable => println(ex.getMessage) } } diff --git a/test/files/run/macro-invalidusage-partialapplication/Impls_Macros_1.scala b/test/files/run/macro-invalidusage-partialapplication/Impls_Macros_1.scala index 5866469499..3ac9cd2a8d 100644 --- a/test/files/run/macro-invalidusage-partialapplication/Impls_Macros_1.scala +++ b/test/files/run/macro-invalidusage-partialapplication/Impls_Macros_1.scala @@ -3,8 +3,8 @@ import scala.reflect.macros.{Context => Ctx} object Impls { def foo(c: Ctx)(x: c.Expr[Int])(y: c.Expr[Int]) = { import c.universe._ - val sum = Apply(Select(x.tree, newTermName("$plus")), List(y.tree)) - val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(sum)) + val sum = Apply(Select(x.tree, TermName("$plus")), List(y.tree)) + val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(sum)) c.Expr[Unit](body) } } diff --git a/test/files/run/macro-invalidusage-partialapplication/Test_2.scala b/test/files/run/macro-invalidusage-partialapplication/Test_2.scala index dc48c127f4..75b8c139d4 100644 --- a/test/files/run/macro-invalidusage-partialapplication/Test_2.scala +++ b/test/files/run/macro-invalidusage-partialapplication/Test_2.scala @@ -2,7 +2,7 @@ object Test extends App { import scala.reflect.runtime.universe._ import scala.reflect.runtime.{currentMirror => cm} import scala.tools.reflect.ToolBox - val tree = Apply(Select(Ident(newTermName("Macros")), newTermName("foo")), List(Literal(Constant(40)))) + val tree = Apply(Select(Ident(TermName("Macros")), TermName("foo")), List(Literal(Constant(40)))) try cm.mkToolBox().eval(tree) catch { case ex: Throwable => println(ex.getMessage) } } diff --git a/test/files/run/macro-openmacros/Impls_Macros_1.scala b/test/files/run/macro-openmacros/Impls_Macros_1.scala index b863ac048b..50a1782431 100644 --- a/test/files/run/macro-openmacros/Impls_Macros_1.scala +++ b/test/files/run/macro-openmacros/Impls_Macros_1.scala @@ -14,7 +14,7 @@ object Macros { } import c.universe._ - val next = if (c.enclosingMacros.length < 3) c.Expr[Unit](Select(Ident(c.mirror.staticModule("Macros")), newTermName("foo"))) else c.literalUnit + val next = if (c.enclosingMacros.length < 3) c.Expr[Unit](Select(Ident(c.mirror.staticModule("Macros")), TermName("foo"))) else c.literalUnit c.universe.reify { println(c.literal(normalizePaths(c.enclosingMacros.toString)).splice) next.splice diff --git a/test/files/run/macro-range/Common_1.scala b/test/files/run/macro-range/Common_1.scala index 5c4bc211fc..4083e6126e 100644 --- a/test/files/run/macro-range/Common_1.scala +++ b/test/files/run/macro-range/Common_1.scala @@ -43,5 +43,5 @@ abstract class Utils { LabelDef(lname, Nil, rhs) } def makeBinop(left: Tree, op: String, right: Tree): Tree = - Apply(Select(left, newTermName(op)), List(right)) + Apply(Select(left, TermName(op)), List(right)) } diff --git a/test/files/run/macro-range/Expansion_Impossible_2.scala b/test/files/run/macro-range/Expansion_Impossible_2.scala index 57e0cee97f..ca0db48822 100644 --- a/test/files/run/macro-range/Expansion_Impossible_2.scala +++ b/test/files/run/macro-range/Expansion_Impossible_2.scala @@ -16,11 +16,11 @@ object Impls { // scala"($_this: RangeDefault).foreach($f)" c.Expr(c.prefix.tree match { case Apply(Select(New(tpt), initName), List(lo, hi)) if tpt.symbol.fullName == "Range" => - val iname = newTermName("$i") - val hname = newTermName("$h") + val iname = TermName("$i") + val hname = TermName("$h") def iref = Ident(iname) def href = Ident(hname) - val labelname = newTermName("$while") + val labelname = TermName("$while") val cond = makeBinop(iref, "$less", href) val body = Block( List(makeApply(f.tree, List(iref))), @@ -37,8 +37,8 @@ object Impls { case _ => Apply( Select( - Typed(c.prefix.tree, Ident(newTypeName("RangeDefault"))), - newTermName("foreach")), + Typed(c.prefix.tree, Ident(TypeName("RangeDefault"))), + TermName("foreach")), List(f.tree)) }) } diff --git a/test/files/run/macro-reflective-ma-normal-mdmi/Impls_Macros_1.scala b/test/files/run/macro-reflective-ma-normal-mdmi/Impls_Macros_1.scala index fa559334d4..51e0264ed5 100644 --- a/test/files/run/macro-reflective-ma-normal-mdmi/Impls_Macros_1.scala +++ b/test/files/run/macro-reflective-ma-normal-mdmi/Impls_Macros_1.scala @@ -3,7 +3,7 @@ import scala.reflect.macros.{Context => Ctx} object Impls { def foo(c: Ctx)(x: c.Expr[Int]) = { import c.universe._ - val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(1)))) + val body = Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(1)))) c.Expr[Int](body) } } diff --git a/test/files/run/macro-reflective-ma-normal-mdmi/Test_2.scala b/test/files/run/macro-reflective-ma-normal-mdmi/Test_2.scala index 2e64c01e35..267d1bc7b0 100644 --- a/test/files/run/macro-reflective-ma-normal-mdmi/Test_2.scala +++ b/test/files/run/macro-reflective-ma-normal-mdmi/Test_2.scala @@ -2,6 +2,6 @@ object Test extends App { import scala.reflect.runtime.universe._ import scala.reflect.runtime.{currentMirror => cm} import scala.tools.reflect.ToolBox - val tree = Apply(Select(Ident(newTermName("Macros")), newTermName("foo")), List(Literal(Constant(42)))) + val tree = Apply(Select(Ident(TermName("Macros")), TermName("foo")), List(Literal(Constant(42)))) println(cm.mkToolBox().eval(tree)) } diff --git a/test/files/run/macro-reflective-mamd-normal-mi/Impls_1.scala b/test/files/run/macro-reflective-mamd-normal-mi/Impls_1.scala index 5d7e077731..4261a6d45d 100644 --- a/test/files/run/macro-reflective-mamd-normal-mi/Impls_1.scala +++ b/test/files/run/macro-reflective-mamd-normal-mi/Impls_1.scala @@ -3,7 +3,7 @@ import scala.reflect.macros.{Context => Ctx} object Impls { def foo(c: Ctx)(x: c.Expr[Int]) = { import c.universe._ - val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(1)))) + val body = Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(1)))) c.Expr[Int](body) } }
\ No newline at end of file diff --git a/test/files/run/macro-reflective-mamd-normal-mi/Macros_Test_2.scala b/test/files/run/macro-reflective-mamd-normal-mi/Macros_Test_2.scala index 70560009b1..13cd953bde 100644 --- a/test/files/run/macro-reflective-mamd-normal-mi/Macros_Test_2.scala +++ b/test/files/run/macro-reflective-mamd-normal-mi/Macros_Test_2.scala @@ -8,12 +8,12 @@ object Test extends App { import scala.reflect.runtime.{currentMirror => cm} import scala.tools.reflect.ToolBox - val macrobody = Select(Ident(newTermName("Impls")), newTermName("foo")) - val macroparam = ValDef(NoMods, newTermName("x"), TypeTree(definitions.IntClass.toType), EmptyTree) - val macrodef = DefDef(Modifiers(MACRO), newTermName("foo"), Nil, List(List(macroparam)), TypeTree(), macrobody) + val macrobody = Select(Ident(TermName("Impls")), TermName("foo")) + val macroparam = ValDef(NoMods, TermName("x"), TypeTree(definitions.IntClass.toType), EmptyTree) + val macrodef = DefDef(Modifiers(MACRO), TermName("foo"), Nil, List(List(macroparam)), TypeTree(), macrobody) val modulector = DefDef(NoMods, nme.CONSTRUCTOR, Nil, List(List()), TypeTree(), Block(List(Apply(Select(Super(This(tpnme.EMPTY), tpnme.EMPTY), nme.CONSTRUCTOR), List())), Literal(Constant(())))) - val module = ModuleDef(NoMods, newTermName("Macros"), Template(Nil, emptyValDef, List(modulector, macrodef))) - val macroapp = Apply(Select(Ident(newTermName("Macros")), newTermName("foo")), List(Literal(Constant(42)))) + val module = ModuleDef(NoMods, TermName("Macros"), Template(Nil, emptyValDef, List(modulector, macrodef))) + val macroapp = Apply(Select(Ident(TermName("Macros")), TermName("foo")), List(Literal(Constant(42)))) val tree = Block(List(macrodef, module), macroapp) val toolbox = cm.mkToolBox(options = "-language:experimental.macros") println(toolbox.eval(tree)) diff --git a/test/files/run/macro-reify-freevars/Test_2.scala b/test/files/run/macro-reify-freevars/Test_2.scala index 7af9d89bdb..c2d0118e17 100644 --- a/test/files/run/macro-reify-freevars/Test_2.scala +++ b/test/files/run/macro-reify-freevars/Test_2.scala @@ -2,10 +2,10 @@ object Test extends App { import scala.reflect.runtime.universe._ import scala.reflect.runtime.{currentMirror => cm} import scala.tools.reflect.ToolBox - val q = New(AppliedTypeTree(Select(Select(Select(Ident(newTermName("scala")), newTermName("collection")), newTermName("slick")), newTypeName("Queryable")), List(Ident(newTermName("Int"))))) - val x = ValDef(NoMods, newTermName("x"), Ident(newTermName("Int")), EmptyTree) - val fn = Function(List(x), Apply(Select(Ident(newTermName("x")), newTermName("$plus")), List(Literal(Constant("5"))))) - val tree = Apply(Select(q, newTermName("map")), List(fn)) + val q = New(AppliedTypeTree(Select(Select(Select(Ident(TermName("scala")), TermName("collection")), TermName("slick")), TypeName("Queryable")), List(Ident(TermName("Int"))))) + val x = ValDef(NoMods, TermName("x"), Ident(TermName("Int")), EmptyTree) + val fn = Function(List(x), Apply(Select(Ident(TermName("x")), TermName("$plus")), List(Literal(Constant("5"))))) + val tree = Apply(Select(q, TermName("map")), List(fn)) try cm.mkToolBox().eval(tree) catch { case ex: Throwable => println(ex.getMessage) } }
\ No newline at end of file diff --git a/test/files/run/macro-reify-nested-a/Impls_Macros_1.scala b/test/files/run/macro-reify-nested-a/Impls_Macros_1.scala index b4351c2c53..bb6a45e11e 100644 --- a/test/files/run/macro-reify-nested-a/Impls_Macros_1.scala +++ b/test/files/run/macro-reify-nested-a/Impls_Macros_1.scala @@ -28,7 +28,7 @@ object QueryableMacros{ val foo = c.Expr[ru.Expr[Queryable[S]]]( c.reifyTree( mkRuntimeUniverseRef, EmptyTree, c.typeCheck( Utils[c.type](c).removeDoubleReify( - Apply(Select(c.prefix.tree, newTermName( name )), List( projection.tree )) + Apply(Select(c.prefix.tree, TermName( name )), List( projection.tree )) ).asInstanceOf[Tree] ))) c.universe.reify{ Queryable.factory[S]( foo.splice )} diff --git a/test/files/run/macro-reify-nested-b/Impls_Macros_1.scala b/test/files/run/macro-reify-nested-b/Impls_Macros_1.scala index b4351c2c53..bb6a45e11e 100644 --- a/test/files/run/macro-reify-nested-b/Impls_Macros_1.scala +++ b/test/files/run/macro-reify-nested-b/Impls_Macros_1.scala @@ -28,7 +28,7 @@ object QueryableMacros{ val foo = c.Expr[ru.Expr[Queryable[S]]]( c.reifyTree( mkRuntimeUniverseRef, EmptyTree, c.typeCheck( Utils[c.type](c).removeDoubleReify( - Apply(Select(c.prefix.tree, newTermName( name )), List( projection.tree )) + Apply(Select(c.prefix.tree, TermName( name )), List( projection.tree )) ).asInstanceOf[Tree] ))) c.universe.reify{ Queryable.factory[S]( foo.splice )} diff --git a/test/files/run/macro-reify-splice-outside-reify/Test_2.scala b/test/files/run/macro-reify-splice-outside-reify/Test_2.scala index 54bd03fcd2..dbc17e7c15 100644 --- a/test/files/run/macro-reify-splice-outside-reify/Test_2.scala +++ b/test/files/run/macro-reify-splice-outside-reify/Test_2.scala @@ -2,7 +2,7 @@ object Test extends App { import scala.reflect.runtime.universe._ import scala.reflect.runtime.{currentMirror => cm} import scala.tools.reflect.ToolBox - val tree = Apply(Select(Ident(newTermName("Macros")), newTermName("foo")), List(Literal(Constant(42)))) + val tree = Apply(Select(Ident(TermName("Macros")), TermName("foo")), List(Literal(Constant(42)))) try println(cm.mkToolBox().eval(tree)) catch { case ex: Throwable => println(ex.getMessage) } } diff --git a/test/files/run/macro-reify-tagless-a/Test_2.scala b/test/files/run/macro-reify-tagless-a/Test_2.scala index 584c4bdf5b..afb418a755 100644 --- a/test/files/run/macro-reify-tagless-a/Test_2.scala +++ b/test/files/run/macro-reify-tagless-a/Test_2.scala @@ -6,9 +6,9 @@ object Test extends App { import scala.reflect.runtime.{currentMirror => cm} import scala.tools.reflect.ToolBox val tpt = AppliedTypeTree(Ident(definitions.ListClass), List(Ident(definitions.StringClass))) - val rhs = Apply(Select(Ident(newTermName("Macros")), newTermName("foo")), List(Literal(Constant("hello world")))) - val list = ValDef(NoMods, newTermName("list"), tpt, rhs) - val tree = Block(List(list), Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Ident(list.name)))) + val rhs = Apply(Select(Ident(TermName("Macros")), TermName("foo")), List(Literal(Constant("hello world")))) + val list = ValDef(NoMods, TermName("list"), tpt, rhs) + val tree = Block(List(list), Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Ident(list.name)))) try cm.mkToolBox().eval(tree) catch { case ex: Throwable => println(ex.getMessage) } } diff --git a/test/files/run/macro-reify-type/Macros_1.scala b/test/files/run/macro-reify-type/Macros_1.scala index 06de05735d..c4d1d9f8ad 100644 --- a/test/files/run/macro-reify-type/Macros_1.scala +++ b/test/files/run/macro-reify-type/Macros_1.scala @@ -8,7 +8,7 @@ object StaticReflect { import c.universe._ val nameName: TermName = name.tree match { - case Literal(Constant(str: String)) => newTermName(str) + case Literal(Constant(str: String)) => TermName(str) case _ => c.error(c.enclosingPosition, s"Method name not constant.") ; return reify(ru.NoType) } val clazz = weakTypeOf[A] @@ -17,8 +17,8 @@ object StaticReflect { case NoSymbol => c.error(c.enclosingPosition, s"No member called $nameName in $clazz.") ; reify(ru.NoType) case member => val mtpe = member typeSignatureIn clazz - val mtag = c.reifyType(treeBuild.mkRuntimeUniverseRef, Select(treeBuild.mkRuntimeUniverseRef, newTermName("rootMirror")), mtpe) - val mtree = Select(mtag, newTermName("tpe")) + val mtag = c.reifyType(treeBuild.mkRuntimeUniverseRef, Select(treeBuild.mkRuntimeUniverseRef, TermName("rootMirror")), mtpe) + val mtree = Select(mtag, TermName("tpe")) c.Expr[ru.Type](mtree) } diff --git a/test/files/run/macro-reify-type/Test_2.scala b/test/files/run/macro-reify-type/Test_2.scala index 9beaf98681..1f35973531 100644 --- a/test/files/run/macro-reify-type/Test_2.scala +++ b/test/files/run/macro-reify-type/Test_2.scala @@ -7,10 +7,10 @@ object Test extends App { //val $m: $u.Mirror = scala.reflect.runtime.universe.rootMirror; //import $u._, $m._, Flag._ //val tpe = { - // val symdef$B2 = build.newNestedSymbol(build.selectTerm(staticClass("scala.collection.TraversableLike"), "map"), newTypeName("B"), NoPosition, DEFERRED | PARAM, false); - // val symdef$That2 = build.newNestedSymbol(build.selectTerm(staticClass("scala.collection.TraversableLike"), "map"), newTypeName("That"), NoPosition, DEFERRED | PARAM, false); - // val symdef$f2 = build.newNestedSymbol(build.selectTerm(staticClass("scala.collection.TraversableLike"), "map"), newTermName("f"), NoPosition, PARAM, false); - // val symdef$bf2 = build.newNestedSymbol(build.selectTerm(staticClass("scala.collection.TraversableLike"), "map"), newTermName("bf"), NoPosition, IMPLICIT | PARAM, false); + // val symdef$B2 = build.newNestedSymbol(build.selectTerm(staticClass("scala.collection.TraversableLike"), "map"), TypeName("B"), NoPosition, DEFERRED | PARAM, false); + // val symdef$That2 = build.newNestedSymbol(build.selectTerm(staticClass("scala.collection.TraversableLike"), "map"), TypeName("That"), NoPosition, DEFERRED | PARAM, false); + // val symdef$f2 = build.newNestedSymbol(build.selectTerm(staticClass("scala.collection.TraversableLike"), "map"), TermName("f"), NoPosition, PARAM, false); + // val symdef$bf2 = build.newNestedSymbol(build.selectTerm(staticClass("scala.collection.TraversableLike"), "map"), TermName("bf"), NoPosition, IMPLICIT | PARAM, false); // build.setTypeSignature(symdef$B2, TypeBounds(staticClass("scala.Nothing").asType.toTypeConstructor, staticClass("scala.Any").asType.toTypeConstructor)); // build.setTypeSignature(symdef$That2, TypeBounds(staticClass("scala.Nothing").asType.toTypeConstructor, staticClass("scala.Any").asType.toTypeConstructor)); // build.setTypeSignature(symdef$f2, TypeRef(ThisType(staticPackage("scala").asModule.moduleClass), staticClass("scala.Function1"), List(staticClass("scala.Int").asType.toTypeConstructor, TypeRef(NoPrefix, symdef$B2, List())))); diff --git a/test/files/run/macro-reify-unreify/Macros_1.scala b/test/files/run/macro-reify-unreify/Macros_1.scala index 9f04c13014..25ed352cca 100644 --- a/test/files/run/macro-reify-unreify/Macros_1.scala +++ b/test/files/run/macro-reify-unreify/Macros_1.scala @@ -9,7 +9,7 @@ object Macros { import treeBuild._ val world = c.reifyTree(mkRuntimeUniverseRef, EmptyTree, s.tree) - val greeting = c.reifyTree(mkRuntimeUniverseRef, EmptyTree, c.typeCheck(Apply(Select(Literal(Constant("hello ")), newTermName("$plus")), List(c.unreifyTree(world))))) + val greeting = c.reifyTree(mkRuntimeUniverseRef, EmptyTree, c.typeCheck(Apply(Select(Literal(Constant("hello ")), TermName("$plus")), List(c.unreifyTree(world))))) val typedGreeting = c.Expr[String](greeting) c.universe.reify { diff --git a/test/files/run/macro-repl-basic.check b/test/files/run/macro-repl-basic.check index 7deed4a878..8d43a3aa16 100644 --- a/test/files/run/macro-repl-basic.check +++ b/test/files/run/macro-repl-basic.check @@ -14,23 +14,23 @@ scala> scala> object Impls { def foo(c: Ctx)(x: c.Expr[Int]) = { import c.universe._ - val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(1)))) + val body = Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(1)))) c.Expr[Int](body) } def bar(c: Ctx)(x: c.Expr[Int]) = { import c.universe._ - val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(2)))) + val body = Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(2)))) c.Expr[Int](body) } def quux(c: Ctx)(x: c.Expr[Int]) = { import c.universe._ - val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(3)))) + val body = Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(3)))) c.Expr[Int](body) } } -defined module Impls +defined object Impls scala> object Macros { object Shmacros { @@ -40,7 +40,7 @@ scala> object Macros { }; class Macros { def quux(x: Int): Int = macro Impls.quux } -defined module Macros +defined object Macros defined class Macros scala> diff --git a/test/files/run/macro-repl-basic.scala b/test/files/run/macro-repl-basic.scala index eae1febb3a..3c22c13dc7 100644 --- a/test/files/run/macro-repl-basic.scala +++ b/test/files/run/macro-repl-basic.scala @@ -8,19 +8,19 @@ object Test extends ReplTest { |object Impls { | def foo(c: Ctx)(x: c.Expr[Int]) = { | import c.universe._ - | val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(1)))) + | val body = Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(1)))) | c.Expr[Int](body) | } | | def bar(c: Ctx)(x: c.Expr[Int]) = { | import c.universe._ - | val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(2)))) + | val body = Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(2)))) | c.Expr[Int](body) | } | | def quux(c: Ctx)(x: c.Expr[Int]) = { | import c.universe._ - | val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(3)))) + | val body = Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(3)))) | c.Expr[Int](body) | } |} diff --git a/test/files/run/macro-repl-dontexpand.check b/test/files/run/macro-repl-dontexpand.check index 628a9146c4..99b70ea3dc 100644 --- a/test/files/run/macro-repl-dontexpand.check +++ b/test/files/run/macro-repl-dontexpand.check @@ -7,6 +7,6 @@ scala> def bar(c: scala.reflect.macros.Context) = ??? bar: (c: scala.reflect.macros.Context)Nothing scala> def foo = macro bar -foo: Any +defined term macro foo: Any scala> diff --git a/test/files/run/macro-toplevel-companion-a.check b/test/files/run/macro-toplevel-companion-a.check new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/files/run/macro-toplevel-companion-a.check diff --git a/test/files/run/macro-toplevel-companion-a.flags b/test/files/run/macro-toplevel-companion-a.flags new file mode 100644 index 0000000000..cd66464f2f --- /dev/null +++ b/test/files/run/macro-toplevel-companion-a.flags @@ -0,0 +1 @@ +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-toplevel-companion-a/Impls_Macros_1.scala b/test/files/run/macro-toplevel-companion-a/Impls_Macros_1.scala new file mode 100644 index 0000000000..23e8694ddc --- /dev/null +++ b/test/files/run/macro-toplevel-companion-a/Impls_Macros_1.scala @@ -0,0 +1,14 @@ +import scala.reflect.macros.Context +import language.experimental.macros + +object Macros { + def impl(c: Context) = { + import c.universe._ + val synthetic = reify{ class C { override def toString = "C" }; object C { implicit val c = new C } }.tree + val defs = synthetic.asInstanceOf[Block].stats.asInstanceOf[List[ImplDef]] + if (c.topLevelRef(TypeName("C")).isEmpty) c.introduceTopLevel(nme.EMPTY_PACKAGE_NAME.toString, defs: _*) + c.literalUnit + } + + def foo = macro impl +}
\ No newline at end of file diff --git a/test/files/run/macro-toplevel-companion-a/Test_2.scala b/test/files/run/macro-toplevel-companion-a/Test_2.scala new file mode 100644 index 0000000000..78b65b5b1f --- /dev/null +++ b/test/files/run/macro-toplevel-companion-a/Test_2.scala @@ -0,0 +1,8 @@ +import Macros._ + +object Test extends App { + foo; + implicitly[C]; + foo; + implicitly[C]; +}
\ No newline at end of file diff --git a/test/files/run/macro-toplevel-companion-b.check b/test/files/run/macro-toplevel-companion-b.check new file mode 100644 index 0000000000..bd30dc75d3 --- /dev/null +++ b/test/files/run/macro-toplevel-companion-b.check @@ -0,0 +1,4 @@ +reflective compilation has failed: + +Companions 'class C' and 'object C' must be defined in same file: + Found in <synthetic file name> and <synthetic file name> diff --git a/test/files/run/macro-toplevel-companion-b.flags b/test/files/run/macro-toplevel-companion-b.flags new file mode 100644 index 0000000000..cd66464f2f --- /dev/null +++ b/test/files/run/macro-toplevel-companion-b.flags @@ -0,0 +1 @@ +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-toplevel-companion-b/Impls_Macros_1.scala b/test/files/run/macro-toplevel-companion-b/Impls_Macros_1.scala new file mode 100644 index 0000000000..f30adc2965 --- /dev/null +++ b/test/files/run/macro-toplevel-companion-b/Impls_Macros_1.scala @@ -0,0 +1,15 @@ +import scala.reflect.macros.Context +import language.experimental.macros + +object Macros { + def impl(c: Context) = { + import c.universe._ + val Block(List(cdef: ClassDef), _) = reify{ class C }.tree + val classRef = c.topLevelRef(TypeName("C")) orElse c.introduceTopLevel(nme.EMPTY_PACKAGE_NAME.toString, cdef) + val Block(List(mdef: ModuleDef), _) = reify{ object C }.tree + val moduleRef = c.topLevelRef(TermName("C")) orElse c.introduceTopLevel(nme.EMPTY_PACKAGE_NAME.toString, mdef) + c.literalUnit + } + + def foo = macro impl +}
\ No newline at end of file diff --git a/test/files/run/macro-toplevel-companion-b/Test_2.scala b/test/files/run/macro-toplevel-companion-b/Test_2.scala new file mode 100644 index 0000000000..ca202d053f --- /dev/null +++ b/test/files/run/macro-toplevel-companion-b/Test_2.scala @@ -0,0 +1,11 @@ +import scala.reflect.runtime.universe._ +import scala.reflect.runtime.{universe => ru} +import scala.reflect.runtime.{currentMirror => cm} +import scala.tools.reflect.{ToolBox, ToolBoxError} +import Macros._ + +object Test extends App { + val tb = cm.mkToolBox() + try tb.compile(Select(Ident(TermName("Macros")), TermName("foo"))) + catch { case ToolBoxError(message, _) => println("""macroSynthetic-.*?\.scala""".r.replaceAllIn(message, "<synthetic file name>")) } +}
\ No newline at end of file diff --git a/test/files/run/macro-toplevel-companion-c.check b/test/files/run/macro-toplevel-companion-c.check new file mode 100644 index 0000000000..8b422c2061 --- /dev/null +++ b/test/files/run/macro-toplevel-companion-c.check @@ -0,0 +1,3 @@ +error: Companions 'class C' and 'object C' must be defined in same file: + Found in <synthetic file name> and newSource1 + diff --git a/test/files/run/macro-toplevel-companion-c.flags b/test/files/run/macro-toplevel-companion-c.flags new file mode 100644 index 0000000000..cd66464f2f --- /dev/null +++ b/test/files/run/macro-toplevel-companion-c.flags @@ -0,0 +1 @@ +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-toplevel-companion-c.scala b/test/files/run/macro-toplevel-companion-c.scala new file mode 100644 index 0000000000..0e99903158 --- /dev/null +++ b/test/files/run/macro-toplevel-companion-c.scala @@ -0,0 +1,51 @@ +import scala.tools.partest._ +import java.io._ + +object Test extends DirectTest { + def code = ??? + + def macros_1 = """ + package test + + import scala.reflect.macros.Context + import language.experimental.macros + + object Macros { + def impl(c: Context) = { + import c.universe._ + val Block(List(cdef: ClassDef), _) = reify{ class C }.tree + val ref = c.topLevelRef(TypeName("test.C")) orElse c.introduceTopLevel("test", cdef) + c.literalUnit + } + + def foo = macro impl + } + """ + def compileMacros() = { + val classpath = List(sys.props("partest.lib"), sys.props("partest.reflect")) mkString sys.props("path.separator") + compileString(newCompiler("-language:experimental.macros", "-cp", classpath, "-d", testOutput.path))(macros_1) + } + + def test_2 = """ + package test + object C { Macros.foo } + """ + def compileTest() = { + val classpath = List(sys.props("partest.lib"), testOutput.path) mkString sys.props("path.separator") + compileString(newCompiler("-cp", classpath, "-d", testOutput.path))(test_2) + } + + def show(): Unit = { + // redirect err to string, for logging + val prevErr = System.err + val baos = new ByteArrayOutputStream() + System.setErr(new PrintStream(baos)) + log("Compiling Macros_1...") + if (compileMacros()) { + log("Compiling Test_2...") + if (compileTest()) log("Success!") else log("Failed...") + } + println("""macroSynthetic-.*?\.scala""".r.replaceAllIn(baos.toString, "<synthetic file name>")) + System.setErr(prevErr) + } +}
\ No newline at end of file diff --git a/test/files/run/macro-toplevel.check b/test/files/run/macro-toplevel.check new file mode 100644 index 0000000000..257c3764fd --- /dev/null +++ b/test/files/run/macro-toplevel.check @@ -0,0 +1,2 @@ +I've been created from Macros.foo +I've been created from Macros.foo diff --git a/test/files/run/macro-toplevel/Macros_1.scala b/test/files/run/macro-toplevel/Macros_1.scala new file mode 100644 index 0000000000..f681c86735 --- /dev/null +++ b/test/files/run/macro-toplevel/Macros_1.scala @@ -0,0 +1,15 @@ +import scala.reflect.macros.Context +import language.experimental.macros + +object Macros { + def impl(c: Context) = { + import c.universe._ + val msg = "I've been created from " + c.macroApplication + val Block(List(synthetic: ClassDef), _) = reify{ class SomeUniqueName { def hello = c.literal(msg).splice } }.tree + val ref = c.topLevelRef(synthetic.name) orElse c.introduceTopLevel(nme.EMPTY_PACKAGE_NAME.toString, synthetic) + c.Expr[String](Select(Apply(Select(New(ref), nme.CONSTRUCTOR), List()), TermName("hello"))) + } + + def foo = macro impl + def foo2 = macro impl +} diff --git a/test/files/run/macro-toplevel/Test_2.scala b/test/files/run/macro-toplevel/Test_2.scala new file mode 100644 index 0000000000..eee2d6ae13 --- /dev/null +++ b/test/files/run/macro-toplevel/Test_2.scala @@ -0,0 +1,6 @@ +import Macros._ + +object Test extends App { + println(Macros.foo) + println(Macros.foo2) +}
\ No newline at end of file diff --git a/test/files/run/macro-typecheck-implicitsdisabled/Impls_Macros_1.scala b/test/files/run/macro-typecheck-implicitsdisabled/Impls_Macros_1.scala index 633cb930fc..dbeb7efbc0 100644 --- a/test/files/run/macro-typecheck-implicitsdisabled/Impls_Macros_1.scala +++ b/test/files/run/macro-typecheck-implicitsdisabled/Impls_Macros_1.scala @@ -4,7 +4,7 @@ object Macros { def impl_with_implicits_enabled(c: Context) = { import c.universe._ - val tree1 = Apply(Select(Literal(Constant(1)), newTermName("$minus$greater")), List(Literal(Constant(2)))) + val tree1 = Apply(Select(Literal(Constant(1)), TermName("$minus$greater")), List(Literal(Constant(2)))) val ttree1 = c.typeCheck(tree1, withImplicitViewsDisabled = false) c.literal(ttree1.toString) } @@ -15,7 +15,7 @@ object Macros { import c.universe._ try { - val tree2 = Apply(Select(Literal(Constant(1)), newTermName("$minus$greater")), List(Literal(Constant(2)))) + val tree2 = Apply(Select(Literal(Constant(1)), TermName("$minus$greater")), List(Literal(Constant(2)))) val ttree2 = c.typeCheck(tree2, withImplicitViewsDisabled = true) c.literal(ttree2.toString) } catch { diff --git a/test/files/run/macro-typecheck-macrosdisabled/Impls_Macros_1.scala b/test/files/run/macro-typecheck-macrosdisabled/Impls_Macros_1.scala index f693ad78cc..ff535fea8d 100644 --- a/test/files/run/macro-typecheck-macrosdisabled/Impls_Macros_1.scala +++ b/test/files/run/macro-typecheck-macrosdisabled/Impls_Macros_1.scala @@ -4,8 +4,8 @@ object Macros { def impl_with_macros_enabled(c: Context) = { import c.universe._ - val ru = Select(Select(Select(Select(Ident(newTermName("scala")), newTermName("reflect")), newTermName("runtime")), newTermName("package")), newTermName("universe")) - val tree1 = Apply(Select(ru, newTermName("reify")), List(Literal(Constant(2)))) + val ru = Select(Select(Select(Select(Ident(TermName("scala")), TermName("reflect")), TermName("runtime")), TermName("package")), TermName("universe")) + val tree1 = Apply(Select(ru, TermName("reify")), List(Literal(Constant(2)))) val ttree1 = c.typeCheck(tree1, withMacrosDisabled = false) c.literal(ttree1.toString) } @@ -21,7 +21,7 @@ object Macros { val ru = build.newFreeTerm("ru", scala.reflect.runtime.universe) build.setTypeSignature(ru, rutpe) - val tree2 = Apply(Select(Ident(ru), newTermName("reify")), List(Literal(Constant(2)))) + val tree2 = Apply(Select(Ident(ru), TermName("reify")), List(Literal(Constant(2)))) val ttree2 = c.typeCheck(tree2, withMacrosDisabled = true) c.literal(ttree2.toString) } diff --git a/test/files/run/macro-typecheck-macrosdisabled2.check b/test/files/run/macro-typecheck-macrosdisabled2.check index 7bdd1d6a3a..b958a95552 100644 --- a/test/files/run/macro-typecheck-macrosdisabled2.check +++ b/test/files/run/macro-typecheck-macrosdisabled2.check @@ -10,7 +10,7 @@ def apply[U >: Nothing <: scala.reflect.api.Universe with Singleton]($m$untyped: scala.reflect.api.Mirror[U]): U#Tree = { val $u: U = $m$untyped.universe; val $m: $u.Mirror = $m$untyped.asInstanceOf[$u.Mirror]; - $u.Apply.apply($u.Select.apply($u.Select.apply($u.build.Ident($m.staticPackage("scala")), $u.newTermName("Array")), $u.newTermName("apply")), scala.collection.immutable.List.apply[$u.Literal]($u.Literal.apply($u.Constant.apply(2)))) + $u.Apply.apply($u.Select.apply($u.Select.apply($u.build.Ident($m.staticPackage("scala")), $u.TermName.apply("Array")), $u.TermName.apply("apply")), scala.collection.immutable.List.apply[$u.Literal]($u.Literal.apply($u.Constant.apply(2)))) } }; new $treecreator1() diff --git a/test/files/run/macro-typecheck-macrosdisabled2/Impls_Macros_1.scala b/test/files/run/macro-typecheck-macrosdisabled2/Impls_Macros_1.scala index 1dbf5a1a87..a96e0c53b6 100644 --- a/test/files/run/macro-typecheck-macrosdisabled2/Impls_Macros_1.scala +++ b/test/files/run/macro-typecheck-macrosdisabled2/Impls_Macros_1.scala @@ -4,8 +4,8 @@ object Macros { def impl_with_macros_enabled(c: Context) = { import c.universe._ - val ru = Select(Select(Select(Select(Ident(newTermName("scala")), newTermName("reflect")), newTermName("runtime")), newTermName("package")), newTermName("universe")) - val tree1 = Apply(Select(ru, newTermName("reify")), List(Apply(Select(Ident(newTermName("scala")), newTermName("Array")), List(Literal(Constant(2)))))) + val ru = Select(Select(Select(Select(Ident(TermName("scala")), TermName("reflect")), TermName("runtime")), TermName("package")), TermName("universe")) + val tree1 = Apply(Select(ru, TermName("reify")), List(Apply(Select(Ident(TermName("scala")), TermName("Array")), List(Literal(Constant(2)))))) val ttree1 = c.typeCheck(tree1, withMacrosDisabled = false) c.literal(ttree1.toString) } @@ -21,7 +21,7 @@ object Macros { val ru = build.newFreeTerm("ru", scala.reflect.runtime.universe) build.setTypeSignature(ru, rutpe) - val tree2 = Apply(Select(Ident(ru), newTermName("reify")), List(Apply(Select(Ident(newTermName("scala")), newTermName("Array")), List(Literal(Constant(2)))))) + val tree2 = Apply(Select(Ident(ru), TermName("reify")), List(Apply(Select(Ident(TermName("scala")), TermName("Array")), List(Literal(Constant(2)))))) val ttree2 = c.typeCheck(tree2, withMacrosDisabled = true) c.literal(ttree2.toString) } diff --git a/test/files/run/map_java_conversions.scala b/test/files/run/map_java_conversions.scala index 7714b2cc74..751167c04d 100644 --- a/test/files/run/map_java_conversions.scala +++ b/test/files/run/map_java_conversions.scala @@ -19,7 +19,7 @@ object Test { val concMap = new java.util.concurrent.ConcurrentHashMap[String, String] test(concMap) - val cmap = asScalaConcurrentMap(concMap) + val cmap = mapAsScalaConcurrentMap(concMap) cmap.putIfAbsent("absentKey", "absentValue") cmap.put("somekey", "somevalue") assert(cmap.remove("somekey", "somevalue") == true) diff --git a/test/files/run/no-pickle-skolems.check b/test/files/run/no-pickle-skolems.check new file mode 100644 index 0000000000..d64066171a --- /dev/null +++ b/test/files/run/no-pickle-skolems.check @@ -0,0 +1 @@ +OK! diff --git a/test/files/run/no-pickle-skolems/Source_1.scala b/test/files/run/no-pickle-skolems/Source_1.scala new file mode 100644 index 0000000000..1b4cbfa788 --- /dev/null +++ b/test/files/run/no-pickle-skolems/Source_1.scala @@ -0,0 +1,5 @@ +package s + +trait Foo { def to[CC[X]](implicit cc: CC[Int]): Unit } + +class Bar extends Foo { def to[CC[X]](implicit cc: CC[Int]): Unit = ??? } diff --git a/test/files/run/no-pickle-skolems/Test_2.scala b/test/files/run/no-pickle-skolems/Test_2.scala new file mode 100644 index 0000000000..90bb4c4f88 --- /dev/null +++ b/test/files/run/no-pickle-skolems/Test_2.scala @@ -0,0 +1,37 @@ +import scala.reflect.runtime.universe._ + +object Test { + /** Collects symbols by the given name, even if they're not + * named CC. + */ + def collectSymbols[T: TypeTag](inMethod: TermName, name: String): List[String] = { + val m = typeOf[T] member inMethod typeSignatureIn typeOf[T] + var buf: List[Symbol] = Nil + var seen: Set[Symbol] = Set() + def id(s: Symbol): Int = s.asInstanceOf[{ def id: Int }].id + + def check(s: Symbol) { + if (!seen(s)) { + seen += s + if (s.name.toString == name) buf ::= s + } + } + def loop(t: Type) { + t match { + case TypeRef(pre, sym, args) => loop(pre) ; check(sym) ; args foreach loop + case PolyType(tparams, restpe) => tparams foreach { tp => check(tp) ; check(tp.owner) ; loop(tp.typeSignature) } ; loop(restpe) + case MethodType(params, restpe) => params foreach { p => check(p) ; loop(p.typeSignature) } ; loop(restpe) + case _ => + } + } + loop(m) + + buf.reverse.distinct map (s => s.name + "#" + id(s)) + } + + def main(args: Array[String]): Unit = { + val syms = collectSymbols[s.Bar]("to", "CC") + assert(syms.size == 1, syms) + println("OK!") + } +} diff --git a/test/files/run/parserJavaIdent.check b/test/files/run/parserJavaIdent.check new file mode 100644 index 0000000000..597ddbee47 --- /dev/null +++ b/test/files/run/parserJavaIdent.check @@ -0,0 +1,26 @@ +[1.7] parsed: simple +[1.8] parsed: with123 +[1.6] parsed: with$ +[1.10] parsed: withøßöèæ +[1.6] parsed: with_ +[1.6] parsed: _with +[1.1] failure: java identifier expected + +3start +^ +[1.1] failure: java identifier expected + +-start +^ +[1.5] failure: java identifier expected + +with-s + ^ +[1.3] failure: java identifier expected + +we♥scala + ^ +[1.6] failure: java identifier expected + +with space + ^ diff --git a/test/files/run/parserJavaIdent.scala b/test/files/run/parserJavaIdent.scala new file mode 100644 index 0000000000..c068075e4e --- /dev/null +++ b/test/files/run/parserJavaIdent.scala @@ -0,0 +1,26 @@ +object Test extends scala.util.parsing.combinator.JavaTokenParsers { + + def test[A](s: String) { + val res = parseAll(ident, s) match { + case Failure(_, in) => Failure("java identifier expected", in) + case o => o + } + println(res) + } + + def main(args: Array[String]) { + // Happy tests + test("simple") + test("with123") + test("with$") + test("withøßöèæ") + test("with_") + test("_with") + // Sad tests + test("3start") + test("-start") + test("with-s") + test("we♥scala") + test("with space") + } +} diff --git a/test/files/run/patmat_unapp_abstype-old.check b/test/files/run/patmat_unapp_abstype-old.check deleted file mode 100644 index 72239d16cd..0000000000 --- a/test/files/run/patmat_unapp_abstype-old.check +++ /dev/null @@ -1,4 +0,0 @@ -TypeRef -none of the above -Bar -Foo diff --git a/test/files/run/patmat_unapp_abstype-old.flags b/test/files/run/patmat_unapp_abstype-old.flags deleted file mode 100644 index ba80cad69b..0000000000 --- a/test/files/run/patmat_unapp_abstype-old.flags +++ /dev/null @@ -1 +0,0 @@ --Xoldpatmat diff --git a/test/files/run/patmat_unapp_abstype-old.scala b/test/files/run/patmat_unapp_abstype-old.scala deleted file mode 100644 index 45496f08a2..0000000000 --- a/test/files/run/patmat_unapp_abstype-old.scala +++ /dev/null @@ -1,83 +0,0 @@ -// abstract types and extractors, oh my! -trait TypesAPI { - trait Type - - // an alternative fix (implemented in the virtual pattern matcher, is to replace the isInstanceOf by a manifest-based run-time test) - // that's what typeRefMani is for - type TypeRef <: Type //; implicit def typeRefMani: Manifest[TypeRef] - val TypeRef: TypeRefExtractor; trait TypeRefExtractor { - def apply(x: Int): TypeRef - def unapply(x: TypeRef): Option[(Int)] - } - - // just for illustration, should follow the same pattern as TypeRef - case class MethodType(n: Int) extends Type -} - -// user should not be exposed to the implementation -trait TypesUser extends TypesAPI { - def shouldNotCrash(tp: Type): Unit = { - tp match { - case TypeRef(x) => println("TypeRef") - // the above checks tp.isInstanceOf[TypeRef], which is erased to tp.isInstanceOf[Type] - // before calling TypeRef.unapply(tp), which will then crash unless tp.isInstanceOf[TypesImpl#TypeRef] (which is not implied by tp.isInstanceOf[Type]) - // tp.isInstanceOf[TypesImpl#TypeRef] is equivalent to classOf[TypesImpl#TypeRef].isAssignableFrom(tp.getClass) - // this is equivalent to manifest - // it is NOT equivalent to manifest[Type] <:< typeRefMani - case MethodType(x) => println("MethodType") - case _ => println("none of the above") - } - } -} - -trait TypesImpl extends TypesAPI { - object TypeRef extends TypeRefExtractor // this will have a bridged unapply(x: Type) = unapply(x.asInstanceOf[TypeRef]) - case class TypeRef(n: Int) extends Type // this has a bridge from TypesAPI#Type to TypesImpl#TypeRef - // --> the cast in the bridge will fail because the pattern matcher can't type test against the abstract types in TypesUser - //lazy val typeRefMani = manifest[TypeRef] -} - -trait Foos { - trait Bar - type Foo <: Bar - trait FooExtractor { - def unapply(foo: Foo): Option[Int] - } - val Foo: FooExtractor -} - -trait RealFoos extends Foos { - class Foo(val x: Int) extends Bar - object Foo extends FooExtractor { - def unapply(foo: Foo): Option[Int] = Some(foo.x) - } -} - -trait Intermed extends Foos { - def crash(bar: Bar): Unit = - bar match { - case Foo(x) => println("Foo") - case _ => println("Bar") - } -} - -object TestUnappStaticallyKnownSynthetic extends TypesImpl with TypesUser { - def test() = { - shouldNotCrash(TypeRef(10)) // should and does print "TypeRef" - // once #1697/#2337 are fixed, this should generate the correct output - shouldNotCrash(MethodType(10)) // should print "MethodType" but prints "none of the above" -- good one, pattern matcher! - } -} - -object TestUnappDynamicSynth extends RealFoos with Intermed { - case class FooToo(n: Int) extends Bar - def test() = { - crash(FooToo(10)) - crash(new Foo(5)) - } -} - -object Test extends App { - TestUnappStaticallyKnownSynthetic.test() - TestUnappDynamicSynth.test() -} diff --git a/test/files/run/programmatic-main.check b/test/files/run/programmatic-main.check index bdf76ddce1..d472c569d2 100644 --- a/test/files/run/programmatic-main.check +++ b/test/files/run/programmatic-main.check @@ -1,31 +1,31 @@ - phase name id description - ---------- -- ----------- - parser 1 parse source into ASTs, perform simple desugaring - namer 2 resolve names, attach symbols to named trees - packageobjects 3 load package objects - typer 4 the meat and potatoes: type the trees - patmat 5 translate match expressions - superaccessors 6 add super accessors in traits and nested classes - extmethods 7 add extension methods for inline classes - pickler 8 serialize symbol tables - refchecks 9 reference/override checking, translate nested objects - uncurry 10 uncurry, translate function values to anonymous classes - tailcalls 11 replace tail calls by jumps - specialize 12 @specialized-driven class and method specialization - explicitouter 13 this refs to outer pointers, translate patterns - erasure 14 erase types, add interfaces for traits - posterasure 15 clean up erased inline classes - lazyvals 16 allocate bitmaps, translate lazy vals into lazified defs - lambdalift 17 move nested functions to top level - constructors 18 move field definitions into constructors - flatten 19 eliminate inner classes - mixin 20 mixin composition - cleanup 21 platform-specific cleanups, generate reflective calls - icode 22 generate portable intermediate code - inliner 23 optimization: do inlining -inlineExceptionHandlers 24 optimization: inline exception handlers - closelim 25 optimization: eliminate uncalled closures - dce 26 optimization: eliminate dead code - jvm 27 generate JVM bytecode - terminal 28 The last phase in the compiler chain + phase name id description + ---------- -- ----------- + parser 1 parse source into ASTs, perform simple desugaring + namer 2 resolve names, attach symbols to named trees +packageobjects 3 load package objects + typer 4 the meat and potatoes: type the trees + patmat 5 translate match expressions +superaccessors 6 add super accessors in traits and nested classes + extmethods 7 add extension methods for inline classes + pickler 8 serialize symbol tables + refchecks 9 reference/override checking, translate nested objects + uncurry 10 uncurry, translate function values to anonymous classes + tailcalls 11 replace tail calls by jumps + specialize 12 @specialized-driven class and method specialization + explicitouter 13 this refs to outer pointers, translate patterns + erasure 14 erase types, add interfaces for traits + posterasure 15 clean up erased inline classes + lazyvals 16 allocate bitmaps, translate lazy vals into lazified defs + lambdalift 17 move nested functions to top level + constructors 18 move field definitions into constructors + flatten 19 eliminate inner classes + mixin 20 mixin composition + cleanup 21 platform-specific cleanups, generate reflective calls + icode 22 generate portable intermediate code + inliner 23 optimization: do inlining +inlinehandlers 24 optimization: inline exception handlers + closelim 25 optimization: eliminate uncalled closures + dce 26 optimization: eliminate dead code + jvm 27 generate JVM bytecode + terminal 28 The last phase in the compiler chain diff --git a/test/files/run/reflection-allmirrors-tostring.scala b/test/files/run/reflection-allmirrors-tostring.scala index 73afff291c..0ca387a6b1 100644 --- a/test/files/run/reflection-allmirrors-tostring.scala +++ b/test/files/run/reflection-allmirrors-tostring.scala @@ -26,18 +26,18 @@ object Test extends App { println(cm.reflect(new C)) val im = cm.reflect(new C) - println(im.reflectField(typeOf[C].member(newTermName("f1")).asTerm)) - println(im.reflectField(typeOf[C].member(newTermName("f2")).asTerm)) - println(im.reflectMethod(typeOf[C].member(newTermName("m1")).asMethod)) - println(im.reflectMethod(typeOf[C].member(newTermName("m2")).asMethod)) - println(im.reflectMethod(typeOf[C].member(newTermName("m3")).asMethod)) - println(im.reflectMethod(typeOf[C].member(newTermName("m4")).asMethod)) - println(im.reflectMethod(typeOf[C].member(newTermName("m5")).asMethod)) - println(im.reflectClass(typeOf[C].member(newTypeName("C")).asClass)) - println(im.reflectModule(typeOf[C].member(newTermName("M")).asModule)) + println(im.reflectField(typeOf[C].member(TermName("f1")).asTerm)) + println(im.reflectField(typeOf[C].member(TermName("f2")).asTerm)) + println(im.reflectMethod(typeOf[C].member(TermName("m1")).asMethod)) + println(im.reflectMethod(typeOf[C].member(TermName("m2")).asMethod)) + println(im.reflectMethod(typeOf[C].member(TermName("m3")).asMethod)) + println(im.reflectMethod(typeOf[C].member(TermName("m4")).asMethod)) + println(im.reflectMethod(typeOf[C].member(TermName("m5")).asMethod)) + println(im.reflectClass(typeOf[C].member(TypeName("C")).asClass)) + println(im.reflectModule(typeOf[C].member(TermName("M")).asModule)) val c = cm.staticClass("C") - val cc = typeOf[C].member(newTypeName("C")).asClass + val cc = typeOf[C].member(TypeName("C")).asClass println(cm.reflectClass(c).reflectConstructor(c.typeSignature.member(nme.CONSTRUCTOR).asMethod)) println(im.reflectClass(cc).reflectConstructor(cc.typeSignature.member(nme.CONSTRUCTOR).asMethod)) }
\ No newline at end of file diff --git a/test/files/run/reflection-enclosed-basic.scala b/test/files/run/reflection-enclosed-basic.scala index 1dcb6c2a27..7b9e0c20dc 100644 --- a/test/files/run/reflection-enclosed-basic.scala +++ b/test/files/run/reflection-enclosed-basic.scala @@ -12,7 +12,7 @@ private object B6 extends B2 { override def toString = "B6"; override def foo = object Test extends App { def testMethodInvocation(instance: Any) = { val instanceMirror = cm.reflect(instance) - val method = instanceMirror.symbol.typeSignature.declaration(newTermName("foo")).asMethod + val method = instanceMirror.symbol.typeSignature.declaration(TermName("foo")).asMethod val methodMirror = instanceMirror.reflectMethod(method) println(methodMirror()) } @@ -20,7 +20,7 @@ object Test extends App { def testNestedClass(name: String) = { val sym = cm.staticClass(name) println(sym) - val ctor = sym.typeSignature.declaration(newTermName("<init>")).asMethod + val ctor = sym.typeSignature.declaration(nme.CONSTRUCTOR).asMethod val ctorMirror = cm.reflectClass(sym).reflectConstructor(ctor) val instance = ctorMirror() println(instance) diff --git a/test/files/run/reflection-enclosed-inner-basic.scala b/test/files/run/reflection-enclosed-inner-basic.scala index 2b2c701993..c1cf9bc336 100644 --- a/test/files/run/reflection-enclosed-inner-basic.scala +++ b/test/files/run/reflection-enclosed-inner-basic.scala @@ -18,15 +18,15 @@ object Test extends App { def testMethodInvocation(instance: Any) = { val instanceMirror = cm.reflect(instance) - val method = instanceMirror.symbol.typeSignature.declaration(newTermName("foo")).asMethod + val method = instanceMirror.symbol.typeSignature.declaration(TermName("foo")).asMethod val methodMirror = instanceMirror.reflectMethod(method) println(methodMirror()) } def testInnerClass(name: String) = { - val sym = b.typeSignature.declaration(newTypeName(name)).asClass + val sym = b.typeSignature.declaration(TypeName(name)).asClass println(sym) - val ctor = sym.typeSignature.declaration(newTermName("<init>")).asMethod + val ctor = sym.typeSignature.declaration(nme.CONSTRUCTOR).asMethod val ctorMirror = cm.reflect(new B).reflectClass(sym).reflectConstructor(ctor) val instance = ctorMirror() println(instance) @@ -37,7 +37,7 @@ object Test extends App { testInnerClass("B2") def testInnerModule(name: String) = { - val sym = b.typeSignature.declaration(newTermName(name)).asModule + val sym = b.typeSignature.declaration(TermName(name)).asModule println(sym) val moduleMirror = cm.reflect(new B).reflectModule(sym) val instance = moduleMirror.instance diff --git a/test/files/run/reflection-enclosed-inner-inner-basic.scala b/test/files/run/reflection-enclosed-inner-inner-basic.scala index 1b9e19d37d..8a73fac522 100644 --- a/test/files/run/reflection-enclosed-inner-inner-basic.scala +++ b/test/files/run/reflection-enclosed-inner-inner-basic.scala @@ -20,15 +20,15 @@ object Test extends App { def testMethodInvocation(instance: Any) = { val instanceMirror = cm.reflect(instance) - val method = instanceMirror.symbol.typeSignature.declaration(newTermName("foo")).asMethod + val method = instanceMirror.symbol.typeSignature.declaration(TermName("foo")).asMethod val methodMirror = instanceMirror.reflectMethod(method) println(methodMirror()) } def testInnerClass(name: String) = { - val sym = b.typeSignature.declaration(newTypeName(name)).asClass + val sym = b.typeSignature.declaration(TypeName(name)).asClass println(sym) - val ctor = sym.typeSignature.declaration(newTermName("<init>")).asMethod + val ctor = sym.typeSignature.declaration(nme.CONSTRUCTOR).asMethod val outer1 = new B val outer2 = new outer1.BB val ctorMirror = cm.reflect(outer2).reflectClass(sym).reflectConstructor(ctor) @@ -41,7 +41,7 @@ object Test extends App { testInnerClass("B2") def testInnerModule(name: String) = { - val sym = b.typeSignature.declaration(newTermName(name)).asModule + val sym = b.typeSignature.declaration(TermName(name)).asModule println(sym) val outer1 = new B val outer2 = new outer1.BB diff --git a/test/files/run/reflection-enclosed-inner-nested-basic.scala b/test/files/run/reflection-enclosed-inner-nested-basic.scala index 2800ee2548..6c2fc6df7a 100644 --- a/test/files/run/reflection-enclosed-inner-nested-basic.scala +++ b/test/files/run/reflection-enclosed-inner-nested-basic.scala @@ -21,15 +21,15 @@ object Test extends App { def testMethodInvocation(instance: Any) = { val instanceMirror = cm.reflect(instance) - val method = instanceMirror.symbol.typeSignature.declaration(newTermName("foo")).asMethod + val method = instanceMirror.symbol.typeSignature.declaration(TermName("foo")).asMethod val methodMirror = instanceMirror.reflectMethod(method) println(methodMirror()) } def testNestedClass(name: String) = { - val sym = b.typeSignature.declaration(newTypeName(name)).asClass + val sym = b.typeSignature.declaration(TypeName(name)).asClass println(sym) - val ctor = sym.typeSignature.declaration(newTermName("<init>")).asMethod + val ctor = sym.typeSignature.declaration(nme.CONSTRUCTOR).asMethod val ctorMirror = cm.reflect(outer1.BB).reflectClass(sym).reflectConstructor(ctor) val instance = ctorMirror() println(instance) @@ -40,7 +40,7 @@ object Test extends App { testNestedClass("B2") def testNestedModule(name: String) = { - val sym = b.typeSignature.declaration(newTermName(name)).asModule + val sym = b.typeSignature.declaration(TermName(name)).asModule println(sym) val moduleMirror = cm.reflect(outer1.BB).reflectModule(sym) val instance = moduleMirror.instance diff --git a/test/files/run/reflection-enclosed-nested-basic.scala b/test/files/run/reflection-enclosed-nested-basic.scala index 8b740c2da2..180ac4ebee 100644 --- a/test/files/run/reflection-enclosed-nested-basic.scala +++ b/test/files/run/reflection-enclosed-nested-basic.scala @@ -18,15 +18,15 @@ object Test extends App { def testMethodInvocation(instance: Any) = { val instanceMirror = cm.reflect(instance) - val method = instanceMirror.symbol.typeSignature.declaration(newTermName("foo")).asMethod + val method = instanceMirror.symbol.typeSignature.declaration(TermName("foo")).asMethod val methodMirror = instanceMirror.reflectMethod(method) println(methodMirror()) } def testNestedClass(name: String) = { - val sym = b.typeSignature.declaration(newTypeName(name)).asClass + val sym = b.typeSignature.declaration(TypeName(name)).asClass println(sym) - val ctor = sym.typeSignature.declaration(newTermName("<init>")).asMethod + val ctor = sym.typeSignature.declaration(nme.CONSTRUCTOR).asMethod val ctorMirror = cm.reflectClass(sym).reflectConstructor(ctor) val instance = ctorMirror() println(instance) @@ -37,7 +37,7 @@ object Test extends App { testNestedClass("B2") def testNestedModule(name: String) = { - val sym = b.typeSignature.declaration(newTermName(name)).asModule + val sym = b.typeSignature.declaration(TermName(name)).asModule println(sym) val moduleMirror = cm.reflectModule(sym) val instance = moduleMirror.instance diff --git a/test/files/run/reflection-enclosed-nested-inner-basic.scala b/test/files/run/reflection-enclosed-nested-inner-basic.scala index 7466733d37..2558b8035a 100644 --- a/test/files/run/reflection-enclosed-nested-inner-basic.scala +++ b/test/files/run/reflection-enclosed-nested-inner-basic.scala @@ -20,15 +20,15 @@ object Test extends App { def testMethodInvocation(instance: Any) = { val instanceMirror = cm.reflect(instance) - val method = instanceMirror.symbol.typeSignature.declaration(newTermName("foo")).asMethod + val method = instanceMirror.symbol.typeSignature.declaration(TermName("foo")).asMethod val methodMirror = instanceMirror.reflectMethod(method) println(methodMirror()) } def testInnerClass(name: String) = { - val sym = b.typeSignature.declaration(newTypeName(name)).asClass + val sym = b.typeSignature.declaration(TypeName(name)).asClass println(sym) - val ctor = sym.typeSignature.declaration(newTermName("<init>")).asMethod + val ctor = sym.typeSignature.declaration(nme.CONSTRUCTOR).asMethod val ctorMirror = cm.reflect(new B.BB).reflectClass(sym).reflectConstructor(ctor) val instance = ctorMirror() println(instance) @@ -39,7 +39,7 @@ object Test extends App { testInnerClass("B2") def testInnerModule(name: String) = { - val sym = b.typeSignature.declaration(newTermName(name)).asModule + val sym = b.typeSignature.declaration(TermName(name)).asModule println(sym) val moduleMirror = cm.reflect(new B.BB).reflectModule(sym) val instance = moduleMirror.instance diff --git a/test/files/run/reflection-enclosed-nested-nested-basic.scala b/test/files/run/reflection-enclosed-nested-nested-basic.scala index 8335ea482a..b4711c9a8c 100644 --- a/test/files/run/reflection-enclosed-nested-nested-basic.scala +++ b/test/files/run/reflection-enclosed-nested-nested-basic.scala @@ -20,15 +20,15 @@ object Test extends App { def testMethodInvocation(instance: Any) = { val instanceMirror = cm.reflect(instance) - val method = instanceMirror.symbol.typeSignature.declaration(newTermName("foo")).asMethod + val method = instanceMirror.symbol.typeSignature.declaration(TermName("foo")).asMethod val methodMirror = instanceMirror.reflectMethod(method) println(methodMirror()) } def testNestedClass(name: String) = { - val sym = b.typeSignature.declaration(newTypeName(name)).asClass + val sym = b.typeSignature.declaration(TypeName(name)).asClass println(sym) - val ctor = sym.typeSignature.declaration(newTermName("<init>")).asMethod + val ctor = sym.typeSignature.declaration(nme.CONSTRUCTOR).asMethod val ctorMirror = cm.reflectClass(sym).reflectConstructor(ctor) val instance = ctorMirror() println(instance) @@ -39,7 +39,7 @@ object Test extends App { testNestedClass("B2") def testNestedModule(name: String) = { - val sym = b.typeSignature.declaration(newTermName(name)).asModule + val sym = b.typeSignature.declaration(TermName(name)).asModule println(sym) val moduleMirror = cm.reflectModule(sym) val instance = moduleMirror.instance diff --git a/test/files/run/reflection-equality.check b/test/files/run/reflection-equality.check index 65b525731f..b3b66f48d6 100644 --- a/test/files/run/reflection-equality.check +++ b/test/files/run/reflection-equality.check @@ -29,7 +29,7 @@ scala.AnyRef { def methodIntIntInt(x: scala.Int,y: scala.Int): scala.Int } -scala> val ms: MethodSymbol = ts.declaration(newTermName("methodIntIntInt")).asMethod +scala> val ms: MethodSymbol = ts.declaration(TermName("methodIntIntInt")).asMethod ms: reflect.runtime.universe.MethodSymbol = method methodIntIntInt scala> val MethodType( _, t1 ) = ms.typeSignature diff --git a/test/files/run/reflection-equality.scala b/test/files/run/reflection-equality.scala index 8fc82721e7..40f116bb53 100644 --- a/test/files/run/reflection-equality.scala +++ b/test/files/run/reflection-equality.scala @@ -11,7 +11,7 @@ object Test extends ReplTest { |def im: InstanceMirror = cm.reflect(new X) |val cs: ClassSymbol = im.symbol |val ts: Type = cs.typeSignature - |val ms: MethodSymbol = ts.declaration(newTermName("methodIntIntInt")).asMethod + |val ms: MethodSymbol = ts.declaration(TermName("methodIntIntInt")).asMethod |val MethodType( _, t1 ) = ms.typeSignature |val t2 = typeOf[scala.Int] |t1 == t2 diff --git a/test/files/run/reflection-fieldmirror-accessorsareokay.scala b/test/files/run/reflection-fieldmirror-accessorsareokay.scala index 16354025f3..3926ab7835 100644 --- a/test/files/run/reflection-fieldmirror-accessorsareokay.scala +++ b/test/files/run/reflection-fieldmirror-accessorsareokay.scala @@ -24,6 +24,6 @@ object Test extends App { } } - test(cs.typeSignature.declaration(newTermName("x")).asTerm) - test(cs.typeSignature.declaration(newTermName("x_$eq")).asTerm) + test(cs.typeSignature.declaration(TermName("x")).asTerm) + test(cs.typeSignature.declaration(TermName("x_$eq")).asTerm) } diff --git a/test/files/run/reflection-fieldmirror-ctorparam.scala b/test/files/run/reflection-fieldmirror-ctorparam.scala index b9d50fe97b..608adad27b 100644 --- a/test/files/run/reflection-fieldmirror-ctorparam.scala +++ b/test/files/run/reflection-fieldmirror-ctorparam.scala @@ -10,7 +10,7 @@ object Test extends App { val im: InstanceMirror = cm.reflect(a) val cs = im.symbol - val f = cs.typeSignature.declaration(newTermName("x")).asTerm + val f = cs.typeSignature.declaration(TermName("x")).asTerm try { val fm: FieldMirror = im.reflectField(f) println(fm.get) diff --git a/test/files/run/reflection-fieldmirror-getsetval.scala b/test/files/run/reflection-fieldmirror-getsetval.scala index 67c54d9708..9cacb7080b 100644 --- a/test/files/run/reflection-fieldmirror-getsetval.scala +++ b/test/files/run/reflection-fieldmirror-getsetval.scala @@ -10,7 +10,7 @@ object Test extends App { val im: InstanceMirror = cm.reflect(a) val cs = im.symbol - val f = cs.typeSignature.declaration(newTermName("x" + nme.LOCAL_SUFFIX_STRING)).asTerm + val f = cs.typeSignature.declaration(TermName("x" + nme.LOCAL_SUFFIX_STRING)).asTerm val fm: FieldMirror = im.reflectField(f) try { println(fm.get) diff --git a/test/files/run/reflection-fieldmirror-getsetvar.scala b/test/files/run/reflection-fieldmirror-getsetvar.scala index abcf396dd1..52c13a73bb 100644 --- a/test/files/run/reflection-fieldmirror-getsetvar.scala +++ b/test/files/run/reflection-fieldmirror-getsetvar.scala @@ -10,7 +10,7 @@ object Test extends App { val im: InstanceMirror = cm.reflect(a) val cs = im.symbol - val f = cs.typeSignature.declaration(newTermName("x" + nme.LOCAL_SUFFIX_STRING)).asTerm + val f = cs.typeSignature.declaration(TermName("x" + nme.LOCAL_SUFFIX_STRING)).asTerm val fm: FieldMirror = im.reflectField(f) println(fm.get) fm.set(2) diff --git a/test/files/run/reflection-fieldmirror-nmelocalsuffixstring.scala b/test/files/run/reflection-fieldmirror-nmelocalsuffixstring.scala index 2b4a9bb55e..e070cdcfa3 100644 --- a/test/files/run/reflection-fieldmirror-nmelocalsuffixstring.scala +++ b/test/files/run/reflection-fieldmirror-nmelocalsuffixstring.scala @@ -10,7 +10,7 @@ object Test extends App { val im: InstanceMirror = cm.reflect(a) val cs = im.symbol - val f = cs.typeSignature.declaration(newTermName("x" + nme.LOCAL_SUFFIX_STRING)).asTerm + val f = cs.typeSignature.declaration(TermName("x" + nme.LOCAL_SUFFIX_STRING)).asTerm val fm: FieldMirror = im.reflectField(f) println(fm.symbol.isVar) } diff --git a/test/files/run/reflection-fieldmirror-privatethis.scala b/test/files/run/reflection-fieldmirror-privatethis.scala index ab838dbb1b..89948772b1 100644 --- a/test/files/run/reflection-fieldmirror-privatethis.scala +++ b/test/files/run/reflection-fieldmirror-privatethis.scala @@ -10,7 +10,7 @@ object Test extends App { val im: InstanceMirror = cm.reflect(a) val cs = im.symbol - val f = cs.typeSignature.declaration(newTermName("x")).asTerm + val f = cs.typeSignature.declaration(TermName("x")).asTerm val fm: FieldMirror = im.reflectField(f) println(fm.symbol.isVar) println(fm.get) diff --git a/test/files/run/reflection-fieldsymbol-navigation.scala b/test/files/run/reflection-fieldsymbol-navigation.scala index 4448724988..33dc18a7e3 100644 --- a/test/files/run/reflection-fieldsymbol-navigation.scala +++ b/test/files/run/reflection-fieldsymbol-navigation.scala @@ -5,7 +5,7 @@ class C { } object Test extends App { - val x = typeOf[C].member(newTermName("x")).asTerm + val x = typeOf[C].member(TermName("x")).asTerm println(x) println(x.isVar) println(x.accessed) diff --git a/test/files/run/reflection-implClass.scala b/test/files/run/reflection-implClass.scala index b3c0081ccf..db211fd9a8 100644 --- a/test/files/run/reflection-implClass.scala +++ b/test/files/run/reflection-implClass.scala @@ -10,19 +10,19 @@ object Test extends App with Outer { import scala.reflect.runtime.universe._ import scala.reflect.runtime.{currentMirror => cm} - assert(cm.classSymbol(classTag[Foo].runtimeClass).typeSignature.declaration(newTermName("bar")).typeSignature == - cm.classSymbol(classTag[Bar].runtimeClass).typeSignature.declaration(newTermName("foo")).typeSignature) + assert(cm.classSymbol(classTag[Foo].runtimeClass).typeSignature.declaration(TermName("bar")).typeSignature == + cm.classSymbol(classTag[Bar].runtimeClass).typeSignature.declaration(TermName("foo")).typeSignature) val s1 = implClass(classTag[Foo].runtimeClass) assert(s1 != NoSymbol) assert(s1.typeSignature != NoType) assert(s1.companionSymbol.typeSignature != NoType) - assert(s1.companionSymbol.typeSignature.declaration(newTermName("bar")) != NoSymbol) + assert(s1.companionSymbol.typeSignature.declaration(TermName("bar")) != NoSymbol) val s2 = implClass(classTag[Bar].runtimeClass) assert(s2 != NoSymbol) assert(s2.typeSignature != NoType) assert(s2.companionSymbol.typeSignature != NoType) - assert(s2.companionSymbol.typeSignature.declaration(newTermName("foo")) != NoSymbol) + assert(s2.companionSymbol.typeSignature.declaration(TermName("foo")) != NoSymbol) def implClass(clazz: Class[_]) = { val implClass = Class.forName(clazz.getName + "$class") cm.classSymbol(implClass) diff --git a/test/files/run/reflection-magicsymbols-invoke.scala b/test/files/run/reflection-magicsymbols-invoke.scala index 5f39370708..ff3992709f 100644 --- a/test/files/run/reflection-magicsymbols-invoke.scala +++ b/test/files/run/reflection-magicsymbols-invoke.scala @@ -28,7 +28,7 @@ object Test extends App { val ctor = tpe.declaration(nme.CONSTRUCTOR).asMethod cm.reflectClass(ctor.owner.asClass).reflectConstructor(ctor)(args: _*) } else { - val meth = tpe.declaration(newTermName(method).encodedName.toTermName).asMethod + val meth = tpe.declaration(TermName(method).encodedName.toTermName).asMethod cm.reflect(receiver).reflectMethod(meth)(args: _*) } }) @@ -54,7 +54,7 @@ object Test extends App { println("it's important to print the list of AnyVal's members") println("if some of them change (possibly, adding and/or removing magic symbols), we must update this test") typeOf[AnyVal].declarations.toList.sortBy(key).foreach(sym => println(key(sym))) - test(typeOf[AnyVal], null, "<init>") + test(typeOf[AnyVal], null, nme.CONSTRUCTOR.toString) test(typeOf[AnyVal], 2, "getClass") println("============\nAnyRef") diff --git a/test/files/run/reflection-magicsymbols-repl.check b/test/files/run/reflection-magicsymbols-repl.check index d3cd26f25f..85a1f63f01 100644 --- a/test/files/run/reflection-magicsymbols-repl.check +++ b/test/files/run/reflection-magicsymbols-repl.check @@ -19,7 +19,7 @@ scala> class A { defined class A scala> def test(n: Int): Unit = { - val sig = typeOf[A] member newTermName("foo" + n) typeSignature + val sig = typeOf[A] member TermName("foo" + n) typeSignature val x = sig.asInstanceOf[MethodType].params.head println(x.typeSignature) } diff --git a/test/files/run/reflection-magicsymbols-repl.scala b/test/files/run/reflection-magicsymbols-repl.scala index 26127b8661..6a432c2664 100644 --- a/test/files/run/reflection-magicsymbols-repl.scala +++ b/test/files/run/reflection-magicsymbols-repl.scala @@ -14,7 +14,7 @@ object Test extends ReplTest { | def foo8(x: Singleton) = ??? |} |def test(n: Int): Unit = { - | val sig = typeOf[A] member newTermName("foo" + n) typeSignature + | val sig = typeOf[A] member TermName("foo" + n) typeSignature | val x = sig.asInstanceOf[MethodType].params.head | println(x.typeSignature) |} diff --git a/test/files/run/reflection-magicsymbols-vanilla.scala b/test/files/run/reflection-magicsymbols-vanilla.scala index 32819dcc46..26b70460eb 100644 --- a/test/files/run/reflection-magicsymbols-vanilla.scala +++ b/test/files/run/reflection-magicsymbols-vanilla.scala @@ -12,7 +12,7 @@ class A { object Test extends App { import scala.reflect.runtime.universe._ def test(n: Int): Unit = { - val sig = typeOf[A] member newTermName("foo" + n) typeSignature + val sig = typeOf[A] member TermName("foo" + n) typeSignature val x = sig.asInstanceOf[MethodType].params.head println(x.typeSignature) } diff --git a/test/files/run/reflection-methodsymbol-params.scala b/test/files/run/reflection-methodsymbol-params.scala index 45b1f9628f..baad8d6b9b 100644 --- a/test/files/run/reflection-methodsymbol-params.scala +++ b/test/files/run/reflection-methodsymbol-params.scala @@ -13,12 +13,12 @@ class C { } object Test extends App { - println(typeOf[C].member(newTermName("x1")).asMethod.paramss) - println(typeOf[C].member(newTermName("x2")).asMethod.paramss) - println(typeOf[C].member(newTermName("x3")).asMethod.paramss) - println(typeOf[C].member(newTermName("x4")).asMethod.paramss) - println(typeOf[C].member(newTermName("y1")).asMethod.paramss) - println(typeOf[C].member(newTermName("y2")).asMethod.paramss) - println(typeOf[C].member(newTermName("y3")).asMethod.paramss) - println(typeOf[C].member(newTermName("y4")).asMethod.paramss) + println(typeOf[C].member(TermName("x1")).asMethod.paramss) + println(typeOf[C].member(TermName("x2")).asMethod.paramss) + println(typeOf[C].member(TermName("x3")).asMethod.paramss) + println(typeOf[C].member(TermName("x4")).asMethod.paramss) + println(typeOf[C].member(TermName("y1")).asMethod.paramss) + println(typeOf[C].member(TermName("y2")).asMethod.paramss) + println(typeOf[C].member(TermName("y3")).asMethod.paramss) + println(typeOf[C].member(TermName("y4")).asMethod.paramss) }
\ No newline at end of file diff --git a/test/files/run/reflection-methodsymbol-returntype.scala b/test/files/run/reflection-methodsymbol-returntype.scala index 392754dbe4..74a9e5dac0 100644 --- a/test/files/run/reflection-methodsymbol-returntype.scala +++ b/test/files/run/reflection-methodsymbol-returntype.scala @@ -13,12 +13,12 @@ class C { } object Test extends App { - println(typeOf[C].member(newTermName("x1")).asMethod.returnType) - println(typeOf[C].member(newTermName("x2")).asMethod.returnType) - println(typeOf[C].member(newTermName("x3")).asMethod.returnType) - println(typeOf[C].member(newTermName("x4")).asMethod.returnType) - println(typeOf[C].member(newTermName("y1")).asMethod.returnType) - println(typeOf[C].member(newTermName("y2")).asMethod.returnType) - println(typeOf[C].member(newTermName("y3")).asMethod.returnType) - println(typeOf[C].member(newTermName("y4")).asMethod.returnType) + println(typeOf[C].member(TermName("x1")).asMethod.returnType) + println(typeOf[C].member(TermName("x2")).asMethod.returnType) + println(typeOf[C].member(TermName("x3")).asMethod.returnType) + println(typeOf[C].member(TermName("x4")).asMethod.returnType) + println(typeOf[C].member(TermName("y1")).asMethod.returnType) + println(typeOf[C].member(TermName("y2")).asMethod.returnType) + println(typeOf[C].member(TermName("y3")).asMethod.returnType) + println(typeOf[C].member(TermName("y4")).asMethod.returnType) }
\ No newline at end of file diff --git a/test/files/run/reflection-methodsymbol-typeparams.scala b/test/files/run/reflection-methodsymbol-typeparams.scala index bb0a3c3aec..56d37ebeaa 100644 --- a/test/files/run/reflection-methodsymbol-typeparams.scala +++ b/test/files/run/reflection-methodsymbol-typeparams.scala @@ -13,12 +13,12 @@ class C { } object Test extends App { - println(typeOf[C].member(newTermName("x1")).asMethod.typeParams) - println(typeOf[C].member(newTermName("x2")).asMethod.typeParams) - println(typeOf[C].member(newTermName("x3")).asMethod.typeParams) - println(typeOf[C].member(newTermName("x4")).asMethod.typeParams) - println(typeOf[C].member(newTermName("y1")).asMethod.typeParams) - println(typeOf[C].member(newTermName("y2")).asMethod.typeParams) - println(typeOf[C].member(newTermName("y3")).asMethod.typeParams) - println(typeOf[C].member(newTermName("y4")).asMethod.typeParams) + println(typeOf[C].member(TermName("x1")).asMethod.typeParams) + println(typeOf[C].member(TermName("x2")).asMethod.typeParams) + println(typeOf[C].member(TermName("x3")).asMethod.typeParams) + println(typeOf[C].member(TermName("x4")).asMethod.typeParams) + println(typeOf[C].member(TermName("y1")).asMethod.typeParams) + println(typeOf[C].member(TermName("y2")).asMethod.typeParams) + println(typeOf[C].member(TermName("y3")).asMethod.typeParams) + println(typeOf[C].member(TermName("y4")).asMethod.typeParams) }
\ No newline at end of file diff --git a/test/files/run/reflection-repl-classes.check b/test/files/run/reflection-repl-classes.check index 2dd96a93bf..d70db59b85 100644 --- a/test/files/run/reflection-repl-classes.check +++ b/test/files/run/reflection-repl-classes.check @@ -19,10 +19,10 @@ scala> object defs { val cm = reflect.runtime.currentMirror val u = cm.universe val im = cm.reflect(new B) - val method = im.symbol.typeSignature.member(u.newTermName("foo")).asMethod + val method = im.symbol.typeSignature.member(u.TermName("foo")).asMethod val mm = im.reflectMethod(method) } -defined module defs +defined object defs scala> import defs._ import defs._ diff --git a/test/files/run/reflection-repl-classes.scala b/test/files/run/reflection-repl-classes.scala index 80e332cde3..4bfb980498 100644 --- a/test/files/run/reflection-repl-classes.scala +++ b/test/files/run/reflection-repl-classes.scala @@ -12,7 +12,7 @@ object Test extends ReplTest { | val cm = reflect.runtime.currentMirror | val u = cm.universe | val im = cm.reflect(new B) - | val method = im.symbol.typeSignature.member(u.newTermName("foo")).asMethod + | val method = im.symbol.typeSignature.member(u.TermName("foo")).asMethod | val mm = im.reflectMethod(method) |} |import defs._ diff --git a/test/files/run/reflection-sanitychecks.scala b/test/files/run/reflection-sanitychecks.scala index f817f23731..6d3daff1f7 100644 --- a/test/files/run/reflection-sanitychecks.scala +++ b/test/files/run/reflection-sanitychecks.scala @@ -32,14 +32,14 @@ object Test extends App { def test(tpe: Type): Unit = { def failsafe(action: => Any): Any = try action catch { case ex: Throwable => ex.toString } println(s"=========members of ${tpe.typeSymbol.name} in a mirror of D=========") - println("field #1: " + failsafe(im.reflectField(tpe.member(newTermName("foo")).asTerm).get)) - println("method #1: " + failsafe(im.reflectMethod(tpe.member(newTermName("bar")).asMethod)())) - println("field #2: " + failsafe(im.reflectField(tpe.member(newTermName("quux")).asTerm).get)) - println("method #2: " + failsafe(im.reflectMethod(tpe.member(newTermName("baz")).asMethod)())) - println("constructor #1: " + failsafe(cm.reflectClass(im.symbol).reflectConstructor(tpe.member(newTermName("bar")).asMethod)())) - println("constructor #2: " + failsafe(cm.reflectClass(im.symbol).reflectConstructor(tpe.member(newTermName("<init>")).asMethod)())) - println("class: " + failsafe(im.reflectClass(tpe.member(newTypeName("C")).asClass).reflectConstructor(typeOf[C].member(newTypeName("C")).asClass.typeSignature.member(newTermName("<init>")).asMethod)())) - println("object: " + failsafe(im.reflectModule(tpe.member(newTermName("O")).asModule).instance)) + println("field #1: " + failsafe(im.reflectField(tpe.member(TermName("foo")).asTerm).get)) + println("method #1: " + failsafe(im.reflectMethod(tpe.member(TermName("bar")).asMethod)())) + println("field #2: " + failsafe(im.reflectField(tpe.member(TermName("quux")).asTerm).get)) + println("method #2: " + failsafe(im.reflectMethod(tpe.member(TermName("baz")).asMethod)())) + println("constructor #1: " + failsafe(cm.reflectClass(im.symbol).reflectConstructor(tpe.member(TermName("bar")).asMethod)())) + println("constructor #2: " + failsafe(cm.reflectClass(im.symbol).reflectConstructor(tpe.member(TermName("<init>")).asMethod)())) + println("class: " + failsafe(im.reflectClass(tpe.member(TypeName("C")).asClass).reflectConstructor(typeOf[C].member(TypeName("C")).asClass.typeSignature.member(nme.CONSTRUCTOR).asMethod)())) + println("object: " + failsafe(im.reflectModule(tpe.member(TermName("O")).asModule).instance)) println() } diff --git a/test/files/run/reflection-valueclasses-derived.scala b/test/files/run/reflection-valueclasses-derived.scala index 6b08f987ba..8d25e2929c 100644 --- a/test/files/run/reflection-valueclasses-derived.scala +++ b/test/files/run/reflection-valueclasses-derived.scala @@ -6,7 +6,7 @@ class C(val x: Int) extends AnyVal { } object Test extends App { - println(cm.reflect(new C(2)).reflectMethod(typeOf[C].member(newTermName("foo")).asMethod)(2)) - println(cm.reflect(new C(2)).reflectMethod(typeOf[C].member(newTermName("getClass")).asMethod)()) - println(cm.reflect(new C(2)).reflectMethod(typeOf[C].member(newTermName("toString")).asMethod)()) + println(cm.reflect(new C(2)).reflectMethod(typeOf[C].member(TermName("foo")).asMethod)(2)) + println(cm.reflect(new C(2)).reflectMethod(typeOf[C].member(TermName("getClass")).asMethod)()) + println(cm.reflect(new C(2)).reflectMethod(typeOf[C].member(TermName("toString")).asMethod)()) }
\ No newline at end of file diff --git a/test/files/run/reflection-valueclasses-magic.scala b/test/files/run/reflection-valueclasses-magic.scala index c4a26e460a..33d4634397 100644 --- a/test/files/run/reflection-valueclasses-magic.scala +++ b/test/files/run/reflection-valueclasses-magic.scala @@ -44,7 +44,7 @@ object Test extends App { val realex = scala.ExceptionUtils.unwrapThrowable(ex) println(realex.getClass + ": " + realex.getMessage) } - val meth = tpe.declaration(newTermName(method).encodedName.toTermName) + val meth = tpe.declaration(TermName(method).encodedName.toTermName) val testees = if (meth.isMethod) List(meth.asMethod) else meth.asTerm.alternatives.map(_.asMethod) testees foreach (testee => { val convertedArgs = args.zipWithIndex.map { case (arg, i) => convert(arg, testee.paramss.flatten.apply(i).typeSignature) } diff --git a/test/files/run/reflection-valueclasses-standard.scala b/test/files/run/reflection-valueclasses-standard.scala index 18a3d1fa04..b6b5a2ede2 100644 --- a/test/files/run/reflection-valueclasses-standard.scala +++ b/test/files/run/reflection-valueclasses-standard.scala @@ -5,8 +5,8 @@ import scala.reflect.{ClassTag, classTag} object Test extends App { def test[T: ClassTag: TypeTag](x: T) = { println(s"========${classTag[T].runtimeClass}========") - println(cm.reflect(x).reflectMethod(typeOf[T].member(newTermName("getClass")).asMethod)()) - println(cm.reflect(x).reflectMethod(typeOf[T].member(newTermName("toString")).asMethod)()) + println(cm.reflect(x).reflectMethod(typeOf[T].member(TermName("getClass")).asMethod)()) + println(cm.reflect(x).reflectMethod(typeOf[T].member(TermName("toString")).asMethod)()) } test(2.toByte) diff --git a/test/files/run/reify-aliases.check b/test/files/run/reify-aliases.check index aa846b9bc6..da784227af 100644 --- a/test/files/run/reify-aliases.check +++ b/test/files/run/reify-aliases.check @@ -1 +1 @@ -TypeRef(SingleType(ThisType(scala), scala.Predef), newTypeName("String"), List()) +TypeRef(SingleType(ThisType(scala), scala.Predef), TypeName("String"), List()) diff --git a/test/files/run/reify_copypaste1.scala b/test/files/run/reify_copypaste1.scala index c597b7af19..b2eef28026 100644 --- a/test/files/run/reify_copypaste1.scala +++ b/test/files/run/reify_copypaste1.scala @@ -9,8 +9,8 @@ object Test extends App { val output = new java.io.ByteArrayOutputStream() System.setOut(new java.io.PrintStream(output)) val toolBox = currentMirror.mkToolBox(options = "-Yreify-copypaste") - val reify = Select(Select(Select(Select(Ident(ScalaPackage), newTermName("reflect")), newTermName("runtime")), newTermName("universe")), newTermName("reify")) - val reifee = Block(List(ValDef(Modifiers(LAZY), newTermName("x"), TypeTree(), Apply(Ident(ListModule), List(Literal(Constant(1)), Literal(Constant(2)))))), Ident(newTermName("x"))) + val reify = Select(Select(Select(Select(Ident(ScalaPackage), TermName("reflect")), TermName("runtime")), TermName("universe")), TermName("reify")) + val reifee = Block(List(ValDef(Modifiers(LAZY), TermName("x"), TypeTree(), Apply(Ident(ListModule), List(Literal(Constant(1)), Literal(Constant(2)))))), Ident(TermName("x"))) toolBox.eval(Apply(reify, List(reifee))) val Block(List(tpeCopypaste), exprCopypaste @ ModuleDef(_, _, Template(_, _, (_ :: stats) :+ expr))) = toolBox.parse(output.toString()) output.reset() diff --git a/test/files/run/reify_implicits-new.check b/test/files/run/reify_implicits-new.check new file mode 100644 index 0000000000..e3aeb20f6b --- /dev/null +++ b/test/files/run/reify_implicits-new.check @@ -0,0 +1 @@ +x = List(1, 2, 3, 4) diff --git a/test/files/run/reify_implicits-new.scala b/test/files/run/reify_implicits-new.scala new file mode 100644 index 0000000000..42a1deef26 --- /dev/null +++ b/test/files/run/reify_implicits-new.scala @@ -0,0 +1,16 @@ +import scala.reflect.{ClassTag, classTag} +import scala.reflect.runtime.universe._ +import scala.tools.reflect.Eval + +object Test extends App { + reify { + implicit def arrayWrapper[A : ClassTag](x: Array[A]) = + new { + def sort(p: (A, A) => Boolean) = { + util.Sorting.stableSort(x, p); x + } + } + val x = Array(2, 3, 1, 4) + println("x = "+ x.sort((x: Int, y: Int) => x < y).toList) + }.eval +}
\ No newline at end of file diff --git a/test/files/run/reify_implicits-old.check b/test/files/run/reify_implicits-old.check new file mode 100644 index 0000000000..e3aeb20f6b --- /dev/null +++ b/test/files/run/reify_implicits-old.check @@ -0,0 +1 @@ +x = List(1, 2, 3, 4) diff --git a/test/files/run/reify_implicits-old.scala b/test/files/run/reify_implicits-old.scala new file mode 100644 index 0000000000..8ff256d2d4 --- /dev/null +++ b/test/files/run/reify_implicits-old.scala @@ -0,0 +1,15 @@ +import scala.reflect.runtime.universe._ +import scala.tools.reflect.Eval + +object Test extends App { + reify { + implicit def arrayWrapper[A : ClassManifest](x: Array[A]) = + new { + def sort(p: (A, A) => Boolean) = { + util.Sorting.stableSort(x, p); x + } + } + val x = Array(2, 3, 1, 4) + println("x = "+ x.sort((x: Int, y: Int) => x < y).toList) + }.eval +}
\ No newline at end of file diff --git a/test/files/run/reify_newimpl_11.check b/test/files/run/reify_newimpl_11.check index 2f5cb581e6..c019c6db2d 100644 --- a/test/files/run/reify_newimpl_11.check +++ b/test/files/run/reify_newimpl_11.check @@ -1,2 +1,4 @@ -scala.tools.reflect.ToolBoxError: reflective toolbox has failed: -unresolved free type variables (namely: T defined by C in reify_newimpl_11.scala:6:11). have you forgot to use TypeTag annotations for type parameters external to a reifee? if you have troubles tracking free type variables, consider using -Xlog-free-types +scala.tools.reflect.ToolBoxError: reflective toolbox failed due to unresolved free type variables: + T defined by C in reify_newimpl_11.scala:6:11 +have you forgotten to use TypeTag annotations for type parameters external to a reifee? +if you have troubles tracking free type variables, consider using -Xlog-free-types diff --git a/test/files/run/reify_newimpl_13.check b/test/files/run/reify_newimpl_13.check index d518cd7b84..13e3c9af1e 100644 --- a/test/files/run/reify_newimpl_13.check +++ b/test/files/run/reify_newimpl_13.check @@ -1,2 +1,4 @@ -scala.tools.reflect.ToolBoxError: reflective toolbox has failed: -unresolved free type variables (namely: T defined by C in reify_newimpl_13.scala:7:13). have you forgot to use TypeTag annotations for type parameters external to a reifee? if you have troubles tracking free type variables, consider using -Xlog-free-types +scala.tools.reflect.ToolBoxError: reflective toolbox failed due to unresolved free type variables: + T defined by C in reify_newimpl_13.scala:7:13 +have you forgotten to use TypeTag annotations for type parameters external to a reifee? +if you have troubles tracking free type variables, consider using -Xlog-free-types diff --git a/test/files/run/reify_newimpl_19.check b/test/files/run/reify_newimpl_19.check index 8b8652f92c..c749d4f106 100644 --- a/test/files/run/reify_newimpl_19.check +++ b/test/files/run/reify_newimpl_19.check @@ -1,2 +1,4 @@ -scala.tools.reflect.ToolBoxError: reflective toolbox has failed: -unresolved free type variables (namely: T defined by C in reify_newimpl_19.scala:7:10). have you forgot to use TypeTag annotations for type parameters external to a reifee? if you have troubles tracking free type variables, consider using -Xlog-free-types +scala.tools.reflect.ToolBoxError: reflective toolbox failed due to unresolved free type variables: + T defined by C in reify_newimpl_19.scala:7:10 +have you forgotten to use TypeTag annotations for type parameters external to a reifee? +if you have troubles tracking free type variables, consider using -Xlog-free-types diff --git a/test/files/run/reify_newimpl_22.check b/test/files/run/reify_newimpl_22.check index dcb3e2889b..e68fe2f6b1 100644 --- a/test/files/run/reify_newimpl_22.check +++ b/test/files/run/reify_newimpl_22.check @@ -19,7 +19,7 @@ scala> { } println(code.eval) } -<console>:15: free term: Ident(newTermName("x")) defined by res0 in <console>:14:21 +<console>:15: free term: Ident(TermName("x")) defined by res0 in <console>:14:21 val code = reify { ^ 2 diff --git a/test/files/run/reify_newimpl_23.check b/test/files/run/reify_newimpl_23.check index 882124657e..38c95646a8 100644 --- a/test/files/run/reify_newimpl_23.check +++ b/test/files/run/reify_newimpl_23.check @@ -18,7 +18,7 @@ scala> def foo[T]{ } println(code.eval) } -<console>:13: free type: Ident(newTypeName("T")) defined by foo in <console>:12:16 +<console>:13: free type: Ident(TypeName("T")) defined by foo in <console>:12:16 val code = reify { ^ foo: [T]=> Unit diff --git a/test/files/run/reify_newimpl_25.check b/test/files/run/reify_newimpl_25.check index d1028b94c7..86f6abce02 100644 --- a/test/files/run/reify_newimpl_25.check +++ b/test/files/run/reify_newimpl_25.check @@ -9,7 +9,7 @@ scala> { val tt = implicitly[TypeTag[x.type]] println(tt) } -<console>:11: free term: Ident(newTermName("x")) defined by res0 in <console>:10:21 +<console>:11: free term: Ident(TermName("x")) defined by res0 in <console>:10:21 val tt = implicitly[TypeTag[x.type]] ^ TypeTag[x.type] diff --git a/test/files/run/reify_newimpl_26.check b/test/files/run/reify_newimpl_26.check index 347f6365aa..d3e2540de0 100644 --- a/test/files/run/reify_newimpl_26.check +++ b/test/files/run/reify_newimpl_26.check @@ -8,7 +8,7 @@ scala> def foo[T]{ val tt = implicitly[WeakTypeTag[List[T]]] println(tt) } -<console>:9: free type: Ident(newTypeName("T")) defined by foo in <console>:7:16 +<console>:9: free type: Ident(TypeName("T")) defined by foo in <console>:7:16 val tt = implicitly[WeakTypeTag[List[T]]] ^ foo: [T]=> Unit diff --git a/test/files/run/reify_printf.scala b/test/files/run/reify_printf.scala index 272856b962..9932a58dfa 100644 --- a/test/files/run/reify_printf.scala +++ b/test/files/run/reify_printf.scala @@ -23,7 +23,7 @@ object Test extends App { */ var i = 0 - def gensym(name: String) = { i += 1; newTermName(name + i) } + def gensym(name: String) = { i += 1; TermName(name + i) } def createTempValDef( value : Tree, tpe : Type ) : (Option[Tree],Tree) = { val local = gensym("temp") @@ -59,10 +59,10 @@ object Test extends App { Apply( Select( Select( - Ident( newTermName("scala") ) - , newTermName("Predef") + Ident( TermName("scala") ) + , TermName("Predef") ) - , newTermName("print") + , TermName("print") ) , List(ref) ): Tree diff --git a/test/files/run/repl-bare-expr.check b/test/files/run/repl-bare-expr.check index 8b6434e986..a92243c7c0 100644 --- a/test/files/run/repl-bare-expr.check +++ b/test/files/run/repl-bare-expr.check @@ -31,7 +31,7 @@ scala> 5 ; 10 ; case object Cow ; 20 ; class Moo { override def toString = "Mooo <console>:7: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses 5 ; 10 ; case object Cow ; 20 ; class Moo { override def toString = "Moooooo" } ; 30 ; def bippy = { ^ -defined module Cow +defined object Cow defined class Moo bippy: Int res2: Int = 105 @@ -39,7 +39,7 @@ res2: Int = 105 scala> scala> object Bovine { var x: List[_] = null } ; case class Ruminant(x: Int) ; bippy * bippy * bippy -defined module Bovine +defined object Bovine defined class Ruminant res3: Int = 216 diff --git a/test/files/run/repl-colon-type.check b/test/files/run/repl-colon-type.check index 56ddd74375..4cd0e1d588 100644 --- a/test/files/run/repl-colon-type.check +++ b/test/files/run/repl-colon-type.check @@ -14,7 +14,6 @@ scala> :type List[1, 2, 3] List[1, 2, 3] ^ - scala> :type List(1, 2, 3) List[Int] @@ -52,10 +51,9 @@ scala> :type protected lazy val f = 5 Access to protected value f not permitted because enclosing object $eval in package $line19 is not a subclass of object $iw where target is defined - lazy val $result = `f` + lazy val $result = f ^ - scala> :type def f = 5 => Int diff --git a/test/files/run/repl-empty-package.check b/test/files/run/repl-empty-package.check new file mode 100644 index 0000000000..ecf79c2c6d --- /dev/null +++ b/test/files/run/repl-empty-package.check @@ -0,0 +1,7 @@ +Type in expressions to have them evaluated. +Type :help for more information. + +scala> println(Bippy.bippy) +bippy! + +scala> diff --git a/test/files/run/repl-empty-package/s_1.scala b/test/files/run/repl-empty-package/s_1.scala new file mode 100644 index 0000000000..b59d16b338 --- /dev/null +++ b/test/files/run/repl-empty-package/s_1.scala @@ -0,0 +1,3 @@ +object Bippy { + def bippy = "bippy!" +} diff --git a/test/files/run/repl-empty-package/s_2.scala b/test/files/run/repl-empty-package/s_2.scala new file mode 100644 index 0000000000..512e6dd382 --- /dev/null +++ b/test/files/run/repl-empty-package/s_2.scala @@ -0,0 +1,5 @@ +import scala.tools.partest.ReplTest + +object Test extends ReplTest { + def code = "println(Bippy.bippy)" +} diff --git a/test/files/run/repl-javap-def.scala b/test/files/run/repl-javap-def.scala new file mode 100644 index 0000000000..dbd769613a --- /dev/null +++ b/test/files/run/repl-javap-def.scala @@ -0,0 +1,17 @@ +import scala.tools.partest.JavapTest + +object Test extends JavapTest { + def code = """ + |def f = 7 + |:javap -public -raw f + """.stripMargin + + // it should find f wrapped in repl skins. replstiltskin. + override def yah(res: Seq[String]) = { + // replstiltskin: what be my name? + val keywords = List("public", "class", "line") + def isLineClass(s: String) = keywords forall (s contains _) + def filtered = res filter isLineClass + 1 == filtered.size + } +} diff --git a/test/files/run/repl-javap-fun.scala b/test/files/run/repl-javap-fun.scala new file mode 100644 index 0000000000..5c9a6b7691 --- /dev/null +++ b/test/files/run/repl-javap-fun.scala @@ -0,0 +1,16 @@ +import scala.tools.partest.JavapTest + +object Test extends JavapTest { + def code = """ + |object Betty { + | List(1,2,3) filter (_ % 2 != 0) map (_ * 2) + |} + |:javap -fun Betty + """.stripMargin + + // two anonfuns of Betty + override def yah(res: Seq[String]) = { + def filtered = res filter (_ contains "public final class Betty") + 2 == filtered.size + } +} diff --git a/test/files/run/repl-javap-mem.scala b/test/files/run/repl-javap-mem.scala new file mode 100644 index 0000000000..8db30e835c --- /dev/null +++ b/test/files/run/repl-javap-mem.scala @@ -0,0 +1,19 @@ +import scala.tools.partest.JavapTest + +object Test extends JavapTest { + def code = """ + |object Betty { + | val ds = List(1,2,3) filter (_ % 2 == 0) map (_ * 3) + | def m(vs: List[Int]) = vs filter (_ % 2 != 0) map (_ * 2) + |} + |:javap Betty#m + """.stripMargin + + // filter for requested method member + override def yah(res: Seq[String]) = { + // cheaply, methods end in arg list + val p = """.*m\(.*\);""".r + def filtered = res filter (_ match { case p() => true case _ => false }) + 1 == filtered.size + } +} diff --git a/test/files/run/repl-javap-memfun.scala b/test/files/run/repl-javap-memfun.scala new file mode 100644 index 0000000000..d2b4243c8b --- /dev/null +++ b/test/files/run/repl-javap-memfun.scala @@ -0,0 +1,18 @@ +import scala.tools.partest.JavapTest + +object Test extends JavapTest { + 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]) = { + def filtered = res filter (_ contains "public final class Betty") + 3 == filtered.size + } +} diff --git a/test/files/run/repl-javap-more-fun.scala b/test/files/run/repl-javap-more-fun.scala new file mode 100644 index 0000000000..e603faf75a --- /dev/null +++ b/test/files/run/repl-javap-more-fun.scala @@ -0,0 +1,17 @@ +import scala.tools.partest.JavapTest + +object Test extends JavapTest { + def code = """ + |object Betty { + | val ds = List(1,2,3) filter (_ % 2 == 0) map (_ * 3) + | def m(vs: List[Int]) = vs filter (_ % 2 != 0) map (_ * 2) + |} + |:javap -fun Betty + """.stripMargin + + // two anonfuns of Betty + override def yah(res: Seq[String]) = { + def filtered = res filter (_ contains "public final class Betty") + 4 == filtered.size + } +} diff --git a/test/files/run/repl-javap-outdir-funs/foo_1.scala b/test/files/run/repl-javap-outdir-funs/foo_1.scala new file mode 100644 index 0000000000..9b98e94733 --- /dev/null +++ b/test/files/run/repl-javap-outdir-funs/foo_1.scala @@ -0,0 +1,6 @@ + +package disktest + +class Foo { + def m(vs: List[Int]) = vs map (_ + 1) +} 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 new file mode 100644 index 0000000000..dfe3dae270 --- /dev/null +++ b/test/files/run/repl-javap-outdir-funs/run-repl_7.scala @@ -0,0 +1,12 @@ +import scala.tools.partest.JavapTest + +object Test extends JavapTest { + def code = """ + |:javap -fun disktest/Foo.class + """.stripMargin + + override def yah(res: Seq[String]) = { + def filtered = res filter (_ contains "public final class disktest.Foo") + 1 == filtered.size + } +} diff --git a/test/files/run/repl-javap-outdir/foo_1.scala b/test/files/run/repl-javap-outdir/foo_1.scala new file mode 100644 index 0000000000..9b98e94733 --- /dev/null +++ b/test/files/run/repl-javap-outdir/foo_1.scala @@ -0,0 +1,6 @@ + +package disktest + +class Foo { + def m(vs: List[Int]) = vs map (_ + 1) +} diff --git a/test/files/run/repl-javap-outdir/run-repl_7.scala b/test/files/run/repl-javap-outdir/run-repl_7.scala new file mode 100644 index 0000000000..dc2c5719ff --- /dev/null +++ b/test/files/run/repl-javap-outdir/run-repl_7.scala @@ -0,0 +1,12 @@ +import scala.tools.partest.JavapTest + +object Test extends JavapTest { + def code = """ + |:javap disktest/Foo.class + """.stripMargin + + override def yah(res: Seq[String]) = { + def filtered = res filter (_ contains "public class disktest.Foo") + 1 == filtered.size + } +} diff --git a/test/files/run/repl-javap.scala b/test/files/run/repl-javap.scala new file mode 100644 index 0000000000..7a19852d4e --- /dev/null +++ b/test/files/run/repl-javap.scala @@ -0,0 +1,13 @@ +import scala.tools.partest.JavapTest + +object Test extends JavapTest { + def code = """ + |case class Betty(i: Int) { def next = Betty(i+1) } + |:javap Betty + """.stripMargin + + override def yah(res: Seq[String]) = { + def filtered = res filter (_ contains "public class Betty") + 1 == filtered.size + } +} diff --git a/test/files/run/repl-out-dir.check b/test/files/run/repl-out-dir.check new file mode 100644 index 0000000000..a96f9ba9d9 --- /dev/null +++ b/test/files/run/repl-out-dir.check @@ -0,0 +1,53 @@ +Type in expressions to have them evaluated. +Type :help for more information. + +scala> + +scala> case class Bippy(x: Int) +defined class Bippy + +scala> val x = Bippy(1) +x: Bippy = Bippy(1) + +scala> $intp.showDirectory +repl-out-dir-run.obj + $line1 + $eval$.class + $eval.class + $line2 + $eval$.class + $eval.class + $read$$iw$$iw$.class + $read$$iw$.class + $read$.class + $read.class + $line3 + $eval$.class + $eval.class + $read$$iw$$iw$.class + $read$$iw$$iw$Bippy$.class + $read$$iw$$iw$Bippy.class + $read$$iw$.class + $read$.class + $read.class + $line4 + $eval$.class + $eval.class + $read$$iw$$iw$.class + $read$$iw$.class + $read$.class + $read.class + $line5 + $eval$.class + $eval.class + $read$$iw$$iw$.class + $read$$iw$.class + $read$.class + $read.class + $repl_$init.class + Test$.class + Test.class + +scala> + +scala> diff --git a/test/files/run/repl-out-dir.scala b/test/files/run/repl-out-dir.scala new file mode 100644 index 0000000000..33c823aa2d --- /dev/null +++ b/test/files/run/repl-out-dir.scala @@ -0,0 +1,13 @@ +import scala.tools.partest.ReplTest +import scala.tools.nsc.Settings + +object Test extends ReplTest { + override def extraSettings = s"-Yrepl-outdir ${testOutput.path}" + + def code = s""" +case class Bippy(x: Int) +val x = Bippy(1) +$$intp.showDirectory + """ + +} diff --git a/test/files/run/repl-paste.check b/test/files/run/repl-paste.check index d3e171fbfb..e4c407c6e8 100644 --- a/test/files/run/repl-paste.check +++ b/test/files/run/repl-paste.check @@ -21,7 +21,7 @@ val x = (new Dingus).y // Exiting paste mode, now interpreting. defined class Dingus -defined module Dingus +defined object Dingus x: Int = 110 scala> diff --git a/test/files/run/search.check b/test/files/run/search.check new file mode 100644 index 0000000000..a885696509 --- /dev/null +++ b/test/files/run/search.check @@ -0,0 +1,6 @@ +Found(2) +Found(4) +InsertionPoint(9) +Found(2) +Found(4) +InsertionPoint(9) diff --git a/test/files/run/search.scala b/test/files/run/search.scala new file mode 100644 index 0000000000..ed7fed54a7 --- /dev/null +++ b/test/files/run/search.scala @@ -0,0 +1,14 @@ +object Test extends App { + import scala.collection.{LinearSeq, IndexedSeq} + import scala.collection.Searching.search + + val ls = LinearSeq(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 13) + println(ls.search(3)) + println(ls.search(5, 3, 8)) + println(ls.search(12)) + + val is = IndexedSeq(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 13) + println(is.search(3)) + println(is.search(5, 3, 8)) + println(is.search(12)) +} diff --git a/test/files/run/settings-parse.check b/test/files/run/settings-parse.check new file mode 100644 index 0000000000..18145c9100 --- /dev/null +++ b/test/files/run/settings-parse.check @@ -0,0 +1,566 @@ +0) List(-cp, ) ==> Settings { + -d = . + -classpath = "" +} + +1) List(-cp, , ) ==> Settings { + -d = . + -classpath = "" +} + +2) List(, -cp, ) ==> Settings { + -d = . + -classpath = "" +} + +3) List(-cp, , -deprecation) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +4) List(-cp, , , -deprecation) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +5) List(-cp, , -deprecation, ) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +6) List(, -cp, , -deprecation) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +7) List(-cp, , -deprecation, foo.scala) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +8) List(-cp, , , -deprecation, foo.scala) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +9) List(-cp, , -deprecation, , foo.scala) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +10) List(-cp, , -deprecation, foo.scala, ) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +11) List(, -cp, , -deprecation, foo.scala) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +12) List(-cp, , foo.scala) ==> Settings { + -d = . + -classpath = "" +} + +13) List(-cp, , , foo.scala) ==> Settings { + -d = . + -classpath = "" +} + +14) List(-cp, , foo.scala, ) ==> Settings { + -d = . + -classpath = "" +} + +15) List(, -cp, , foo.scala) ==> Settings { + -d = . + -classpath = "" +} + +16) List(-cp, , foo.scala, -deprecation) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +17) List(-cp, , , foo.scala, -deprecation) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +18) List(-cp, , foo.scala, , -deprecation) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +19) List(-cp, , foo.scala, -deprecation, ) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +20) List(, -cp, , foo.scala, -deprecation) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +21) List(-deprecation, -cp, ) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +22) List(, -deprecation, -cp, ) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +23) List(-deprecation, -cp, , ) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +24) List(-deprecation, , -cp, ) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +25) List(-deprecation, -cp, , foo.scala) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +26) List(, -deprecation, -cp, , foo.scala) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +27) List(-deprecation, -cp, , , foo.scala) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +28) List(-deprecation, -cp, , foo.scala, ) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +29) List(-deprecation, , -cp, , foo.scala) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +30) List(-deprecation, foo.scala, -cp, ) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +31) List(, -deprecation, foo.scala, -cp, ) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +32) List(-deprecation, , foo.scala, -cp, ) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +33) List(-deprecation, foo.scala, -cp, , ) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +34) List(-deprecation, foo.scala, , -cp, ) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +35) List(foo.scala, -cp, ) ==> Settings { + -d = . + -classpath = "" +} + +36) List(, foo.scala, -cp, ) ==> Settings { + -d = . + -classpath = "" +} + +37) List(foo.scala, -cp, , ) ==> Settings { + -d = . + -classpath = "" +} + +38) List(foo.scala, , -cp, ) ==> Settings { + -d = . + -classpath = "" +} + +39) List(foo.scala, -cp, , -deprecation) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +40) List(, foo.scala, -cp, , -deprecation) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +41) List(foo.scala, -cp, , , -deprecation) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +42) List(foo.scala, -cp, , -deprecation, ) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +43) List(foo.scala, , -cp, , -deprecation) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +44) List(foo.scala, -deprecation, -cp, ) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +45) List(, foo.scala, -deprecation, -cp, ) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +46) List(foo.scala, , -deprecation, -cp, ) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +47) List(foo.scala, -deprecation, -cp, , ) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +48) List(foo.scala, -deprecation, , -cp, ) ==> Settings { + -d = . + -deprecation = true + -classpath = "" +} + +0) List(-cp, /tmp:/bippy) ==> Settings { + -d = . + -classpath = /tmp:/bippy +} + +1) List(-cp, /tmp:/bippy, ) ==> Settings { + -d = . + -classpath = /tmp:/bippy +} + +2) List(, -cp, /tmp:/bippy) ==> Settings { + -d = . + -classpath = /tmp:/bippy +} + +3) List(-cp, /tmp:/bippy, -deprecation) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +4) List(-cp, /tmp:/bippy, , -deprecation) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +5) List(-cp, /tmp:/bippy, -deprecation, ) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +6) List(, -cp, /tmp:/bippy, -deprecation) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +7) List(-cp, /tmp:/bippy, -deprecation, foo.scala) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +8) List(-cp, /tmp:/bippy, , -deprecation, foo.scala) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +9) List(-cp, /tmp:/bippy, -deprecation, , foo.scala) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +10) List(-cp, /tmp:/bippy, -deprecation, foo.scala, ) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +11) List(, -cp, /tmp:/bippy, -deprecation, foo.scala) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +12) List(-cp, /tmp:/bippy, foo.scala) ==> Settings { + -d = . + -classpath = /tmp:/bippy +} + +13) List(-cp, /tmp:/bippy, , foo.scala) ==> Settings { + -d = . + -classpath = /tmp:/bippy +} + +14) List(-cp, /tmp:/bippy, foo.scala, ) ==> Settings { + -d = . + -classpath = /tmp:/bippy +} + +15) List(, -cp, /tmp:/bippy, foo.scala) ==> Settings { + -d = . + -classpath = /tmp:/bippy +} + +16) List(-cp, /tmp:/bippy, foo.scala, -deprecation) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +17) List(-cp, /tmp:/bippy, , foo.scala, -deprecation) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +18) List(-cp, /tmp:/bippy, foo.scala, , -deprecation) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +19) List(-cp, /tmp:/bippy, foo.scala, -deprecation, ) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +20) List(, -cp, /tmp:/bippy, foo.scala, -deprecation) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +21) List(-deprecation, -cp, /tmp:/bippy) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +22) List(, -deprecation, -cp, /tmp:/bippy) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +23) List(-deprecation, -cp, /tmp:/bippy, ) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +24) List(-deprecation, , -cp, /tmp:/bippy) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +25) List(-deprecation, -cp, /tmp:/bippy, foo.scala) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +26) List(, -deprecation, -cp, /tmp:/bippy, foo.scala) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +27) List(-deprecation, -cp, /tmp:/bippy, , foo.scala) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +28) List(-deprecation, -cp, /tmp:/bippy, foo.scala, ) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +29) List(-deprecation, , -cp, /tmp:/bippy, foo.scala) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +30) List(-deprecation, foo.scala, -cp, /tmp:/bippy) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +31) List(, -deprecation, foo.scala, -cp, /tmp:/bippy) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +32) List(-deprecation, , foo.scala, -cp, /tmp:/bippy) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +33) List(-deprecation, foo.scala, -cp, /tmp:/bippy, ) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +34) List(-deprecation, foo.scala, , -cp, /tmp:/bippy) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +35) List(foo.scala, -cp, /tmp:/bippy) ==> Settings { + -d = . + -classpath = /tmp:/bippy +} + +36) List(, foo.scala, -cp, /tmp:/bippy) ==> Settings { + -d = . + -classpath = /tmp:/bippy +} + +37) List(foo.scala, -cp, /tmp:/bippy, ) ==> Settings { + -d = . + -classpath = /tmp:/bippy +} + +38) List(foo.scala, , -cp, /tmp:/bippy) ==> Settings { + -d = . + -classpath = /tmp:/bippy +} + +39) List(foo.scala, -cp, /tmp:/bippy, -deprecation) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +40) List(, foo.scala, -cp, /tmp:/bippy, -deprecation) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +41) List(foo.scala, -cp, /tmp:/bippy, , -deprecation) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +42) List(foo.scala, -cp, /tmp:/bippy, -deprecation, ) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +43) List(foo.scala, , -cp, /tmp:/bippy, -deprecation) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +44) List(foo.scala, -deprecation, -cp, /tmp:/bippy) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +45) List(, foo.scala, -deprecation, -cp, /tmp:/bippy) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +46) List(foo.scala, , -deprecation, -cp, /tmp:/bippy) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +47) List(foo.scala, -deprecation, -cp, /tmp:/bippy, ) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + +48) List(foo.scala, -deprecation, , -cp, /tmp:/bippy) ==> Settings { + -d = . + -deprecation = true + -classpath = /tmp:/bippy +} + diff --git a/test/files/run/settings-parse.scala b/test/files/run/settings-parse.scala new file mode 100644 index 0000000000..2b04f55b24 --- /dev/null +++ b/test/files/run/settings-parse.scala @@ -0,0 +1,27 @@ +import scala.tools.nsc._ + +object Test { + val tokens = List("", "-deprecation", "foo.scala") + val subsets = tokens.toSet.subsets.toList + val permutations0 = subsets.flatMap(_.toList.permutations).distinct + + def runWithCp(cp: String) = { + val permutations = permutations0 flatMap ("-cp CPTOKEN" :: _ permutations) + + for ((p, i) <- permutations.distinct.sortBy(_ mkString "").zipWithIndex) { + val args = p flatMap (_ split "\\s+") map (x => if (x == "CPTOKEN") cp else x) + val s = new settings.MutableSettings(println) + val (ok, residual) = s.processArguments(args, processAll = true) + + val expected = args filter (_ == "foo.scala") + assert(residual == expected, residual) + assert(ok, args) + println(s"$i) $args ==> $s") + } + } + + def main(args0: Array[String]): Unit = { + runWithCp("") + runWithCp("/tmp:/bippy") + } +} diff --git a/test/files/run/shortClass.check b/test/files/run/shortClass.check new file mode 100644 index 0000000000..fbdb725cca --- /dev/null +++ b/test/files/run/shortClass.check @@ -0,0 +1,10 @@ +bippity.bop.Foo +bippity.bop.Foo$Bar +bippity.bop.Foo$Bar$ +Test$$anon$1 +Test$$anon$2 +Foo +Bar +Bar$ +Foo with DingDongBippy +Bar with DingDongBippy diff --git a/test/files/run/shortClass.scala b/test/files/run/shortClass.scala new file mode 100644 index 0000000000..b7bb016896 --- /dev/null +++ b/test/files/run/shortClass.scala @@ -0,0 +1,24 @@ +import scala.reflect.internal.util._ + +package bippity { + trait DingDongBippy + + package bop { + class Foo { + class Bar + object Bar + } + } +} + +object Test { + import bippity._ + import bop._ + + def main(args: Array[String]): Unit = { + val f = new Foo + val instances = List(f, new f.Bar, f.Bar, new Foo with DingDongBippy, new f.Bar with DingDongBippy) + instances map (_.getClass.getName) foreach println + instances map shortClassOfInstance foreach println + } +} diff --git a/test/files/run/showraw_aliases.check b/test/files/run/showraw_aliases.check index aebd354031..d6a198b1cb 100644 --- a/test/files/run/showraw_aliases.check +++ b/test/files/run/showraw_aliases.check @@ -1,2 +1,2 @@ -Block(List(Import(Select(Select(Ident(scala), scala.reflect), scala.reflect.runtime), List(ImportSelector(newTermName("universe"), <offset>, newTermName("ru"), <offset>)))), Select(Select(Select(Select(Ident(scala), scala.reflect), scala.reflect.runtime), scala.reflect.runtime.package), [newTermName("universe") aka newTermName("ru")])) -Block(List(Import(Select(Select(Ident(scala#<id>), scala.reflect#<id>), scala.reflect.runtime#<id>), List(ImportSelector(newTermName("universe"), <offset>, newTermName("ru"), <offset>)))), Select(Select(Select(Select(Ident(scala#<id>), scala.reflect#<id>), scala.reflect.runtime#<id>), scala.reflect.runtime.package#<id>), [newTermName("universe")#<id> aka newTermName("ru")])) +Block(List(Import(Select(Select(Ident(scala), scala.reflect), scala.reflect.runtime), List(ImportSelector(TermName("universe"), <offset>, TermName("ru"), <offset>)))), Select(Select(Select(Select(Ident(scala), scala.reflect), scala.reflect.runtime), scala.reflect.runtime.package), [TermName("universe") aka TermName("ru")])) +Block(List(Import(Select(Select(Ident(scala#<id>), scala.reflect#<id>), scala.reflect.runtime#<id>), List(ImportSelector(TermName("universe"), <offset>, TermName("ru"), <offset>)))), Select(Select(Select(Select(Ident(scala#<id>), scala.reflect#<id>), scala.reflect.runtime#<id>), scala.reflect.runtime.package#<id>), [TermName("universe")#<id> aka TermName("ru")])) diff --git a/test/files/run/showraw_mods.check b/test/files/run/showraw_mods.check index 7fca027614..3ec868542d 100644 --- a/test/files/run/showraw_mods.check +++ b/test/files/run/showraw_mods.check @@ -1 +1 @@ -Block(List(ClassDef(Modifiers(ABSTRACT | DEFAULTPARAM/TRAIT), newTypeName("C"), List(), Template(List(Ident(newTypeName("AnyRef"))), emptyValDef, List(DefDef(Modifiers(), newTermName("$init$"), List(), List(List()), TypeTree(), Block(List(), Literal(Constant(())))), ValDef(Modifiers(PRIVATE | LOCAL), newTermName("x"), TypeTree(), Literal(Constant(2))), ValDef(Modifiers(MUTABLE), newTermName("y"), TypeTree(), Select(This(newTypeName("C")), newTermName("x"))), ValDef(Modifiers(LAZY), newTermName("z"), TypeTree(), Select(This(newTypeName("C")), newTermName("y"))))))), Literal(Constant(()))) +Block(List(ClassDef(Modifiers(ABSTRACT | DEFAULTPARAM/TRAIT), TypeName("C"), List(), Template(List(Ident(TypeName("AnyRef"))), emptyValDef, List(DefDef(Modifiers(), TermName("$init$"), List(), List(List()), TypeTree(), Block(List(), Literal(Constant(())))), ValDef(Modifiers(PRIVATE | LOCAL), TermName("x"), TypeTree(), Literal(Constant(2))), ValDef(Modifiers(MUTABLE), TermName("y"), TypeTree(), Select(This(TypeName("C")), TermName("x"))), ValDef(Modifiers(LAZY), TermName("z"), TypeTree(), Select(This(TypeName("C")), TermName("y"))))))), Literal(Constant(()))) diff --git a/test/files/run/showraw_tree.check b/test/files/run/showraw_tree.check index dca272684e..0416b12568 100644 --- a/test/files/run/showraw_tree.check +++ b/test/files/run/showraw_tree.check @@ -1,2 +1,2 @@ -Apply(Select(New(AppliedTypeTree(Ident(scala.collection.immutable.HashMap), List(Ident(newTypeName("String")), Ident(newTypeName("String"))))), nme.CONSTRUCTOR), List()) -Apply(Select(New(AppliedTypeTree(Ident(scala.collection.mutable.HashMap), List(Ident(newTypeName("String")), Ident(newTypeName("String"))))), nme.CONSTRUCTOR), List()) +Apply(Select(New(AppliedTypeTree(Ident(scala.collection.immutable.HashMap), List(Ident(TypeName("String")), Ident(TypeName("String"))))), nme.CONSTRUCTOR), List()) +Apply(Select(New(AppliedTypeTree(Ident(scala.collection.mutable.HashMap), List(Ident(TypeName("String")), Ident(TypeName("String"))))), nme.CONSTRUCTOR), List()) diff --git a/test/files/run/showraw_tree_ids.check b/test/files/run/showraw_tree_ids.check index d25599c7fc..6e17bf2fb4 100644 --- a/test/files/run/showraw_tree_ids.check +++ b/test/files/run/showraw_tree_ids.check @@ -1,2 +1,2 @@ -Apply(Select(New(AppliedTypeTree(Ident(scala.collection.immutable.HashMap#<id>), List(Ident(newTypeName("String")#<id>), Ident(newTypeName("String")#<id>)))), nme.CONSTRUCTOR), List()) -Apply(Select(New(AppliedTypeTree(Ident(scala.collection.mutable.HashMap#<id>), List(Ident(newTypeName("String")#<id>), Ident(newTypeName("String")#<id>)))), nme.CONSTRUCTOR), List()) +Apply(Select(New(AppliedTypeTree(Ident(scala.collection.immutable.HashMap#<id>), List(Ident(TypeName("String")#<id>), Ident(TypeName("String")#<id>)))), nme.CONSTRUCTOR), List()) +Apply(Select(New(AppliedTypeTree(Ident(scala.collection.mutable.HashMap#<id>), List(Ident(TypeName("String")#<id>), Ident(TypeName("String")#<id>)))), nme.CONSTRUCTOR), List()) diff --git a/test/files/run/showraw_tree_kinds.check b/test/files/run/showraw_tree_kinds.check index d0d4cd0058..16147a64f4 100644 --- a/test/files/run/showraw_tree_kinds.check +++ b/test/files/run/showraw_tree_kinds.check @@ -1,2 +1,2 @@ -Apply(Select(New(AppliedTypeTree(Ident(scala.collection.immutable.HashMap#CLS), List(Ident(newTypeName("String")#TPE), Ident(newTypeName("String")#TPE)))), nme.CONSTRUCTOR), List()) -Apply(Select(New(AppliedTypeTree(Ident(scala.collection.mutable.HashMap#CLS), List(Ident(newTypeName("String")#TPE), Ident(newTypeName("String")#TPE)))), nme.CONSTRUCTOR), List()) +Apply(Select(New(AppliedTypeTree(Ident(scala.collection.immutable.HashMap#CLS), List(Ident(TypeName("String")#TPE), Ident(TypeName("String")#TPE)))), nme.CONSTRUCTOR), List()) +Apply(Select(New(AppliedTypeTree(Ident(scala.collection.mutable.HashMap#CLS), List(Ident(TypeName("String")#TPE), Ident(TypeName("String")#TPE)))), nme.CONSTRUCTOR), List()) diff --git a/test/files/run/showraw_tree_types_ids.check b/test/files/run/showraw_tree_types_ids.check index 92ee45a1e6..c98b16e956 100644 --- a/test/files/run/showraw_tree_types_ids.check +++ b/test/files/run/showraw_tree_types_ids.check @@ -1,10 +1,10 @@ -Apply[1](Select[2](New[1](TypeTree[1]().setOriginal(AppliedTypeTree(Ident[3](scala.collection.immutable.HashMap#<id>), List(TypeTree[4]().setOriginal(Ident[4](newTypeName("String")#<id>)), TypeTree[4]().setOriginal(Ident[4](newTypeName("String")#<id>)))))), nme.CONSTRUCTOR#<id>), List()) -[1] TypeRef(ThisType(scala.collection.immutable#<id>), scala.collection.immutable.HashMap#<id>, List(TypeRef(ThisType(scala.Predef#<id>), newTypeName("String")#<id>, List()), TypeRef(ThisType(scala.Predef#<id>), newTypeName("String")#<id>, List()))) -[2] MethodType(List(), TypeRef(ThisType(scala.collection.immutable#<id>), scala.collection.immutable.HashMap#<id>, List(TypeRef(ThisType(scala.Predef#<id>), newTypeName("String")#<id>, List()), TypeRef(ThisType(scala.Predef#<id>), newTypeName("String")#<id>, List())))) +Apply[1](Select[2](New[1](TypeTree[1]().setOriginal(AppliedTypeTree(Ident[3](scala.collection.immutable.HashMap#<id>), List(TypeTree[4]().setOriginal(Ident[4](TypeName("String")#<id>)), TypeTree[4]().setOriginal(Ident[4](TypeName("String")#<id>)))))), nme.CONSTRUCTOR#<id>), List()) +[1] TypeRef(ThisType(scala.collection.immutable#<id>), scala.collection.immutable.HashMap#<id>, List(TypeRef(ThisType(scala.Predef#<id>), TypeName("String")#<id>, List()), TypeRef(ThisType(scala.Predef#<id>), TypeName("String")#<id>, List()))) +[2] MethodType(List(), TypeRef(ThisType(scala.collection.immutable#<id>), scala.collection.immutable.HashMap#<id>, List(TypeRef(ThisType(scala.Predef#<id>), TypeName("String")#<id>, List()), TypeRef(ThisType(scala.Predef#<id>), TypeName("String")#<id>, List())))) [3] TypeRef(ThisType(scala.collection.immutable#<id>), scala.collection.immutable.HashMap#<id>, List()) -[4] TypeRef(ThisType(scala.Predef#<id>), newTypeName("String")#<id>, List()) -Apply[5](Select[6](New[5](TypeTree[5]().setOriginal(AppliedTypeTree(Ident[7](scala.collection.mutable.HashMap#<id>), List(TypeTree[4]().setOriginal(Ident[4](newTypeName("String")#<id>)), TypeTree[4]().setOriginal(Ident[4](newTypeName("String")#<id>)))))), nme.CONSTRUCTOR#<id>), List()) -[4] TypeRef(ThisType(scala.Predef#<id>), newTypeName("String")#<id>, List()) -[5] TypeRef(ThisType(scala.collection.mutable#<id>), scala.collection.mutable.HashMap#<id>, List(TypeRef(ThisType(scala.Predef#<id>), newTypeName("String")#<id>, List()), TypeRef(ThisType(scala.Predef#<id>), newTypeName("String")#<id>, List()))) -[6] MethodType(List(), TypeRef(ThisType(scala.collection.mutable#<id>), scala.collection.mutable.HashMap#<id>, List(TypeRef(ThisType(scala.Predef#<id>), newTypeName("String")#<id>, List()), TypeRef(ThisType(scala.Predef#<id>), newTypeName("String")#<id>, List())))) +[4] TypeRef(ThisType(scala.Predef#<id>), TypeName("String")#<id>, List()) +Apply[5](Select[6](New[5](TypeTree[5]().setOriginal(AppliedTypeTree(Ident[7](scala.collection.mutable.HashMap#<id>), List(TypeTree[4]().setOriginal(Ident[4](TypeName("String")#<id>)), TypeTree[4]().setOriginal(Ident[4](TypeName("String")#<id>)))))), nme.CONSTRUCTOR#<id>), List()) +[4] TypeRef(ThisType(scala.Predef#<id>), TypeName("String")#<id>, List()) +[5] TypeRef(ThisType(scala.collection.mutable#<id>), scala.collection.mutable.HashMap#<id>, List(TypeRef(ThisType(scala.Predef#<id>), TypeName("String")#<id>, List()), TypeRef(ThisType(scala.Predef#<id>), TypeName("String")#<id>, List()))) +[6] MethodType(List(), TypeRef(ThisType(scala.collection.mutable#<id>), scala.collection.mutable.HashMap#<id>, List(TypeRef(ThisType(scala.Predef#<id>), TypeName("String")#<id>, List()), TypeRef(ThisType(scala.Predef#<id>), TypeName("String")#<id>, List())))) [7] TypeRef(ThisType(scala.collection.mutable#<id>), scala.collection.mutable.HashMap#<id>, List()) diff --git a/test/files/run/showraw_tree_types_typed.check b/test/files/run/showraw_tree_types_typed.check index c6c20409dc..30dda7d18b 100644 --- a/test/files/run/showraw_tree_types_typed.check +++ b/test/files/run/showraw_tree_types_typed.check @@ -1,10 +1,10 @@ -Apply[1](Select[2](New[1](TypeTree[1]().setOriginal(AppliedTypeTree(Ident[3](scala.collection.immutable.HashMap), List(TypeTree[4]().setOriginal(Ident[4](newTypeName("String"))), TypeTree[4]().setOriginal(Ident[4](newTypeName("String"))))))), nme.CONSTRUCTOR), List()) -[1] TypeRef(ThisType(scala.collection.immutable), scala.collection.immutable.HashMap, List(TypeRef(ThisType(scala.Predef), newTypeName("String"), List()), TypeRef(ThisType(scala.Predef), newTypeName("String"), List()))) -[2] MethodType(List(), TypeRef(ThisType(scala.collection.immutable), scala.collection.immutable.HashMap, List(TypeRef(ThisType(scala.Predef), newTypeName("String"), List()), TypeRef(ThisType(scala.Predef), newTypeName("String"), List())))) +Apply[1](Select[2](New[1](TypeTree[1]().setOriginal(AppliedTypeTree(Ident[3](scala.collection.immutable.HashMap), List(TypeTree[4]().setOriginal(Ident[4](TypeName("String"))), TypeTree[4]().setOriginal(Ident[4](TypeName("String"))))))), nme.CONSTRUCTOR), List()) +[1] TypeRef(ThisType(scala.collection.immutable), scala.collection.immutable.HashMap, List(TypeRef(ThisType(scala.Predef), TypeName("String"), List()), TypeRef(ThisType(scala.Predef), TypeName("String"), List()))) +[2] MethodType(List(), TypeRef(ThisType(scala.collection.immutable), scala.collection.immutable.HashMap, List(TypeRef(ThisType(scala.Predef), TypeName("String"), List()), TypeRef(ThisType(scala.Predef), TypeName("String"), List())))) [3] TypeRef(ThisType(scala.collection.immutable), scala.collection.immutable.HashMap, List()) -[4] TypeRef(ThisType(scala.Predef), newTypeName("String"), List()) -Apply[5](Select[6](New[5](TypeTree[5]().setOriginal(AppliedTypeTree(Ident[7](scala.collection.mutable.HashMap), List(TypeTree[4]().setOriginal(Ident[4](newTypeName("String"))), TypeTree[4]().setOriginal(Ident[4](newTypeName("String"))))))), nme.CONSTRUCTOR), List()) -[4] TypeRef(ThisType(scala.Predef), newTypeName("String"), List()) -[5] TypeRef(ThisType(scala.collection.mutable), scala.collection.mutable.HashMap, List(TypeRef(ThisType(scala.Predef), newTypeName("String"), List()), TypeRef(ThisType(scala.Predef), newTypeName("String"), List()))) -[6] MethodType(List(), TypeRef(ThisType(scala.collection.mutable), scala.collection.mutable.HashMap, List(TypeRef(ThisType(scala.Predef), newTypeName("String"), List()), TypeRef(ThisType(scala.Predef), newTypeName("String"), List())))) +[4] TypeRef(ThisType(scala.Predef), TypeName("String"), List()) +Apply[5](Select[6](New[5](TypeTree[5]().setOriginal(AppliedTypeTree(Ident[7](scala.collection.mutable.HashMap), List(TypeTree[4]().setOriginal(Ident[4](TypeName("String"))), TypeTree[4]().setOriginal(Ident[4](TypeName("String"))))))), nme.CONSTRUCTOR), List()) +[4] TypeRef(ThisType(scala.Predef), TypeName("String"), List()) +[5] TypeRef(ThisType(scala.collection.mutable), scala.collection.mutable.HashMap, List(TypeRef(ThisType(scala.Predef), TypeName("String"), List()), TypeRef(ThisType(scala.Predef), TypeName("String"), List()))) +[6] MethodType(List(), TypeRef(ThisType(scala.collection.mutable), scala.collection.mutable.HashMap, List(TypeRef(ThisType(scala.Predef), TypeName("String"), List()), TypeRef(ThisType(scala.Predef), TypeName("String"), List())))) [7] TypeRef(ThisType(scala.collection.mutable), scala.collection.mutable.HashMap, List()) diff --git a/test/files/run/showraw_tree_types_untyped.check b/test/files/run/showraw_tree_types_untyped.check index dca272684e..0416b12568 100644 --- a/test/files/run/showraw_tree_types_untyped.check +++ b/test/files/run/showraw_tree_types_untyped.check @@ -1,2 +1,2 @@ -Apply(Select(New(AppliedTypeTree(Ident(scala.collection.immutable.HashMap), List(Ident(newTypeName("String")), Ident(newTypeName("String"))))), nme.CONSTRUCTOR), List()) -Apply(Select(New(AppliedTypeTree(Ident(scala.collection.mutable.HashMap), List(Ident(newTypeName("String")), Ident(newTypeName("String"))))), nme.CONSTRUCTOR), List()) +Apply(Select(New(AppliedTypeTree(Ident(scala.collection.immutable.HashMap), List(Ident(TypeName("String")), Ident(TypeName("String"))))), nme.CONSTRUCTOR), List()) +Apply(Select(New(AppliedTypeTree(Ident(scala.collection.mutable.HashMap), List(Ident(TypeName("String")), Ident(TypeName("String"))))), nme.CONSTRUCTOR), List()) diff --git a/test/files/run/showraw_tree_ultimate.check b/test/files/run/showraw_tree_ultimate.check index 46ccd4df8f..991ecc5410 100644 --- a/test/files/run/showraw_tree_ultimate.check +++ b/test/files/run/showraw_tree_ultimate.check @@ -1,10 +1,10 @@ -Apply[1](Select[2](New[1](TypeTree[1]().setOriginal(AppliedTypeTree(Ident[3](scala.collection.immutable.HashMap#<id>#CLS), List(TypeTree[4]().setOriginal(Ident[4](newTypeName("String")#<id>#TPE)), TypeTree[4]().setOriginal(Ident[4](newTypeName("String")#<id>#TPE)))))), nme.CONSTRUCTOR#<id>#PCTOR), List()) -[1] TypeRef(ThisType(scala.collection.immutable#<id>#PK), scala.collection.immutable.HashMap#<id>#CLS, List(TypeRef(ThisType(scala.Predef#<id>#MODC), newTypeName("String")#<id>#TPE, List()), TypeRef(ThisType(scala.Predef#<id>#MODC), newTypeName("String")#<id>#TPE, List()))) -[2] MethodType(List(), TypeRef(ThisType(scala.collection.immutable#<id>#PK), scala.collection.immutable.HashMap#<id>#CLS, List(TypeRef(ThisType(scala.Predef#<id>#MODC), newTypeName("String")#<id>#TPE, List()), TypeRef(ThisType(scala.Predef#<id>#MODC), newTypeName("String")#<id>#TPE, List())))) +Apply[1](Select[2](New[1](TypeTree[1]().setOriginal(AppliedTypeTree(Ident[3](scala.collection.immutable.HashMap#<id>#CLS), List(TypeTree[4]().setOriginal(Ident[4](TypeName("String")#<id>#TPE)), TypeTree[4]().setOriginal(Ident[4](TypeName("String")#<id>#TPE)))))), nme.CONSTRUCTOR#<id>#PCTOR), List()) +[1] TypeRef(ThisType(scala.collection.immutable#<id>#PK), scala.collection.immutable.HashMap#<id>#CLS, List(TypeRef(ThisType(scala.Predef#<id>#MODC), TypeName("String")#<id>#TPE, List()), TypeRef(ThisType(scala.Predef#<id>#MODC), TypeName("String")#<id>#TPE, List()))) +[2] MethodType(List(), TypeRef(ThisType(scala.collection.immutable#<id>#PK), scala.collection.immutable.HashMap#<id>#CLS, List(TypeRef(ThisType(scala.Predef#<id>#MODC), TypeName("String")#<id>#TPE, List()), TypeRef(ThisType(scala.Predef#<id>#MODC), TypeName("String")#<id>#TPE, List())))) [3] TypeRef(ThisType(scala.collection.immutable#<id>#PK), scala.collection.immutable.HashMap#<id>#CLS, List()) -[4] TypeRef(ThisType(scala.Predef#<id>#MODC), newTypeName("String")#<id>#TPE, List()) -Apply[5](Select[6](New[5](TypeTree[5]().setOriginal(AppliedTypeTree(Ident[7](scala.collection.mutable.HashMap#<id>#CLS), List(TypeTree[4]().setOriginal(Ident[4](newTypeName("String")#<id>#TPE)), TypeTree[4]().setOriginal(Ident[4](newTypeName("String")#<id>#TPE)))))), nme.CONSTRUCTOR#<id>#CTOR), List()) -[4] TypeRef(ThisType(scala.Predef#<id>#MODC), newTypeName("String")#<id>#TPE, List()) -[5] TypeRef(ThisType(scala.collection.mutable#<id>#PK), scala.collection.mutable.HashMap#<id>#CLS, List(TypeRef(ThisType(scala.Predef#<id>#MODC), newTypeName("String")#<id>#TPE, List()), TypeRef(ThisType(scala.Predef#<id>#MODC), newTypeName("String")#<id>#TPE, List()))) -[6] MethodType(List(), TypeRef(ThisType(scala.collection.mutable#<id>#PK), scala.collection.mutable.HashMap#<id>#CLS, List(TypeRef(ThisType(scala.Predef#<id>#MODC), newTypeName("String")#<id>#TPE, List()), TypeRef(ThisType(scala.Predef#<id>#MODC), newTypeName("String")#<id>#TPE, List())))) +[4] TypeRef(ThisType(scala.Predef#<id>#MODC), TypeName("String")#<id>#TPE, List()) +Apply[5](Select[6](New[5](TypeTree[5]().setOriginal(AppliedTypeTree(Ident[7](scala.collection.mutable.HashMap#<id>#CLS), List(TypeTree[4]().setOriginal(Ident[4](TypeName("String")#<id>#TPE)), TypeTree[4]().setOriginal(Ident[4](TypeName("String")#<id>#TPE)))))), nme.CONSTRUCTOR#<id>#CTOR), List()) +[4] TypeRef(ThisType(scala.Predef#<id>#MODC), TypeName("String")#<id>#TPE, List()) +[5] TypeRef(ThisType(scala.collection.mutable#<id>#PK), scala.collection.mutable.HashMap#<id>#CLS, List(TypeRef(ThisType(scala.Predef#<id>#MODC), TypeName("String")#<id>#TPE, List()), TypeRef(ThisType(scala.Predef#<id>#MODC), TypeName("String")#<id>#TPE, List()))) +[6] MethodType(List(), TypeRef(ThisType(scala.collection.mutable#<id>#PK), scala.collection.mutable.HashMap#<id>#CLS, List(TypeRef(ThisType(scala.Predef#<id>#MODC), TypeName("String")#<id>#TPE, List()), TypeRef(ThisType(scala.Predef#<id>#MODC), TypeName("String")#<id>#TPE, List())))) [7] TypeRef(ThisType(scala.collection.mutable#<id>#PK), scala.collection.mutable.HashMap#<id>#CLS, List()) diff --git a/test/files/run/structural.scala b/test/files/run/structural.scala index 36af8c4bfc..3a703d2cf1 100644 --- a/test/files/run/structural.scala +++ b/test/files/run/structural.scala @@ -152,7 +152,7 @@ object test2 { object test3 { - case class Exc extends Exception + case class Exc() extends Exception object Rec { def f = throw Exc() diff --git a/test/files/run/t0091.check b/test/files/run/t0091.check index 7ed6ff82de..fd3c81a4d7 100644 --- a/test/files/run/t0091.check +++ b/test/files/run/t0091.check @@ -1 +1,2 @@ 5 +5 diff --git a/test/files/run/t0091.scala b/test/files/run/t0091.scala index eaddde0dbf..45235eb77b 100644 --- a/test/files/run/t0091.scala +++ b/test/files/run/t0091.scala @@ -4,10 +4,13 @@ object C extends B { object m extends A { def x = 5 } } object Test { - // The type annotation here is necessary, otherwise - // the compiler would reference C$m$ directly. - def o : B = C - def main(argv : Array[String]) : Unit = { - println(o.m.x) - } + // The type annotation here is necessary, otherwise + // the compiler would reference C$m$ directly. + def o1 : B = C + def o2 = C + + def main(argv : Array[String]) : Unit = { + println(o1.m.x) + println(o2.m.x) + } } diff --git a/test/files/run/t1500.scala b/test/files/run/t1500.scala index ab132b724f..6d2e7ee05f 100644 --- a/test/files/run/t1500.scala +++ b/test/files/run/t1500.scala @@ -21,7 +21,7 @@ object Test { val settings = new Settings() settings.classpath.value = System.getProperty("java.class.path") val tool = new interpreter.IMain(settings) - val global = tool.compiler + val global = tool.global import global._ import definitions._ diff --git a/test/files/run/t1501.scala b/test/files/run/t1501.scala index aba206bc7a..a2f7bb3a65 100644 --- a/test/files/run/t1501.scala +++ b/test/files/run/t1501.scala @@ -31,7 +31,7 @@ object Test { val settings = new Settings() settings.classpath.value = System.getProperty("java.class.path") val tool = new interpreter.IMain(settings) - val global = tool.compiler + val global = tool.global import global._ import definitions._ diff --git a/test/files/run/t1505.scala b/test/files/run/t1505.scala index a246e8a35b..d7feb30ce3 100644 --- a/test/files/run/t1505.scala +++ b/test/files/run/t1505.scala @@ -1,5 +1,3 @@ -object P extends Enumeration(0, "A", "B", "C") { val A, B, C = Value } - object Q extends Enumeration { val A = Value("A") val B = Value("B") @@ -11,9 +9,14 @@ object R extends Enumeration { } object Test extends App { - assert(P(0) == P.withName("A")) - assert(P.C == P.withName("C")) - assert(Q(0) == Q.withName("A")) assert(Q.C == Q.withName("C")) + + assert(R(0) == R.withName("A")) + assert(R.C == R.withName("C")) + + var failed = false + try { Q.withName("x") } catch { case _: NoSuchElementException => failed = true } + assert(failed) + } diff --git a/test/files/run/t2251.check b/test/files/run/t2251.check new file mode 100644 index 0000000000..55ad2a5857 --- /dev/null +++ b/test/files/run/t2251.check @@ -0,0 +1 @@ +Set(List(List(C), Stream(D, ?))) diff --git a/test/files/run/t2251.scala b/test/files/run/t2251.scala new file mode 100644 index 0000000000..00c5619b49 --- /dev/null +++ b/test/files/run/t2251.scala @@ -0,0 +1,19 @@ +class A +trait B[T <: B[T]] extends A +class C extends B[C] { override def toString = "C" } +class D extends B[D] { override def toString = "D" } + +class E { + val ys = List(List(new C), Stream(new D)) +} + +object Test { + def trav = List(List(), Stream()) + + def main(args: Array[String]): Unit = { + val f = (new E).ys _ + var xs: Set[List[_ <: Seq[B[_]]]] = Set() + xs += f() + println(xs) + } +} diff --git a/test/files/run/t2251b.check b/test/files/run/t2251b.check new file mode 100644 index 0000000000..42b0be457a --- /dev/null +++ b/test/files/run/t2251b.check @@ -0,0 +1,11 @@ +TypeTag[List[scala.collection.immutable.LinearSeq[B[_ >: D with C <: B[_ >: D with C <: A]]] with scala.collection.AbstractSeq[B[_ >: D with C <: B[_ >: D with C <: A]]]{def companion: scala.collection.generic.GenericCompanion[scala.collection.immutable.LinearSeq with scala.collection.AbstractSeq]; def reverse: scala.collection.immutable.LinearSeq[B[_ >: D with C <: A]] with scala.collection.AbstractSeq[B[_ >: D with C <: A]]{def companion: scala.collection.generic.GenericCompanion[scala.collection.immutable.LinearSeq with scala.collection.AbstractSeq]; def reverse: scala.collection.immutable.LinearSeq[A] with scala.collection.AbstractSeq[A]; def dropRight(n: Int): scala.collection.immutable.LinearSeq[A] with scala.collection.AbstractSeq[A]; def takeRight(n: Int): scala.collection.immutable.LinearSeq[A] with scala.collection.AbstractSeq[A]; def drop(n: Int): scala.collection.immutable.LinearSeq[A] with scala.collection.AbstractSeq[A]; def take(n: Int): scala.collection.immutable.LinearSeq[A] with scala.collection.AbstractSeq[A]; def slice(from: Int,until: Int): scala.collection.immutable.LinearSeq[A] with scala.collection.AbstractSeq[A]}; def dropRight(n: Int): scala.collection.immutable.LinearSeq[B[_ >: D with C <: A]] with scala.collection.AbstractSeq[B[_ >: D with C <: A]]{def companion: scala.collection.generic.GenericCompanion[scala.collection.immutable.LinearSeq with scala.collection.AbstractSeq]; def reverse: scala.collection.immutable.LinearSeq[A] with scala.collection.AbstractSeq[A]; def dropRight(n: Int): scala.collection.immutable.LinearSeq[A] with scala.collection.AbstractSeq[A]; def takeRight(n: Int): scala.collection.immutable.LinearSeq[A] with scala.collection.AbstractSeq[A]; def drop(n: Int): scala.collection.immutable.LinearSeq[A] with scala.collection.AbstractSeq[A]; def take(n: Int): scala.collection.immutable.LinearSeq[A] with scala.collection.AbstractSeq[A]; def slice(from: Int,until: Int): scala.collection.immutable.LinearSeq[A] with scala.collection.AbstractSeq[A]}; def takeRight(n: Int): scala.collection.immutable.LinearSeq[B[_ >: D with C <: A]] with scala.collection.AbstractSeq[B[_ >: D with C <: A]]{def companion: scala.collection.generic.GenericCompanion[scala.collection.immutable.LinearSeq with scala.collection.AbstractSeq]; def reverse: scala.collection.immutable.LinearSeq[A] with scala.collection.AbstractSeq[A]; def dropRight(n: Int): scala.collection.immutable.LinearSeq[A] with scala.collection.AbstractSeq[A]; def takeRight(n: Int): scala.collection.immutable.LinearSeq[A] with scala.collection.AbstractSeq[A]; def drop(n: Int): scala.collection.immutable.LinearSeq[A] with scala.collection.AbstractSeq[A]; def take(n: Int): scala.collection.immutable.LinearSeq[A] with scala.collection.AbstractSeq[A]; def slice(from: Int,until: Int): scala.collection.immutable.LinearSeq[A] with scala.collection.AbstractSeq[A]}; def drop(n: Int): scala.collection.immutable.LinearSeq[B[_ >: D with C <: A]] with scala.collection.AbstractSeq[B[_ >: D with C <: A]]{def companion: scala.collection.generic.GenericCompanion[scala.collection.immutable.LinearSeq with scala.collection.AbstractSeq]; def reverse: scala.collection.immutable.LinearSeq[A] with scala.collection.AbstractSeq[A]; def dropRight(n: Int): scala.collection.immutable.LinearSeq[A] with scala.collection.AbstractSeq[A]; def takeRight(n: Int): scala.collection.immutable.LinearSeq[A] with scala.collection.AbstractSeq[A]; def drop(n: Int): scala.collection.immutable.LinearSeq[A] with scala.collection.AbstractSeq[A]; def take(n: Int): scala.collection.immutable.LinearSeq[A] with scala.collection.AbstractSeq[A]; def slice(from: Int,until: Int): scala.collection.immutable.LinearSeq[A] with scala.collection.AbstractSeq[A]}; def take(n: Int): scala.collection.immutable.LinearSeq[B[_ >: D with C <: A]] with scala.collection.AbstractSeq[B[_ >: D with C <: A]]{def companion: scala.collection.generic.GenericCompanion[scala.collection.immutable.LinearSeq with scala.collection.AbstractSeq]; def reverse: scala.collection.immutable.LinearSeq[A] with scala.collection.AbstractSeq[A]; def dropRight(n: Int): scala.collection.immutable.LinearSeq[A] with scala.collection.AbstractSeq[A]; def takeRight(n: Int): scala.collection.immutable.LinearSeq[A] with scala.collection.AbstractSeq[A]; def drop(n: Int): scala.collection.immutable.LinearSeq[A] with scala.collection.AbstractSeq[A]; def take(n: Int): scala.collection.immutable.LinearSeq[A] with scala.collection.AbstractSeq[A]; def slice(from: Int,until: Int): scala.collection.immutable.LinearSeq[A] with scala.collection.AbstractSeq[A]}; def slice(from: Int,until: Int): scala.collection.immutable.LinearSeq[B[_ >: D with C <: A]] with scala.collection.AbstractSeq[B[_ >: D with C <: A]]{def companion: scala.collection.generic.GenericCompanion[scala.collection.immutable.LinearSeq with scala.collection.AbstractSeq]; def reverse: scala.collection.immutable.LinearSeq[A] with scala.collection.AbstractSeq[A]; def dropRight(n: Int): scala.collection.immutable.LinearSeq[A] with scala.collection.AbstractSeq[A]; def takeRight(n: Int): scala.collection.immutable.LinearSeq[A] with scala.collection.AbstractSeq[A]; def drop(n: Int): scala.collection.immutable.LinearSeq[A] with scala.collection.AbstractSeq[A]; def take(n: Int): scala.collection.immutable.LinearSeq[A] with scala.collection.AbstractSeq[A]; def slice(from: Int,until: Int): scala.collection.immutable.LinearSeq[A] with scala.collection.AbstractSeq[A]}; def splitAt(n: Int): (scala.collection.immutable.LinearSeq[A] with scala.collection.AbstractSeq[A], scala.collection.immutable.LinearSeq[A] with scala.collection.AbstractSeq[A])}]] +TypeTag[List[scala.collection.immutable.Iterable[B[_ >: F with E with D with C <: B[_ >: F with E with D with C <: A]]] with F with Int => Any]] +TypeTag[List[scala.collection.immutable.Seq[B[_ >: D with C <: B[_ >: D with C <: A]]] with scala.collection.AbstractSeq[B[_ >: D with C <: B[_ >: D with C <: A]]]{def companion: scala.collection.generic.GenericCompanion[scala.collection.immutable.Seq with scala.collection.AbstractSeq]; def dropRight(n: Int): scala.collection.immutable.Seq[B[_ >: D with C <: A]] with scala.collection.AbstractSeq[B[_ >: D with C <: A]]{def companion: scala.collection.generic.GenericCompanion[scala.collection.immutable.Seq with scala.collection.AbstractSeq]; def dropRight(n: Int): scala.collection.immutable.Seq[A] with scala.collection.AbstractSeq[A]; def takeRight(n: Int): scala.collection.immutable.Seq[A] with scala.collection.AbstractSeq[A]; def drop(n: Int): scala.collection.immutable.Seq[A] with scala.collection.AbstractSeq[A]; def take(n: Int): scala.collection.immutable.Seq[A] with scala.collection.AbstractSeq[A]; def slice(from: Int,until: Int): scala.collection.immutable.Seq[A] with scala.collection.AbstractSeq[A]; def init: scala.collection.immutable.Seq[A] with scala.collection.AbstractSeq[A]}; def takeRight(n: Int): scala.collection.immutable.Seq[B[_ >: D with C <: A]] with scala.collection.AbstractSeq[B[_ >: D with C <: A]]{def companion: scala.collection.generic.GenericCompanion[scala.collection.immutable.Seq with scala.collection.AbstractSeq]; def dropRight(n: Int): scala.collection.immutable.Seq[A] with scala.collection.AbstractSeq[A]; def takeRight(n: Int): scala.collection.immutable.Seq[A] with scala.collection.AbstractSeq[A]; def drop(n: Int): scala.collection.immutable.Seq[A] with scala.collection.AbstractSeq[A]; def take(n: Int): scala.collection.immutable.Seq[A] with scala.collection.AbstractSeq[A]; def slice(from: Int,until: Int): scala.collection.immutable.Seq[A] with scala.collection.AbstractSeq[A]; def init: scala.collection.immutable.Seq[A] with scala.collection.AbstractSeq[A]}; def drop(n: Int): scala.collection.immutable.Seq[B[_ >: D with C <: A]] with scala.collection.AbstractSeq[B[_ >: D with C <: A]]{def companion: scala.collection.generic.GenericCompanion[scala.collection.immutable.Seq with scala.collection.AbstractSeq]; def dropRight(n: Int): scala.collection.immutable.Seq[A] with scala.collection.AbstractSeq[A]; def takeRight(n: Int): scala.collection.immutable.Seq[A] with scala.collection.AbstractSeq[A]; def drop(n: Int): scala.collection.immutable.Seq[A] with scala.collection.AbstractSeq[A]; def take(n: Int): scala.collection.immutable.Seq[A] with scala.collection.AbstractSeq[A]; def slice(from: Int,until: Int): scala.collection.immutable.Seq[A] with scala.collection.AbstractSeq[A]; def init: scala.collection.immutable.Seq[A] with scala.collection.AbstractSeq[A]}; def take(n: Int): scala.collection.immutable.Seq[B[_ >: D with C <: A]] with scala.collection.AbstractSeq[B[_ >: D with C <: A]]{def companion: scala.collection.generic.GenericCompanion[scala.collection.immutable.Seq with scala.collection.AbstractSeq]; def dropRight(n: Int): scala.collection.immutable.Seq[A] with scala.collection.AbstractSeq[A]; def takeRight(n: Int): scala.collection.immutable.Seq[A] with scala.collection.AbstractSeq[A]; def drop(n: Int): scala.collection.immutable.Seq[A] with scala.collection.AbstractSeq[A]; def take(n: Int): scala.collection.immutable.Seq[A] with scala.collection.AbstractSeq[A]; def slice(from: Int,until: Int): scala.collection.immutable.Seq[A] with scala.collection.AbstractSeq[A]; def init: scala.collection.immutable.Seq[A] with scala.collection.AbstractSeq[A]}; def slice(from: Int,until: Int): scala.collection.immutable.Seq[B[_ >: D with C <: A]] with scala.collection.AbstractSeq[B[_ >: D with C <: A]]{def companion: scala.collection.generic.GenericCompanion[scala.collection.immutable.Seq with scala.collection.AbstractSeq]; def dropRight(n: Int): scala.collection.immutable.Seq[A] with scala.collection.AbstractSeq[A]; def takeRight(n: Int): scala.collection.immutable.Seq[A] with scala.collection.AbstractSeq[A]; def drop(n: Int): scala.collection.immutable.Seq[A] with scala.collection.AbstractSeq[A]; def take(n: Int): scala.collection.immutable.Seq[A] with scala.collection.AbstractSeq[A]; def slice(from: Int,until: Int): scala.collection.immutable.Seq[A] with scala.collection.AbstractSeq[A]; def init: scala.collection.immutable.Seq[A] with scala.collection.AbstractSeq[A]}; def splitAt(n: Int): (scala.collection.immutable.Seq[A] with scala.collection.AbstractSeq[A], scala.collection.immutable.Seq[A] with scala.collection.AbstractSeq[A]); def init: scala.collection.immutable.Seq[B[_ >: D with C <: A]] with scala.collection.AbstractSeq[B[_ >: D with C <: A]]{def companion: scala.collection.generic.GenericCompanion[scala.collection.immutable.Seq with scala.collection.AbstractSeq]; def dropRight(n: Int): scala.collection.immutable.Seq[A] with scala.collection.AbstractSeq[A]; def takeRight(n: Int): scala.collection.immutable.Seq[A] with scala.collection.AbstractSeq[A]; def drop(n: Int): scala.collection.immutable.Seq[A] with scala.collection.AbstractSeq[A]; def take(n: Int): scala.collection.immutable.Seq[A] with scala.collection.AbstractSeq[A]; def slice(from: Int,until: Int): scala.collection.immutable.Seq[A] with scala.collection.AbstractSeq[A]; def init: scala.collection.immutable.Seq[A] with scala.collection.AbstractSeq[A]}}]] +TypeTag[List[scala.collection.Set[_ >: G with F <: B[_ >: G with F <: B[_ >: G with F <: A]]]]] +TypeTag[List[scala.collection.Set[_ >: G with F <: B[_ >: G with F <: B[_ >: G with F <: A]]]]] +TypeTag[List[scala.collection.Set[_ >: G with F <: B[_ >: G with F <: B[_ >: G with F <: A]]]]] +TypeTag[List[Seq[B[_ >: G with F <: B[_ >: G with F <: A]]]]] +TypeTag[List[scala.collection.Map[_ >: F with C <: B[_ >: F with C <: B[_ >: F with C <: A]], B[_ >: G with D <: B[_ >: G with D <: A]]]]] +TypeTag[List[scala.collection.AbstractSeq[B[_ >: G with F <: B[_ >: G with F <: A]]] with scala.collection.LinearSeq[B[_ >: G with F <: B[_ >: G with F <: A]]]{def companion: scala.collection.generic.GenericCompanion[scala.collection.AbstractSeq with scala.collection.LinearSeq]; def dropRight(n: Int): scala.collection.AbstractSeq[B[_ >: G with F <: A]] with scala.collection.LinearSeq[B[_ >: G with F <: A]]{def companion: scala.collection.generic.GenericCompanion[scala.collection.AbstractSeq with scala.collection.LinearSeq]; def dropRight(n: Int): scala.collection.AbstractSeq[A] with scala.collection.LinearSeq[A]; def drop(n: Int): scala.collection.AbstractSeq[A] with scala.collection.LinearSeq[A]; def take(n: Int): scala.collection.AbstractSeq[A] with scala.collection.LinearSeq[A]; def slice(from: Int,until: Int): scala.collection.AbstractSeq[A] with scala.collection.LinearSeq[A]}; def drop(n: Int): scala.collection.AbstractSeq[B[_ >: G with F <: A]] with scala.collection.LinearSeq[B[_ >: G with F <: A]]{def companion: scala.collection.generic.GenericCompanion[scala.collection.AbstractSeq with scala.collection.LinearSeq]; def dropRight(n: Int): scala.collection.AbstractSeq[A] with scala.collection.LinearSeq[A]; def drop(n: Int): scala.collection.AbstractSeq[A] with scala.collection.LinearSeq[A]; def take(n: Int): scala.collection.AbstractSeq[A] with scala.collection.LinearSeq[A]; def slice(from: Int,until: Int): scala.collection.AbstractSeq[A] with scala.collection.LinearSeq[A]}; def take(n: Int): scala.collection.AbstractSeq[B[_ >: G with F <: A]] with scala.collection.LinearSeq[B[_ >: G with F <: A]]{def companion: scala.collection.generic.GenericCompanion[scala.collection.AbstractSeq with scala.collection.LinearSeq]; def dropRight(n: Int): scala.collection.AbstractSeq[A] with scala.collection.LinearSeq[A]; def drop(n: Int): scala.collection.AbstractSeq[A] with scala.collection.LinearSeq[A]; def take(n: Int): scala.collection.AbstractSeq[A] with scala.collection.LinearSeq[A]; def slice(from: Int,until: Int): scala.collection.AbstractSeq[A] with scala.collection.LinearSeq[A]}; def slice(from: Int,until: Int): scala.collection.AbstractSeq[B[_ >: G with F <: A]] with scala.collection.LinearSeq[B[_ >: G with F <: A]]{def companion: scala.collection.generic.GenericCompanion[scala.collection.AbstractSeq with scala.collection.LinearSeq]; def dropRight(n: Int): scala.collection.AbstractSeq[A] with scala.collection.LinearSeq[A]; def drop(n: Int): scala.collection.AbstractSeq[A] with scala.collection.LinearSeq[A]; def take(n: Int): scala.collection.AbstractSeq[A] with scala.collection.LinearSeq[A]; def slice(from: Int,until: Int): scala.collection.AbstractSeq[A] with scala.collection.LinearSeq[A]}}]] +TypeTag[List[Seq[B[_ >: G with F <: B[_ >: G with F <: A]]]]] +TypeTag[List[Seq[B[_ >: G with F <: B[_ >: G with F <: A]]]]] diff --git a/test/files/run/t2251b.scala b/test/files/run/t2251b.scala new file mode 100644 index 0000000000..b67b3aec1e --- /dev/null +++ b/test/files/run/t2251b.scala @@ -0,0 +1,48 @@ +class A +trait B[T <: B[T]] extends A +class B1[T <: B1[T]] extends B[T] +class C extends B[C] { override def toString = "C" } +class D extends B[D] { override def toString = "D" } +class E extends B[E] { override def toString = "E" } +class F extends B[F] { override def toString = "F" } +class G extends B1[G] { override def toString = "G" } + +object Test { + import scala.collection.{ mutable, immutable } + import scala.collection.immutable.{ Vector } + import scala.reflect.runtime.universe._ + def what[T: TypeTag](x: T) = println(typeTag[T]) + + def main(args: Array[String]): Unit = { + what(List(List(new C), Stream(new D))) + what(List(List(new C), Stream(new D), Vector(new E), Set(new F))) + what(List(immutable.Vector(new C), Stream(new D))) + what(List(collection.Set(new F), mutable.Set(new G))) + what(List(collection.Set(new F), immutable.Set(new G))) + what(List(mutable.Set(new F), immutable.Set(new G))) + what(List(mutable.Seq(new F), immutable.Seq(new G))) + what(List(mutable.Map(new C -> new D), immutable.Map(new F -> new G))) + what(List(mutable.MutableList(new F), immutable.List(new G))) + what(List(mutable.Seq(new F), collection.Seq(new G))) + what(List(mutable.LinearSeq(new F), collection.IndexedSeq(new G))) + } +} + + +// class D extends B[D] { override def toString = "D" } + + +// class E { +// val ys = List(List(new C), Stream(new D)) +// } + +// object Test { +// def trav = List(List(), Stream()) + +// def main(args: Array[String]): Unit = { +// val f = (new E).ys _ +// var xs: Set[List[_ <: Seq[B[_]]]] = Set() +// xs += f() +// println(xs) +// } +// } diff --git a/test/files/run/t2318.check b/test/files/run/t2318.check new file mode 100644 index 0000000000..a486f1ac47 --- /dev/null +++ b/test/files/run/t2318.check @@ -0,0 +1,2 @@ +bar +bar diff --git a/test/files/run/t2318.scala b/test/files/run/t2318.scala new file mode 100644 index 0000000000..47d083eb9d --- /dev/null +++ b/test/files/run/t2318.scala @@ -0,0 +1,39 @@ +import java.security._ + +object Test { + trait Bar { def bar: Unit } + + object Mgr extends SecurityManager { + override def checkPermission(perm: Permission) = perm match { + case _: java.lang.RuntimePermission => () + case _: java.io.FilePermission => () + case x: java.security.SecurityPermission if x.getName contains ".networkaddress." => () // generality ftw + case x: java.util.PropertyPermission if x.getName == "sun.net.inetaddr.ttl" => () + case _ => super.checkPermission(perm) + } + } + + def t1() = { + val p = Runtime.getRuntime().exec("ls"); + type Destroyable = { def destroy() : Unit } + def doDestroy( obj : Destroyable ) : Unit = obj.destroy(); + doDestroy( p ); + } + def t2() = { + System.setSecurityManager(Mgr) + + val b = new Bar { def bar = println("bar") } + b.bar + + val structural = b.asInstanceOf[{ def bar: Unit }] + structural.bar + } + + def main(args: Array[String]) { + // figuring this will otherwise break on windows + try t1() + catch { case _: java.io.IOException => () } + + t2() + } +} diff --git a/test/files/run/t2577.check b/test/files/run/t2577.check new file mode 100644 index 0000000000..4a584e4989 --- /dev/null +++ b/test/files/run/t2577.check @@ -0,0 +1 @@ +Nothing diff --git a/test/files/run/t2577.scala b/test/files/run/t2577.scala new file mode 100644 index 0000000000..6d836a3996 --- /dev/null +++ b/test/files/run/t2577.scala @@ -0,0 +1,17 @@ +case class annot[T]() extends scala.annotation.StaticAnnotation + +// type inference should infer @annot[Nothing] instead of @annot[T] +// note the T is not in scope here! +class Foo[@annot U] + +object Test { + import scala.reflect.runtime.universe._ + val x = new Foo + + def main(args: Array[String]): Unit = { + val targ = typeOf[x.type].widen match { + case TypeRef(_, _, arg :: _) => arg + } + println(targ) + } +} diff --git a/test/files/run/t2873.check b/test/files/run/t2873.check index 9198280f61..209b679c07 100644 --- a/test/files/run/t2873.check +++ b/test/files/run/t2873.check @@ -1 +1 @@ -scala.collection.immutable.RedBlack<A>.Empty$ +RedBlack<A>.Empty$ diff --git a/test/files/run/t2873.scala b/test/files/run/t2873.scala index 8d48a8dbb4..3a3cc59b46 100644 --- a/test/files/run/t2873.scala +++ b/test/files/run/t2873.scala @@ -1,5 +1,10 @@ +abstract class RedBlack[A] extends Serializable { + abstract class Tree[+B] extends Serializable + case object Empty extends Tree[Nothing] +} + object Test { def main(args: Array[String]): Unit = { - println(classOf[scala.collection.immutable.RedBlack[_]].getMethod("Empty").getGenericReturnType) + println(classOf[RedBlack[_]].getMethod("Empty").getGenericReturnType) } } diff --git a/test/files/run/t2886.check b/test/files/run/t2886.check index ce31bc7408..cb0db8a6dc 100644 --- a/test/files/run/t2886.check +++ b/test/files/run/t2886.check @@ -1,5 +1,5 @@ ((x: String) => { - val x$1 = x; - val x$2 = x; + <artifact> val x$1 = x; + <artifact> val x$2 = x; Test.this.test(x$2, x$1) }) diff --git a/test/files/run/t3038d.scala b/test/files/run/t3038d.scala index 6cd2d83776..9550165235 100644 --- a/test/files/run/t3038d.scala +++ b/test/files/run/t3038d.scala @@ -16,9 +16,7 @@ trait Foo { } } - -@serializable -class Bar extends Foo { +class Bar extends Foo with Serializable { @transient protected var first: Any = null def size = a @transient var second: Any = null diff --git a/test/files/run/t3667.check b/test/files/run/t3667.check index bbe5d1bc48..6375c88997 100644 --- a/test/files/run/t3667.check +++ b/test/files/run/t3667.check @@ -1,6 +1,3 @@ -1 -2 -3 4 2 3 diff --git a/test/files/run/t3667.scala b/test/files/run/t3667.scala index f30d57ce3a..ada09d5886 100644 --- a/test/files/run/t3667.scala +++ b/test/files/run/t3667.scala @@ -1,27 +1,9 @@ object Test { def main(args: Array[String]) { - val o1 = new Outer1 - val o2 = new Outer2 - val o3 = new Outer3 val o4 = new Outer4 val o5 = new Outer5 val o6 = new Outer6 - println(1) - ser(new o1.Inner(1)) - o1.Inner // make sure the Inner$module field of the Outer1 instance is initialized! - ser(new o1.Inner(1)) - - println(2) - ser(new o2.Inner(1)) - o2.Inner - ser(new o2.Inner(1)) - - println(3) - ser(new o3.Inner(1)) - o3.Inner - ser(new o3.Inner(1)) - println(4) ser(new o4.Inner(1)) o4.Inner @@ -54,23 +36,6 @@ object Test { } -@serializable -class Outer1 { - @serializable - class Inner(x: Int = 1) -} - -@serializable -class Outer2 { - case class Inner(x: Int = 1) -} - -@serializable -class Outer3 { - case class Inner(x: Int) -} - - class Outer4 extends Serializable { class Inner(x: Int = 1) extends Serializable } diff --git a/test/files/run/t3835.scala b/test/files/run/t3835.scala index c120a61f6e..766b6ddc2e 100644 --- a/test/files/run/t3835.scala +++ b/test/files/run/t3835.scala @@ -1,6 +1,6 @@ object Test extends App { // work around optimizer bug SI-5672 -- generates wrong bytecode for switches in arguments - // virtpatmat happily emits a switch for a one-case switch, whereas -Xoldpatmat did not + // virtpatmat happily emits a switch for a one-case switch // this is not the focus of this test, hence the temporary workaround def a = (1, 2, 3) match { case (r, \u03b8, \u03c6) => r + \u03b8 + \u03c6 } println(a) diff --git a/test/files/run/t3897.check b/test/files/run/t3897.check new file mode 100644 index 0000000000..244b83716f --- /dev/null +++ b/test/files/run/t3897.check @@ -0,0 +1,8 @@ +(One$$messages,scala.collection.mutable.MutableList<java.lang.String>) +(One$$messages,scala.collection.mutable.MutableList<java.lang.String>) +(messages,scala.collection.mutable.MutableList<java.lang.String>) +(messages,scala.collection.mutable.MutableList<java.lang.String>) +(One$$messages,scala.collection.mutable.MutableList<java.lang.String>) +(One$$messages,scala.collection.mutable.MutableList<java.lang.String>) +(messages,scala.collection.mutable.MutableList<java.lang.String>) +(messages,scala.collection.mutable.MutableList<java.lang.String>) diff --git a/test/files/run/t3897/J_2.java b/test/files/run/t3897/J_2.java new file mode 100644 index 0000000000..178412dc92 --- /dev/null +++ b/test/files/run/t3897/J_2.java @@ -0,0 +1,27 @@ +import java.lang.reflect.*; + +public class J_2 { + public void f1(Class<?> clazz) { + Field[] fields = clazz.getDeclaredFields(); + for (int i = 0 ; i < fields.length; i++) { + String name = fields[i].getName(); + if (name.length() >= 7 && name.substring(0, 7).equals("bitmap$")) { } + else System.out.println("(" + name + "," + fields[i].getGenericType() + ")"); + } + } + public void f2(Class<?> clazz) { + Method[] methods = clazz.getDeclaredMethods(); + for (int i = 0 ; i < methods.length; i++) { + String name = methods[i].getName(); + if (name.length() >= 7 && name.substring(0, 7).equals("bitmap$")) { } + else System.out.println("(" + name + "," + methods[i].getGenericReturnType() + ")"); + } + } + + public void javaRun() { + f1(One.class); + f2(One.class); + f1(Two.class); + f2(Two.class); + } +}
\ No newline at end of file diff --git a/test/files/run/t3897/a_1.scala b/test/files/run/t3897/a_1.scala new file mode 100644 index 0000000000..4da959e2ac --- /dev/null +++ b/test/files/run/t3897/a_1.scala @@ -0,0 +1,8 @@ +class One { + private val messages = new collection.mutable.MutableList[String] + List("a") foreach { messages += _ } +} + +class Two { + private val messages = new collection.mutable.MutableList[String] +} diff --git a/test/files/run/t3897/a_2.scala b/test/files/run/t3897/a_2.scala new file mode 100644 index 0000000000..4d9e59ef05 --- /dev/null +++ b/test/files/run/t3897/a_2.scala @@ -0,0 +1,23 @@ +object Test { + def f1(clazz: Class[_]) = ( + clazz.getDeclaredFields.toList + . filterNot (_.getName contains "bitmap$") + . map (f => (f.getName, f.getGenericType)) + . foreach (println) + ) + def f2(clazz: Class[_]) = ( + clazz.getDeclaredMethods.toList + . filterNot (_.getName contains "bitmap$") + . map (f => (f.getName, f.getGenericReturnType)) + . foreach (println) + ) + + def main(args: Array[String]): Unit = { + f1(classOf[One]) + f2(classOf[One]) + f1(classOf[Two]) + f2(classOf[Two]) + + new J_2().javaRun + } +} diff --git a/test/files/run/t4023.check b/test/files/run/t4023.check new file mode 100644 index 0000000000..05f867c397 --- /dev/null +++ b/test/files/run/t4023.check @@ -0,0 +1,21 @@ +Try 1: (6 classes) +class Test$C$B1 +class Test$C$B2 +class Test$C$B3$ +class Test$C$B4$ +class Test$C$B5$ +class Test$C$B6$ +Try 2: (6 classes) +class Test$C$B1 +class Test$C$B2 +class Test$C$B3$ +class Test$C$B4$ +class Test$C$B5$ +class Test$C$B6$ +Try 3: (6 classes) +class Test$C$B1 +class Test$C$B2 +class Test$C$B3$ +class Test$C$B4$ +class Test$C$B5$ +class Test$C$B6$ diff --git a/test/files/run/t4023.scala b/test/files/run/t4023.scala new file mode 100644 index 0000000000..4846fa31b4 --- /dev/null +++ b/test/files/run/t4023.scala @@ -0,0 +1,23 @@ +object Test { + object C { + class B1 + private class B2 + object B3 + private object B4 + object B5 extends B1 + private object B6 extends B2 + + val valuesTry1 = this.getClass.getDeclaredClasses + val valuesTry2 = C.getClass.getDeclaredClasses + val valuesTry3 = getClass.getDeclaredClasses + } + + def main(args: Array[String]) { + println("Try 1: (" + C.valuesTry1.length + " classes)") + C.valuesTry1.foreach(println) + println("Try 2: (" + C.valuesTry2.length + " classes)") + C.valuesTry2.foreach(println) + println("Try 3: (" + C.valuesTry3.length + " classes)") + C.valuesTry3.foreach(println) + } +}
\ No newline at end of file diff --git a/test/files/run/t4047.scala b/test/files/run/t4047.scala index cd42a8b4df..08989bd278 100644 --- a/test/files/run/t4047.scala +++ b/test/files/run/t4047.scala @@ -18,7 +18,7 @@ class D extends Bar[Unit]{ def foo = println("Unit: called D.foo") } -object Test extends Application { +object Test extends App { val a: Foo[Unit] = new A a.foo a.foo diff --git a/test/files/run/t4146.scala b/test/files/run/t4146.scala deleted file mode 100644 index 93ce22b519..0000000000 --- a/test/files/run/t4146.scala +++ /dev/null @@ -1,7 +0,0 @@ -object bob extends Application { - var name = "Bob" -} - -object Test extends App { - assert(bob.name == "Bob") -} diff --git a/test/files/run/t4351.check b/test/files/run/t4351.check new file mode 100644 index 0000000000..cb5d407e13 --- /dev/null +++ b/test/files/run/t4351.check @@ -0,0 +1 @@ +runtime exception diff --git a/test/files/run/t4351.scala b/test/files/run/t4351.scala new file mode 100644 index 0000000000..d954d748b7 --- /dev/null +++ b/test/files/run/t4351.scala @@ -0,0 +1,21 @@ +object Test { + def main(args: Array[String]): Unit = { + try new BooleanPropImpl().value + catch { + // was: StackOverflowError + case e: RuntimeException => println("runtime exception") + } + } +} + +trait Prop[@specialized(Boolean) +T] { + def value: T +} + +class PropImpl[+T] extends Prop[T] { + def value: T = scala.sys.error("") +} + +trait BooleanProp extends Prop[Boolean] + +class BooleanPropImpl() extends PropImpl[Boolean] with BooleanProp diff --git a/test/files/run/t4415.scala b/test/files/run/t4415.scala index f96031d650..caf1609b9e 100644 --- a/test/files/run/t4415.scala +++ b/test/files/run/t4415.scala @@ -39,7 +39,7 @@ class SecondProperty extends TopProperty class SubclassSecondProperty extends StandardProperty trait MyProp[T] -case class MyPropImpl[T] extends MyProp[T] +case class MyPropImpl[T]() extends MyProp[T] object SubclassMatch { diff --git a/test/files/run/t4537.check b/test/files/run/t4537.check new file mode 100644 index 0000000000..63739ca64a --- /dev/null +++ b/test/files/run/t4537.check @@ -0,0 +1 @@ +b.Settings diff --git a/test/files/run/t4537/a.scala b/test/files/run/t4537/a.scala new file mode 100644 index 0000000000..125e223e13 --- /dev/null +++ b/test/files/run/t4537/a.scala @@ -0,0 +1,5 @@ +package a + +private[a] object Settings { + val X = "a.Settings" +} diff --git a/test/files/run/t4537/b.scala b/test/files/run/t4537/b.scala new file mode 100644 index 0000000000..c709d49b04 --- /dev/null +++ b/test/files/run/t4537/b.scala @@ -0,0 +1,5 @@ +package b + +object Settings { + val Y = "b.Settings" +} diff --git a/test/files/run/t4537/c.scala b/test/files/run/t4537/c.scala new file mode 100644 index 0000000000..ee05d4bbfb --- /dev/null +++ b/test/files/run/t4537/c.scala @@ -0,0 +1,8 @@ +package b +package c + +import a._ + +object Unambiguous { + println(Settings.Y) +} diff --git a/test/files/run/t4537/d.scala b/test/files/run/t4537/d.scala new file mode 100644 index 0000000000..dd1d2045ed --- /dev/null +++ b/test/files/run/t4537/d.scala @@ -0,0 +1,6 @@ +import a._ +import b._ + +object Test extends App { + println(Settings.Y) +} diff --git a/test/files/run/t4671.check b/test/files/run/t4671.check index 4699818cd4..d4f8af480a 100644 --- a/test/files/run/t4671.check +++ b/test/files/run/t4671.check @@ -2,7 +2,7 @@ Type in expressions to have them evaluated. Type :help for more information. scala> object o { val file = sys.props("partest.cwd") + "/t4671.scala" } -defined module o +defined object o scala> val s = scala.io.Source.fromFile(o.file) s: scala.io.BufferedSource = non-empty iterator diff --git a/test/files/run/t4729/S_2.scala b/test/files/run/t4729/S_2.scala index e34e3d34d4..a80afb0257 100644 --- a/test/files/run/t4729/S_2.scala +++ b/test/files/run/t4729/S_2.scala @@ -20,7 +20,7 @@ object Test { (new ScalaVarArgs).method("1", "2") (new ScalaVarArgs: J_1).method("1", "2") - //[4] Not Ok -- error when assigning anonymous class to a explictly typed val + //[4] Not Ok -- error when assigning anonymous class to an explictly typed val // Compiler error: object creation impossible, since method method in trait VarArgs of type (s: <repeated...>[java.lang.String])Unit is not defined val tagged: J_1 = new J_1 { def method(s: String*) { println(s) } diff --git a/test/files/run/t4859.check b/test/files/run/t4859.check new file mode 100644 index 0000000000..d329744ca0 --- /dev/null +++ b/test/files/run/t4859.check @@ -0,0 +1,8 @@ +Inner +Inner.i +About to reference Inner.i +Outer +Inner.i +About to reference O.N +About to reference O.N +About to reference O.N.apply() diff --git a/test/files/run/t4859.scala b/test/files/run/t4859.scala new file mode 100644 index 0000000000..3c20cea983 --- /dev/null +++ b/test/files/run/t4859.scala @@ -0,0 +1,29 @@ +object O { + case class N() + object P +} + +object Outer { + println("Outer") + object Inner { + println("Inner") + def i { + println("Inner.i") + } + } +} + +object Test { + def main(args: Array[String]) { + Outer.Inner.i // we still don't initialize Outer here (but should we?) + + {println("About to reference Inner.i"); Outer}.Inner.i // Outer will be initialized. + + {println("About to reference O.N" ); O}.N + + {println("About to reference O.N" ); O}.N + + {println("About to reference O.N.apply()"); O}.N.apply() + } +} + diff --git a/test/files/run/t4935.flags b/test/files/run/t4935.flags index ac14fe5dbd..49d036a887 100644 --- a/test/files/run/t4935.flags +++ b/test/files/run/t4935.flags @@ -1 +1 @@ --optimize
+-optimize diff --git a/test/files/run/t4996.check b/test/files/run/t4996.check new file mode 100644 index 0000000000..8d45b413c9 --- /dev/null +++ b/test/files/run/t4996.check @@ -0,0 +1,4 @@ +B.foo +M.foo +B.foo +M.foo
\ No newline at end of file diff --git a/test/files/run/t4996.scala b/test/files/run/t4996.scala new file mode 100644 index 0000000000..8e7636aaac --- /dev/null +++ b/test/files/run/t4996.scala @@ -0,0 +1,47 @@ + + + + + + +trait A[@specialized(Int) T] { + def foo(t: T) +} + + +trait B extends A[Int] { + def foo(t: Int) { + println("B.foo") + } +} + + +trait M extends B { + abstract override def foo(t: Int) { + super.foo(t) + println("M.foo") + } +} + + +object C extends B with M + + +object D extends B { + override def foo(t: Int) { + super.foo(t) + println("M.foo") + } +} + + +object Test { + + def main(args: Array[String]) { + D.foo(42) // OK, prints B.foo M.foo + C.foo(42) // was StackOverflowError + } + +} + + diff --git a/test/files/run/t5064.check b/test/files/run/t5064.check index 077006abd9..61ccfd16e7 100644 --- a/test/files/run/t5064.check +++ b/test/files/run/t5064.check @@ -1,6 +1,6 @@ -[12] T5064.super.<init>() -[12] T5064.super.<init> -[12] this +[53] T5064.super.<init>() +[53] T5064.super.<init> +[53] this [16:23] immutable.this.List.apply(scala.this.Predef.wrapIntArray(Array[Int]{1})) [16:20] immutable.this.List.apply <16:20> immutable.this.List diff --git a/test/files/run/t5225_2.check b/test/files/run/t5225_2.check index 8ed54a14bb..477ea4eb6d 100644 --- a/test/files/run/t5225_2.check +++ b/test/files/run/t5225_2.check @@ -1,4 +1,4 @@ { - def foo(@new cloneable() x: Int) = ""; + def foo(@new elidable(0) x: Int) = ""; () } diff --git a/test/files/run/t5225_2.scala b/test/files/run/t5225_2.scala index d1b607499c..cf0f23a5c8 100644 --- a/test/files/run/t5225_2.scala +++ b/test/files/run/t5225_2.scala @@ -1,6 +1,6 @@ import scala.reflect.runtime.universe._ object Test extends App { - val tree = reify{def foo(@cloneable x: Int) = ""}.tree + val tree = reify{def foo(@annotation.elidable(0) x: Int) = ""}.tree println(tree.toString) }
\ No newline at end of file diff --git a/test/files/run/t5293-map.scala b/test/files/run/t5293-map.scala new file mode 100644 index 0000000000..2707aed07e --- /dev/null +++ b/test/files/run/t5293-map.scala @@ -0,0 +1,88 @@ + + + +import scala.collection.JavaConverters._ + + + +object Test extends App { + + def bench(label: String)(body: => Unit): Long = { + val start = System.nanoTime + + 0.until(10).foreach(_ => body) + + val end = System.nanoTime + + //println("%s: %s ms".format(label, (end - start) / 1000.0 / 1000.0)) + + end - start + } + + def benchJava(values: java.util.Map[Int, Int]) = { + bench("Java Map") { + val m = new java.util.HashMap[Int, Int] + + m.putAll(values) + } + } + + def benchScala(values: Iterable[(Int, Int)]) = { + bench("Scala Map") { + val m = new scala.collection.mutable.HashMap[Int, Int] + + m ++= values + } + } + + def benchScalaSorted(values: Iterable[(Int, Int)]) = { + bench("Scala Map sorted") { + val m = new scala.collection.mutable.HashMap[Int, Int] + + m ++= values.toArray.sorted + } + } + + def benchScalaPar(values: Iterable[(Int, Int)]) = { + bench("Scala ParMap") { + val m = new scala.collection.parallel.mutable.ParHashMap[Int, Int] map { x => x } + + m ++= values + } + } + + val total = 50000 + val values = (0 until total) zip (0 until total) + val map = scala.collection.mutable.HashMap.empty[Int, Int] + + map ++= values + + // warmup + for (x <- 0 until 5) { + benchJava(map.asJava) + benchScala(map) + benchScalaPar(map) + benchJava(map.asJava) + benchScala(map) + benchScalaPar(map) + } + + val javamap = benchJava(map.asJava) + val scalamap = benchScala(map) + val scalaparmap = benchScalaPar(map) + + // println(javamap) + // println(scalamap) + // println(scalaparmap) + + assert(scalamap < (javamap * 10), "scalamap: " + scalamap + " vs. javamap: " + javamap) + assert(scalaparmap < (javamap * 10), "scalaparmap: " + scalaparmap + " vs. javamap: " + javamap) +} + + + + + + + + diff --git a/test/files/run/t5293.scala b/test/files/run/t5293.scala new file mode 100644 index 0000000000..01ead45d2a --- /dev/null +++ b/test/files/run/t5293.scala @@ -0,0 +1,83 @@ + + + +import scala.collection.JavaConverters._ + + + +object Test extends App { + + def bench(label: String)(body: => Unit): Long = { + val start = System.nanoTime + + 0.until(10).foreach(_ => body) + + val end = System.nanoTime + + //println("%s: %s ms".format(label, (end - start) / 1000.0 / 1000.0)) + + end - start + } + + def benchJava(values: java.util.Collection[Int]) = { + bench("Java Set") { + val set = new java.util.HashSet[Int] + + set.addAll(values) + } + } + + def benchScala(values: Iterable[Int]) = { + bench("Scala Set") { + val set = new scala.collection.mutable.HashSet[Int] + + set ++= values + } + } + + def benchScalaSorted(values: Iterable[Int]) = { + bench("Scala Set sorted") { + val set = new scala.collection.mutable.HashSet[Int] + + set ++= values.toArray.sorted + } + } + + def benchScalaPar(values: Iterable[Int]) = { + bench("Scala ParSet") { + val set = new scala.collection.parallel.mutable.ParHashSet[Int] map { x => x } + + set ++= values + } + } + + val values = 0 until 50000 + val set = scala.collection.mutable.HashSet.empty[Int] + + set ++= values + + // warmup + for (x <- 0 until 5) { + benchJava(set.asJava) + benchScala(set) + benchScalaPar(set) + benchJava(set.asJava) + benchScala(set) + benchScalaPar(set) + } + + val javaset = benchJava(set.asJava) + val scalaset = benchScala(set) + val scalaparset = benchScalaPar(set) + + assert(scalaset < (javaset * 8), "scalaset: " + scalaset + " vs. javaset: " + javaset) + assert(scalaparset < (javaset * 8), "scalaparset: " + scalaparset + " vs. javaset: " + javaset) +} + + + + + + + + diff --git a/test/files/run/t5353.check b/test/files/run/t5353.check new file mode 100644 index 0000000000..a2906793ed --- /dev/null +++ b/test/files/run/t5353.check @@ -0,0 +1,2 @@ +1 +[Ljava.lang.Object; cannot be cast to [Ljava.lang.String; diff --git a/test/files/run/t5353.scala b/test/files/run/t5353.scala new file mode 100644 index 0000000000..5208fe527f --- /dev/null +++ b/test/files/run/t5353.scala @@ -0,0 +1,9 @@ +object Test extends App { + def f(x: Boolean) = if (x) Array("abc") else Array() + try { + println(f(true).length) + println(f(false).length) + } catch { + case ex: Throwable => println(ex.getMessage) + } +} diff --git a/test/files/run/t5374.check b/test/files/run/t5374.check index 6be88d77ec..c1cd843080 100644 --- a/test/files/run/t5374.check +++ b/test/files/run/t5374.check @@ -2,5 +2,4 @@ ListBuffer(1, 2, 3, 1) ListBuffer(1, 2, 3, 1) ListBuffer() List(1, 2, 3, 4, 5) -List(1, 2, 3) -ok
\ No newline at end of file +ok diff --git a/test/files/run/t5374.scala b/test/files/run/t5374.scala index 9b1671e795..f6a913e35c 100644 --- a/test/files/run/t5374.scala +++ b/test/files/run/t5374.scala @@ -7,15 +7,15 @@ import java.io._ object Test { - + def main(args: Array[String]) { ticketExample() emptyListBuffer() list() - legacyList() + // legacyList() objectWithMultipleLists() } - + def inAndOut[T <: AnyRef](obj: T): T = { val baos = new ByteArrayOutputStream val oos = new ObjectOutputStream(baos) @@ -24,53 +24,53 @@ object Test { val ois = new ObjectInputStream(bais) ois.readObject.asInstanceOf[T] } - + def ticketExample() { val lb = inAndOut(ListBuffer(1, 2, 3)) val lb2 = ListBuffer[Int]() ++= lb - + lb2 ++= List(1) lb ++= List(1) println(lb) println(lb2) } - + def emptyListBuffer() { val lb = inAndOut(ListBuffer[Int]()) - + println(lb) } - + def list() { val l = inAndOut(List(1, 2, 3, 4, 5)) - + println(l) } - + // this byte array corresponds to what List(1, 2, 3) used to be serialized to prior to this fix val listBytes = Array[Byte](-84, -19, 0, 5, 115, 114, 0, 39, 115, 99, 97, 108, 97, 46, 99, 111, 108, 108, 101, 99, 116, 105, 111, 110, 46, 105, 109, 109, 117, 116, 97, 98, 108, 101, 46, 36, 99, 111, 108, 111, 110, 36, 99, 111, 108, 111, 110, -118, 92, 99, 91, -10, -40, -7, 109, 3, 0, 2, 76, 0, 43, 115, 99, 97, 108, 97, 36, 99, 111, 108, 108, 101, 99, 116, 105, 111, 110, 36, 105, 109, 109, 117, 116, 97, 98, 108, 101, 36, 36, 99, 111, 108, 111, 110, 36, 99, 111, 108, 111, 110, 36, 36, 104, 100, 116, 0, 18, 76, 106, 97, 118, 97, 47, 108, 97, 110, 103, 47, 79, 98, 106, 101, 99, 116, 59, 76, 0, 2, 116, 108, 116, 0, 33, 76, 115, 99, 97, 108, 97, 47, 99, 111, 108, 108, 101, 99, 116, 105, 111, 110, 47, 105, 109, 109, 117, 116, 97, 98, 108, 101, 47, 76, 105, 115, 116, 59, 120, 112, 115, 114, 0, 17, 106, 97, 118, 97, 46, 108, 97, 110, 103, 46, 73, 110, 116, 101, 103, 101, 114, 18, -30, -96, -92, -9, -127, -121, 56, 2, 0, 1, 73, 0, 5, 118, 97, 108, 117, 101, 120, 114, 0, 16, 106, 97, 118, 97, 46, 108, 97, 110, 103, 46, 78, 117, 109, 98, 101, 114, -122, -84, -107, 29, 11, -108, -32, -117, 2, 0, 0, 120, 112, 0, 0, 0, 1, 115, 113, 0, 126, 0, 4, 0, 0, 0, 2, 115, 113, 0, 126, 0, 4, 0, 0, 0, 3, 115, 114, 0, 44, 115, 99, 97, 108, 97, 46, 99, 111, 108, 108, 101, 99, 116, 105, 111, 110, 46, 105, 109, 109, 117, 116, 97, 98, 108, 101, 46, 76, 105, 115, 116, 83, 101, 114, 105, 97, 108, 105, 122, 101, 69, 110, 100, 36, -118, 92, 99, 91, -9, 83, 11, 109, 2, 0, 0, 120, 112, 120) - - def legacyList() { - val bais = new ByteArrayInputStream(listBytes) - val ois = new ObjectInputStream(bais) - val l = ois.readObject() - - println(l) - } - + + // def legacyList() { + // val bais = new ByteArrayInputStream(listBytes) + // val ois = new ObjectInputStream(bais) + // val l = ois.readObject() + + // println(l) + // } + class Foo extends Serializable { val head = List(1, 2, 3) val last = head.tail.tail def structuralSharing: Boolean = head.tail.tail eq last - + assert(structuralSharing) } - + def objectWithMultipleLists() { val foo = inAndOut(new Foo) - + if (foo.structuralSharing) println("ok") else println("no structural sharing") } - + } diff --git a/test/files/run/t5418.check b/test/files/run/t5418.check new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/files/run/t5418.check diff --git a/test/files/run/t5418.scala b/test/files/run/t5418.scala new file mode 100644 index 0000000000..e3cb20cf82 --- /dev/null +++ b/test/files/run/t5418.scala @@ -0,0 +1,8 @@ +import scala.reflect.runtime.universe._ +import scala.tools.reflect.Eval + +object Test extends App { + reify { + new Object().getClass + }.eval +}
\ No newline at end of file diff --git a/test/files/run/t5418b.check b/test/files/run/t5418b.check index 48d82a2aae..f036a4be84 100644 --- a/test/files/run/t5418b.check +++ b/test/files/run/t5418b.check @@ -1,2 +1,2 @@ new Object().getClass() -TypeRef(ThisType(java.lang), java.lang.Class, List(TypeRef(NoPrefix, newTypeName("?0"), List()))) +TypeRef(ThisType(java.lang), java.lang.Class, List(TypeRef(NoPrefix, TypeName("?0"), List()))) diff --git a/test/files/run/t5603.check b/test/files/run/t5603.check index 5127d3c1c7..3b2eb55313 100644 --- a/test/files/run/t5603.check +++ b/test/files/run/t5603.check @@ -12,7 +12,7 @@ [95:101]<paramaccessor> private[this] val i: [98:101]Int = _; <119:139>def <init>([95]i: [98]Int) = <119:139>{ <119:139>val nameElse = <134:139>"Bob"; - [94][94][94]super.<init>(); + [NoPosition][NoPosition][NoPosition]super.<init>(); [94]() }; [168:184]val name = [179:184]"avc"; @@ -20,7 +20,7 @@ }; [215:241]object Test extends [227:241][235:238]App { [227]def <init>() = [227]{ - [227][227][227]super.<init>(); + [NoPosition][NoPosition][NoPosition]super.<init>(); [227]() }; [NoPosition]<empty> diff --git a/test/files/run/t5610a.check b/test/files/run/t5610a.check new file mode 100644 index 0000000000..2aa46b3b91 --- /dev/null +++ b/test/files/run/t5610a.check @@ -0,0 +1 @@ +Stroke a kitten diff --git a/test/files/run/t5610a.scala b/test/files/run/t5610a.scala new file mode 100644 index 0000000000..f20b295762 --- /dev/null +++ b/test/files/run/t5610a.scala @@ -0,0 +1,19 @@ +object Test extends App { + class Result(_str: => String) { + lazy val str = _str + } + + def foo(str: => String)(i: Int) = new Result(str) + + def bar(f: Int => Result) = f(42) + + var test: String = null + val result = bar(foo(test)) + test = "bar" + + if (result.str == null) { + println("Destroy ALL THE THINGS!!!") + } else { + println("Stroke a kitten") + } +}
\ No newline at end of file diff --git a/test/files/run/t5655.check b/test/files/run/t5655.check index 43ebd50e7a..1103b0e36f 100644 --- a/test/files/run/t5655.check +++ b/test/files/run/t5655.check @@ -4,7 +4,7 @@ Type :help for more information. scala> scala> object x { def x={} } -defined module x +defined object x scala> import x._ import x._ diff --git a/test/files/run/t5879.check b/test/files/run/t5879.check index b6cbda35a7..4bdf3f5fcf 100644 --- a/test/files/run/t5879.check +++ b/test/files/run/t5879.check @@ -1,16 +1,8 @@ Map(1 -> 1) 1 -Map(1 -> 1) -1 -(1,1) -Map(1 -> 1) -1 (1,1) Map(1 -> 1) 1 (1,2) Map(1 -> 2) 2 -(1,2) -Map(1 -> 2) -2
\ No newline at end of file diff --git a/test/files/run/t5879.scala b/test/files/run/t5879.scala index e1c07fc4c2..18dd94289d 100644 --- a/test/files/run/t5879.scala +++ b/test/files/run/t5879.scala @@ -17,10 +17,6 @@ object Test { val r = a.merged(b)(null) println(r) println(r(1)) - - val rold = a.merge(b) - println(rold) - println(rold(1)) } def resolveFirst() { @@ -34,10 +30,6 @@ object Test { val r = a.merged(b) { collision } println(r) println(r(1)) - - val rold = a.merge(b, collision) - println(rold) - println(rold(1)) } def resolveSecond() { @@ -51,10 +43,6 @@ object Test { val r = a.merged(b) { collision } println(r) println(r(1)) - - val rold = a.merge(b, collision) - println(rold) - println(rold(1)) } def resolveMany() { @@ -66,9 +54,6 @@ object Test { val r = a.merged(b) { collision } for ((k, v) <- r) assert(v == 100 + 2 * k, (k, v)) - - val rold = a.merge(b, collision) - for ((k, v) <- r) assert(v == 100 + 2 * k, (k, v)) } } diff --git a/test/files/run/t6028.check b/test/files/run/t6028.check index 79deaacf3a..942f3d5f0c 100644 --- a/test/files/run/t6028.check +++ b/test/files/run/t6028.check @@ -31,14 +31,14 @@ package <empty> { }; final def apply(): Int = $anonfun$foo$1.this.apply$mcI$sp(); <specialized> def apply$mcI$sp(): Int = $anonfun$foo$1.this.$outer.T$$classParam.+($anonfun$foo$1.this.$outer.field()).+($anonfun$foo$1.this.methodParam$1).+($anonfun$foo$1.this.methodLocal$1); - <synthetic> <paramaccessor> private[this] val $outer: T = _; - <synthetic> <stable> def T$$anonfun$$$outer(): T = $anonfun$foo$1.this.$outer; - final <bridge> def apply(): Object = scala.Int.box($anonfun$foo$1.this.apply()); + <synthetic> <paramaccessor> <artifact> private[this] val $outer: T = _; + <synthetic> <stable> <artifact> def T$$anonfun$$$outer(): T = $anonfun$foo$1.this.$outer; + final <bridge> <artifact> def apply(): Object = scala.Int.box($anonfun$foo$1.this.apply()); <synthetic> <paramaccessor> private[this] val methodParam$1: Int = _; <synthetic> <paramaccessor> private[this] val methodLocal$1: Int = _ }; abstract trait MethodLocalTrait$1 extends Object { - <synthetic> <stable> def T$MethodLocalTrait$$$outer(): T + <synthetic> <stable> <artifact> def T$MethodLocalTrait$$$outer(): T }; object MethodLocalObject$2 extends Object with T#MethodLocalTrait$1 { def <init>($outer: T, barParam$1: Int): T#MethodLocalObject$2.type = { @@ -46,9 +46,9 @@ package <empty> { MethodLocalObject$2.this.$asInstanceOf[T#MethodLocalTrait$1$class]()./*MethodLocalTrait$1$class*/$init$(barParam$1); () }; - <synthetic> <paramaccessor> private[this] val $outer: T = _; - <synthetic> <stable> def T$MethodLocalObject$$$outer(): T = MethodLocalObject$2.this.$outer; - <synthetic> <stable> def T$MethodLocalTrait$$$outer(): T = MethodLocalObject$2.this.$outer + <synthetic> <paramaccessor> <artifact> private[this] val $outer: T = _; + <synthetic> <stable> <artifact> def T$MethodLocalObject$$$outer(): T = MethodLocalObject$2.this.$outer; + <synthetic> <stable> <artifact> def T$MethodLocalTrait$$$outer(): T = MethodLocalObject$2.this.$outer }; final <stable> private[this] def MethodLocalObject$1(barParam$1: Int, MethodLocalObject$module$1: runtime.VolatileObjectRef): T#MethodLocalObject$2.type = { MethodLocalObject$module$1.elem = new T#MethodLocalObject$2.type(T.this, barParam$1); @@ -69,9 +69,9 @@ package <empty> { <specialized> def apply$mcV$sp(): Unit = try { $anonfun$tryy$1.this.tryyLocal$1.elem = $anonfun$tryy$1.this.tryyParam$1 } finally (); - <synthetic> <paramaccessor> private[this] val $outer: T = _; - <synthetic> <stable> def T$$anonfun$$$outer(): T = $anonfun$tryy$1.this.$outer; - final <bridge> def apply(): Object = { + <synthetic> <paramaccessor> <artifact> private[this] val $outer: T = _; + <synthetic> <stable> <artifact> def T$$anonfun$$$outer(): T = $anonfun$tryy$1.this.$outer; + final <bridge> <artifact> def apply(): Object = { $anonfun$tryy$1.this.apply(); scala.runtime.BoxedUnit.UNIT }; diff --git a/test/files/run/t6064.scala b/test/files/run/t6064.scala new file mode 100644 index 0000000000..fc184dd92d --- /dev/null +++ b/test/files/run/t6064.scala @@ -0,0 +1,9 @@ +object Test extends App { + assert(Option(42) contains 42) + assert(Some(42) contains 42) + assert(Option(BigInt(42)) contains 42) + assert(Option(42) contains BigInt(42)) + assert(!(None contains 42)) + assert(Some(null) contains null) + assert(!(Option(null) contains null)) +}
\ No newline at end of file diff --git a/test/files/run/t6150.scala b/test/files/run/t6150.scala index bd8af5d460..f3e83e1549 100644 --- a/test/files/run/t6150.scala +++ b/test/files/run/t6150.scala @@ -1,7 +1,3 @@ - - - - object Test { import collection.{ immutable, mutable, generic } def TheOneTrueCBF = collection.IndexedSeq.ReusableCBF @@ -38,7 +34,3 @@ object Test { check(iv.:+(4)(cbf3)) } } - - - - diff --git a/test/files/run/t6178.scala b/test/files/run/t6178.scala index 0b4cf0bbf5..41e148af91 100644 --- a/test/files/run/t6178.scala +++ b/test/files/run/t6178.scala @@ -2,6 +2,6 @@ import scala.reflect.runtime.universe._ import scala.reflect.runtime.{currentMirror => cm} object Test extends App { - val plus = typeOf[java.lang.String].member(newTermName("$plus")).asMethod + val plus = typeOf[java.lang.String].member(TermName("$plus")).asMethod println(cm.reflect("").reflectMethod(plus).apply("2")) }
\ No newline at end of file diff --git a/test/files/run/t6181.scala b/test/files/run/t6181.scala index fb23eaff63..eaa7340178 100644 --- a/test/files/run/t6181.scala +++ b/test/files/run/t6181.scala @@ -3,6 +3,6 @@ import scala.reflect.runtime.{currentMirror => cm} object Test extends App { class C { def test(x: => Int) = println(x) } - val mm = cm.reflect(new C).reflectMethod(typeOf[C].member(newTermName("test")).asMethod) + val mm = cm.reflect(new C).reflectMethod(typeOf[C].member(TermName("test")).asMethod) mm(2) }
\ No newline at end of file diff --git a/test/files/run/t6199-mirror.scala b/test/files/run/t6199-mirror.scala index 772a384542..3fda56bf7c 100644 --- a/test/files/run/t6199-mirror.scala +++ b/test/files/run/t6199-mirror.scala @@ -3,5 +3,5 @@ import scala.reflect.runtime.{currentMirror => cm} object Test extends App { class C { def foo = () } - println(cm.reflect(new C).reflectMethod(typeOf[C].member(newTermName("foo")).asMethod)()) + println(cm.reflect(new C).reflectMethod(typeOf[C].member(TermName("foo")).asMethod)()) }
\ No newline at end of file diff --git a/test/files/run/t6223.check b/test/files/run/t6223.check index 90ec019407..4a09d1930f 100644 --- a/test/files/run/t6223.check +++ b/test/files/run/t6223.check @@ -1,4 +1,4 @@ bar -bar$mcI$sp bar$mIc$sp bar$mIcI$sp +bar$mcI$sp diff --git a/test/files/run/t6223.scala b/test/files/run/t6223.scala index 4ab7c832e6..fb176e32e6 100644 --- a/test/files/run/t6223.scala +++ b/test/files/run/t6223.scala @@ -5,7 +5,7 @@ class Foo[@specialized(Int) A](a:A) { object Test { def main(args:Array[String]) { val f = new Foo(333) - val ms = f.getClass().getDeclaredMethods() + val ms = f.getClass().getDeclaredMethods().sortBy(_.getName) ms.foreach(m => println(m.getName)) } } diff --git a/test/files/run/t6259.scala b/test/files/run/t6259.scala new file mode 100644 index 0000000000..294c95e96b --- /dev/null +++ b/test/files/run/t6259.scala @@ -0,0 +1,56 @@ +import scala.reflect.runtime.universe._ + +class A[X](implicit val tt: TypeTag[X]) {} +object B extends A[String] + +object C { + object D extends A[String] +} + +trait E { + object F extends A[String] +} + +class G { + object H extends A[String] +} + +object HasX { + val x = { + object InVal extends A[String] + InVal + 5 + } + +} + +trait NeedsEarly { + val x: AnyRef +} + +object Early extends { + // Drops to this.getClass and is not ok... + val x = { object EarlyOk extends A[String]; EarlyOk } +} with NeedsEarly + + +class DoubleTrouble[X](x: AnyRef)(implicit override val tt: TypeTag[X]) extends A[X] + +object DoubleOk extends DoubleTrouble[String]({ + // Drops to this.getClass and is an issue + object InnerTrouble extends A[String]; + InnerTrouble +}) + +object Test extends App { + B + C.D + val e = new E {}; e.F + val g = new G; g.H + + locally(HasX.x) + // locally(Early.x) TODO sort out VerifyError in Early$.<init> + // DoubleOk TODO sort out VerifyError in DoubleOk$.<init> +} + + diff --git a/test/files/run/t6288.check b/test/files/run/t6288.check index e6467edc95..4465b6302c 100644 --- a/test/files/run/t6288.check +++ b/test/files/run/t6288.check @@ -1,8 +1,8 @@ [[syntax trees at end of patmat]] // newSource1 [7]package [7]<empty> { [7]object Case3 extends [13][106]scala.AnyRef { - [13]def <init>(): [13]Case3.type = [13]{ - [13][13][13]Case3.super.<init>(); + [106]def <init>(): [13]Case3.type = [106]{ + [106][106][106]Case3.super.<init>(); [13]() }; [21]def unapply([29]z: [32]<type: [32]scala.Any>): [21]Option[Int] = [56][52][52]scala.Some.apply[[52]Int]([58]-1); @@ -24,8 +24,8 @@ } }; [113]object Case4 extends [119][217]scala.AnyRef { - [119]def <init>(): [119]Case4.type = [119]{ - [119][119][119]Case4.super.<init>(); + [217]def <init>(): [119]Case4.type = [217]{ + [217][217][217]Case4.super.<init>(); [119]() }; [127]def unapplySeq([138]z: [141]<type: [141]scala.Any>): [127]Option[List[Int]] = [167]scala.None; @@ -50,8 +50,8 @@ } }; [224]object Case5 extends [230][312]scala.AnyRef { - [230]def <init>(): [230]Case5.type = [230]{ - [230][230][230]Case5.super.<init>(); + [312]def <init>(): [230]Case5.type = [312]{ + [312][312][312]Case5.super.<init>(); [230]() }; [238]def unapply([246]z: [249]<type: [249]scala.Any>): [238]Boolean = [265]true; @@ -60,7 +60,7 @@ [273]case5()[293]{ [293]<synthetic> val o7: [293]Option[List[Int]] = [293][293]Case4.unapplySeq([293]x1); [293]if ([293]o7.isEmpty.unary_!) - [293]if ([293][293][293][293]o7.get.!=([293]null).&&([293][293][293][293]o7.get.lengthCompare([293]0).==([195]0))) + [293]if ([293][293][293][293]o7.get.!=([293]null).&&([293][293][293][293]o7.get.lengthCompare([293]0).==([293]0))) [304][304]matchEnd4([304]()) else [293][293]case6() diff --git a/test/files/run/t6288b-jump-position.check b/test/files/run/t6288b-jump-position.check index 83ba810958..ece88b18f0 100644 --- a/test/files/run/t6288b-jump-position.check +++ b/test/files/run/t6288b-jump-position.check @@ -65,9 +65,9 @@ object Case3 extends Object { blocks: [1] 1: - 1 THIS(Case3) - 1 CALL_METHOD java.lang.Object.<init> (super()) - 1 RETURN(UNIT) + 12 THIS(Case3) + 12 CALL_METHOD java.lang.Object.<init> (super()) + 12 RETURN(UNIT) } Exception handlers: diff --git a/test/files/run/t6329_repl.check b/test/files/run/t6329_repl.check index 8663184bde..55d689f2fb 100644 --- a/test/files/run/t6329_repl.check +++ b/test/files/run/t6329_repl.check @@ -3,11 +3,37 @@ Type :help for more information. scala> -scala> classManifest[List[_]] +scala> import scala.reflect.classTag +import scala.reflect.classTag + +scala> classManifest[scala.List[_]] warning: there were 1 deprecation warnings; re-run with -deprecation for details -res0: scala.reflect.ClassTag[List[_]] = scala.collection.immutable.List[Any] +res0: scala.reflect.ClassTag[List[_]] = scala.collection.immutable.List[<?>] -scala> scala.reflect.classTag[List[_]] +scala> classTag[scala.List[_]] res1: scala.reflect.ClassTag[List[_]] = scala.collection.immutable.List +scala> classManifest[scala.collection.immutable.List[_]] +warning: there were 1 deprecation warnings; re-run with -deprecation for details +res2: scala.reflect.ClassTag[List[_]] = scala.collection.immutable.List[<?>] + +scala> classTag[scala.collection.immutable.List[_]] +res3: scala.reflect.ClassTag[List[_]] = scala.collection.immutable.List + +scala> classManifest[Predef.Set[_]] +warning: there were 1 deprecation warnings; re-run with -deprecation for details +res4: scala.reflect.ClassTag[scala.collection.immutable.Set[_]] = scala.collection.immutable.Set[<?>] + +scala> classTag[Predef.Set[_]] +res5: scala.reflect.ClassTag[scala.collection.immutable.Set[_]] = scala.collection.immutable.Set + +scala> classManifest[scala.collection.immutable.Set[_]] +warning: there were 1 deprecation warnings; re-run with -deprecation for details +res6: scala.reflect.ClassTag[scala.collection.immutable.Set[_]] = scala.collection.immutable.Set[<?>] + +scala> classTag[scala.collection.immutable.Set[_]] +res7: scala.reflect.ClassTag[scala.collection.immutable.Set[_]] = scala.collection.immutable.Set + +scala> + scala> diff --git a/test/files/run/t6329_repl.scala b/test/files/run/t6329_repl.scala index add6d64962..f210d6512c 100644 --- a/test/files/run/t6329_repl.scala +++ b/test/files/run/t6329_repl.scala @@ -2,7 +2,14 @@ import scala.tools.partest.ReplTest object Test extends ReplTest { def code = """ - |classManifest[List[_]] - |scala.reflect.classTag[List[_]] - |""".stripMargin + |import scala.reflect.classTag + |classManifest[scala.List[_]] + |classTag[scala.List[_]] + |classManifest[scala.collection.immutable.List[_]] + |classTag[scala.collection.immutable.List[_]] + |classManifest[Predef.Set[_]] + |classTag[Predef.Set[_]] + |classManifest[scala.collection.immutable.Set[_]] + |classTag[scala.collection.immutable.Set[_]] + """.stripMargin } diff --git a/test/files/run/t6329_vanilla.check b/test/files/run/t6329_vanilla.check index 8282afaeba..ad8f4b5c77 100644 --- a/test/files/run/t6329_vanilla.check +++ b/test/files/run/t6329_vanilla.check @@ -1,2 +1,8 @@ -scala.collection.immutable.List[Any] +scala.collection.immutable.List[<?>] scala.collection.immutable.List +scala.collection.immutable.List[<?>] +scala.collection.immutable.List +scala.collection.immutable.Set[<?>] +scala.collection.immutable.Set +scala.collection.immutable.Set[<?>] +scala.collection.immutable.Set diff --git a/test/files/run/t6329_vanilla.scala b/test/files/run/t6329_vanilla.scala index a31cd5c72e..f2d843896d 100644 --- a/test/files/run/t6329_vanilla.scala +++ b/test/files/run/t6329_vanilla.scala @@ -1,4 +1,12 @@ +import scala.reflect.classTag + object Test extends App { - println(classManifest[List[_]]) - println(scala.reflect.classTag[List[_]]) -}
\ No newline at end of file + println(classManifest[scala.List[_]]) + println(classTag[scala.List[_]]) + println(classManifest[scala.collection.immutable.List[_]]) + println(classTag[scala.collection.immutable.List[_]]) + println(classManifest[Predef.Set[_]]) + println(classTag[Predef.Set[_]]) + println(classManifest[scala.collection.immutable.Set[_]]) + println(classTag[scala.collection.immutable.Set[_]]) +} diff --git a/test/files/run/t6381.check b/test/files/run/t6381.check new file mode 100644 index 0000000000..5070b67e46 --- /dev/null +++ b/test/files/run/t6381.check @@ -0,0 +1,17 @@ +Type in expressions to have them evaluated. +Type :help for more information. + +scala> import language.experimental.macros +import language.experimental.macros + +scala> def pos_impl(c: reflect.macros.Context): c.Expr[String] = + c.literal(c.enclosingPosition.getClass.toString) +pos_impl: (c: scala.reflect.macros.Context)c.Expr[String] + +scala> def pos = macro pos_impl +defined term macro pos: String + +scala> pos +res0: String = class scala.reflect.internal.util.RangePosition + +scala> diff --git a/test/files/run/t6381.scala b/test/files/run/t6381.scala new file mode 100644 index 0000000000..859ec3cb30 --- /dev/null +++ b/test/files/run/t6381.scala @@ -0,0 +1,13 @@ +import scala.tools.partest.ReplTest + +object Test extends ReplTest { + def code = """ + |import language.experimental.macros + |def pos_impl(c: reflect.macros.Context): c.Expr[String] = + | c.literal(c.enclosingPosition.getClass.toString) + |def pos = macro pos_impl + |pos + |""".stripMargin.trim + + override def extraSettings: String = "-Yrangepos" +} diff --git a/test/files/run/t6392b.check b/test/files/run/t6392b.check index e9c7ecaa34..2afc48495f 100644 --- a/test/files/run/t6392b.check +++ b/test/files/run/t6392b.check @@ -1 +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(()))))))) +ModuleDef(Modifiers(), TermName("C"), Template(List(Select(Ident(scala#PK), TypeName("AnyRef")#TPE)), emptyValDef, List(DefDef(Modifiers(), nme.CONSTRUCTOR, List(), List(List()), TypeTree(), Block(List(Apply(Select(Super(This(TypeName("C")), tpnme.EMPTY), nme.CONSTRUCTOR#PCTOR), List())), Literal(Constant(()))))))) diff --git a/test/files/run/t6394a/Macros_1.scala b/test/files/run/t6394a/Macros_1.scala index 3d39d3e40a..5aa07e7f41 100644 --- a/test/files/run/t6394a/Macros_1.scala +++ b/test/files/run/t6394a/Macros_1.scala @@ -4,7 +4,7 @@ object Macros { def impl(c:Context): c.Expr[Any] = { import c.universe._ - val selfTree = This(c.enclosingClass.symbol.asModule.moduleClass) + val selfTree = This(c.enclosingImpl.symbol.asModule.moduleClass) c.Expr[AnyRef](selfTree) } diff --git a/test/files/run/t6406-regextract.check b/test/files/run/t6406-regextract.check new file mode 100644 index 0000000000..88c5a52eb3 --- /dev/null +++ b/test/files/run/t6406-regextract.check @@ -0,0 +1,4 @@ +List(1, 3) +List(1, 3) +List(1, 3) +Some(2011) Some(2011) diff --git a/test/files/run/t6406-regextract.scala b/test/files/run/t6406-regextract.scala new file mode 100644 index 0000000000..83679a5167 --- /dev/null +++ b/test/files/run/t6406-regextract.scala @@ -0,0 +1,30 @@ + +object Test extends App { + import util.matching._ + import Regex._ + + val r = "(\\d+)".r + val q = """(\d)""".r + val ns = List("1,2","x","3,4") + val u = r.unanchored + + val is = ns collect { case u(x) => x } map { case r(x) => x } + println(is) + // Match from same pattern + val js = (ns map { u findFirstMatchIn _ }).flatten map { case r(x) => x } + println(js) + // Match not from same pattern + val ks = (ns map { q findFirstMatchIn _ }).flatten map { case r(x) => x } + println(ks) + + val t = "Last modified 2011-07-15" + val p1 = """(\d\d\d\d)-(\d\d)-(\d\d)""".r + val y1: Option[String] = for { + p1(year, month, day) <- p1 findFirstIn t + } yield year + val y2: Option[String] = for { + p1(year, month, day) <- p1 findFirstMatchIn t + } yield year + println(s"$y1 $y2") + +} diff --git a/test/files/run/t6439.check b/test/files/run/t6439.check index 178ea739f5..3f5f7dc8a4 100644 --- a/test/files/run/t6439.check +++ b/test/files/run/t6439.check @@ -7,7 +7,7 @@ scala> class A defined class A scala> object A // warn -defined module A +defined object A warning: previously defined class A is not a companion to object A. Companions must be defined together; you may wish to use :paste mode for this. @@ -15,15 +15,15 @@ scala> trait B defined trait B scala> object B // warn -defined module B +defined object B warning: previously defined trait B is not a companion to object B. Companions must be defined together; you may wish to use :paste mode for this. scala> object C -defined module C +defined object C scala> object Bippy -defined module Bippy +defined object Bippy scala> class C // warn defined class C @@ -40,13 +40,13 @@ scala> val D = 0 // no warn D: Int = 0 scala> object E -defined module E +defined object E scala> var E = 0 // no warn E: Int = 0 scala> object F -defined module F +defined object F scala> type F = Int // no warn defined type alias F @@ -58,7 +58,18 @@ scala> :power ** global._, definitions._ also imported ** ** Try :help, :vals, power.<tab> ** -scala> intp("F") // this now works as a result of changing .typeSymbol to .typeSymbolDirect in IMain#Request#definedSymbols +scala> object lookup { + import intp._ + def apply(name: String): Symbol = types(name) orElse terms(name) + def types(name: String): Symbol = replScope lookup (name: TypeName) orElse getClassIfDefined(name) + def terms(name: String): Symbol = replScope lookup (name: TermName) orElse getModuleIfDefined(name) + def types[T: global.TypeTag] : Symbol = typeOf[T].typeSymbol + def terms[T: global.TypeTag] : Symbol = typeOf[T].termSymbol + def apply[T: global.TypeTag] : Symbol = typeOf[T].typeSymbol +} +defined object lookup + +scala> lookup("F") // this now works as a result of changing .typeSymbol to .typeSymbolDirect in IMain#Request#definedSymbols res0: $r.intp.global.Symbol = type F scala> diff --git a/test/files/run/t6439.scala b/test/files/run/t6439.scala index 70a2dbafaf..175a1d134f 100644 --- a/test/files/run/t6439.scala +++ b/test/files/run/t6439.scala @@ -1,6 +1,7 @@ import scala.tools.partest.ReplTest object Test extends ReplTest { + def code = """ class A object A // warn @@ -17,6 +18,15 @@ var E = 0 // no warn object F type F = Int // no warn :power -intp("F") // this now works as a result of changing .typeSymbol to .typeSymbolDirect in IMain#Request#definedSymbols +object lookup { + import intp._ + def apply(name: String): Symbol = types(name) orElse terms(name) + def types(name: String): Symbol = replScope lookup (name: TypeName) orElse getClassIfDefined(name) + def terms(name: String): Symbol = replScope lookup (name: TermName) orElse getModuleIfDefined(name) + def types[T: global.TypeTag] : Symbol = typeOf[T].typeSymbol + def terms[T: global.TypeTag] : Symbol = typeOf[T].termSymbol + def apply[T: global.TypeTag] : Symbol = typeOf[T].typeSymbol +} +lookup("F") // this now works as a result of changing .typeSymbol to .typeSymbolDirect in IMain#Request#definedSymbols """ } diff --git a/test/files/run/t6448.check b/test/files/run/t6448.check new file mode 100644 index 0000000000..9401568319 --- /dev/null +++ b/test/files/run/t6448.check @@ -0,0 +1,32 @@ + +=List.collect= +f(1) +f(2) +List(1) + +=List.collectFirst= +f(1) +Some(1) + +=Option.collect= +f(1) +Some(1) + +=Option.collect= +f(2) +None + +=Stream.collect= +f(1) +f(2) +List(1) + +=Stream.collectFirst= +f(1) +Some(1) + +=ParVector.collect= +(ParVector(1),2) + +=ParArray.collect= +(ParArray(1),2) diff --git a/test/files/run/t6448.scala b/test/files/run/t6448.scala new file mode 100644 index 0000000000..4d1528e500 --- /dev/null +++ b/test/files/run/t6448.scala @@ -0,0 +1,61 @@ +// Tests to show that various `collect` functions avoid calling +// both `PartialFunction#isDefinedAt` and `PartialFunction#apply`. +// +object Test { + def f(i: Int) = { println("f(" + i + ")"); true } + class Counter { + var count = 0 + def apply(i: Int) = synchronized {count += 1; true} + } + + def testing(label: String)(body: => Any) { + println(s"\n=$label=") + println(body) + } + + def main(args: Array[String]) { + testing("List.collect")(List(1, 2) collect { case x if f(x) && x < 2 => x}) + testing("List.collectFirst")(List(1, 2) collectFirst { case x if f(x) && x < 2 => x}) + testing("Option.collect")(Some(1) collect { case x if f(x) && x < 2 => x}) + testing("Option.collect")(Some(2) collect { case x if f(x) && x < 2 => x}) + testing("Stream.collect")((Stream(1, 2).collect { case x if f(x) && x < 2 => x}).toList) + testing("Stream.collectFirst")(Stream.continually(1) collectFirst { case x if f(x) && x < 2 => x}) + + import collection.parallel.ParIterable + import collection.parallel.immutable.ParVector + import collection.parallel.mutable.ParArray + testing("ParVector.collect") { + val counter = new Counter() + (ParVector(1, 2) collect { case x if counter(x) && x < 2 => x}, counter.synchronized(counter.count)) + } + + testing("ParArray.collect") { + val counter = new Counter() + (ParArray(1, 2) collect { case x if counter(x) && x < 2 => x}, counter.synchronized(counter.count)) + } + + object PendingTests { + testing("Iterator.collect")((Iterator(1, 2) collect { case x if f(x) && x < 2 => x}).toList) + + testing("List.view.collect")((List(1, 2).view collect { case x if f(x) && x < 2 => x}).force) + + // This would do the trick in Future.collect, but I haven't added this yet as there is a tradeoff + // with extra allocations to consider. + // + // pf.lift(v) match { + // case Some(x) => p success x + // case None => fail(v) + // } + testing("Future.collect") { + import concurrent.ExecutionContext.Implicits.global + import concurrent.Await + import concurrent.duration.Duration + val result = concurrent.future(1) collect { case x if f(x) => x} + Await.result(result, Duration.Inf) + } + + // TODO Future.{onSuccess, onFailure, recoverWith, andThen} + } + + } +} diff --git a/test/files/run/t6467.scala b/test/files/run/t6467.scala new file mode 100644 index 0000000000..dc93b69fdc --- /dev/null +++ b/test/files/run/t6467.scala @@ -0,0 +1,20 @@ + + + + +import collection._ + + + +object Test extends App { + + def compare(s1: String, s2: String) { + assert(s1 == s2, s1 + "\nvs.\n" + s2) + } + + compare(List(1, 2, 3, 4).aggregate(new java.lang.StringBuffer)(_ append _, _ append _).toString, "1234") + compare(List(1, 2, 3, 4).par.aggregate(new java.lang.StringBuffer)(_ append _, _ append _).toString, "1234") + compare(Seq(0 until 100: _*).aggregate(new java.lang.StringBuffer)(_ append _, _ append _).toString, (0 until 100).mkString) + compare(Seq(0 until 100: _*).par.aggregate(new java.lang.StringBuffer)(_ append _, _ append _).toString, (0 until 100).mkString) + +}
\ No newline at end of file diff --git a/test/files/run/t6506.scala b/test/files/run/t6506.scala new file mode 100644 index 0000000000..04d77c3c16 --- /dev/null +++ b/test/files/run/t6506.scala @@ -0,0 +1,8 @@ +object Test { + def main(args: Array[String]) { + new WL(new {} #:: S) with T + } + object S { def #::(a: Any): Any = () } + trait T + class WL(a: Any) +} diff --git a/test/files/run/t6548/Test_2.scala b/test/files/run/t6548/Test_2.scala index 6e4f6ba92a..7200259d36 100644 --- a/test/files/run/t6548/Test_2.scala +++ b/test/files/run/t6548/Test_2.scala @@ -8,5 +8,5 @@ class Bean { object Test extends App { println(cm.staticClass("Bean").isCaseClass) - println(typeOf[Bean].declaration(newTermName("value")).annotations) + println(typeOf[Bean].declaration(TermName("value")).annotations) } diff --git a/test/files/run/t6572/bar_1.scala b/test/files/run/t6572/bar_1.scala deleted file mode 100644 index 5518ced7af..0000000000 --- a/test/files/run/t6572/bar_1.scala +++ /dev/null @@ -1,19 +0,0 @@ -package bar - -abstract class IntBase[V] extends Base[Int, V] - -class DefaultIntBase[V <: IntProvider] extends IntBase[V] { - override protected def hashCode(key: Int) = key -} - -trait IntProvider { - def int: Int -} - -abstract class Base[@specialized K, V] { - - protected def hashCode(key: K) = key.hashCode - - def get(key: K): V = throw new RuntimeException - -}
\ No newline at end of file diff --git a/test/files/run/t6572/foo_2.scala b/test/files/run/t6572/foo_2.scala deleted file mode 100644 index 465f0b7c3c..0000000000 --- a/test/files/run/t6572/foo_2.scala +++ /dev/null @@ -1,17 +0,0 @@ -//package foo - -import bar._ - -class FooProvider extends IntProvider { - def int = 3 -} - -class Wrapper(users: DefaultIntBase[FooProvider]) { - final def user(userId: Int) = users.get(userId) -} - -object Test { - def main(args: Array[String]) { - new Wrapper(new DefaultIntBase) - } -}
\ No newline at end of file diff --git a/test/files/run/t6611.scala b/test/files/run/t6611.scala index 0947a48f90..c295368aea 100644 --- a/test/files/run/t6611.scala +++ b/test/files/run/t6611.scala @@ -7,55 +7,55 @@ object Test extends App { locally { val a = Array("1": Object) - val a2 = Array[Object](a: _*) + val a2 = Array(a: _*) assert(a ne a2) } locally { val a = Array(true) - val a2 = Array[Boolean](a: _*) + val a2 = Array(a: _*) assert(a ne a2) } locally { val a = Array(1: Short) - val a2 = Array[Short](a: _*) + val a2 = Array(a: _*) assert(a ne a2) } locally { val a = Array(1: Byte) - val a2 = Array[Byte](a: _*) + val a2 = Array(a: _*) assert(a ne a2) } locally { val a = Array(1) - val a2 = Array[Int](a: _*) + val a2 = Array(a: _*) assert(a ne a2) } locally { val a = Array(1L) - val a2 = Array[Long](a: _*) + val a2 = Array(a: _*) assert(a ne a2) } locally { val a = Array(1f) - val a2 = Array[Float](a: _*) + val a2 = Array(a: _*) assert(a ne a2) } locally { val a = Array(1d) - val a2 = Array[Double](a: _*) + val a2 = Array(a: _*) assert(a ne a2) } locally { val a = Array(()) - val a2 = Array[Unit](a: _*) + val a2 = Array(a: _*) assert(a ne a2) } } diff --git a/test/files/run/t6666a.scala b/test/files/run/t6666a.scala new file mode 100644 index 0000000000..1d208a32e7 --- /dev/null +++ b/test/files/run/t6666a.scala @@ -0,0 +1,16 @@ +class A(a: Any) + +object Test { + def main(args: Array[String]): Unit = { + } + + val x: Unit = { + object InVal extends A({ + new {} // okay + val o = {new {}} // nesting triggers a VerifyError. + null + }); + InVal; + () + }; +} diff --git a/test/files/run/t6745-2.scala b/test/files/run/t6745-2.scala new file mode 100644 index 0000000000..31ecd42bd1 --- /dev/null +++ b/test/files/run/t6745-2.scala @@ -0,0 +1,22 @@ +import scala.tools.nsc._ +import scala.tools.partest.CompilerTest +import scala.collection.{ mutable, immutable, generic } + +object Test extends CompilerTest { + import global._ + import rootMirror._ + import definitions._ + import global.analyzer.{Context, ImportInfo} + + override def code = """ +package context { +} + """ + + def check(source: String, unit: global.CompilationUnit) = { + val context: Context = global.analyzer.rootContext(unit) + val importInfo: ImportInfo = context.imports.head // Predef._ + val importedSym = importInfo.importedSymbol(nme.CONSTRUCTOR) + assert(importedSym == NoSymbol, importedSym) // was "constructor Predef" + } +} diff --git a/test/files/run/t6860.check b/test/files/run/t6860.check new file mode 100644 index 0000000000..c96331f540 --- /dev/null +++ b/test/files/run/t6860.check @@ -0,0 +1,4 @@ +Bippy[String] +Bippy[String] +throws[Nothing] +throws[RuntimeException] diff --git a/test/files/run/t6860.scala b/test/files/run/t6860.scala new file mode 100644 index 0000000000..2dcc2a67f7 --- /dev/null +++ b/test/files/run/t6860.scala @@ -0,0 +1,20 @@ +class Bippy[T](val value: T) extends annotation.StaticAnnotation + +class A { + @Bippy("hi") def f1: Int = 1 + @Bippy[String]("hi") def f2: Int = 2 + + @throws("what do I throw?") def f3 = throw new RuntimeException + @throws[RuntimeException]("that's good to know!") def f4 = throw new RuntimeException +} + +object Test { + import scala.reflect.runtime.universe._ + + def main(args: Array[String]): Unit = { + val members = typeOf[A].declarations.toList + val tpes = members flatMap (_.annotations) map (_.tpe) + + tpes.map(_.toString).sorted foreach println + } +} diff --git a/test/files/run/t6888.check b/test/files/run/t6888.check new file mode 100644 index 0000000000..4e8a2de2db --- /dev/null +++ b/test/files/run/t6888.check @@ -0,0 +1,3 @@ +2 +3 +3 diff --git a/test/files/run/t6888.scala b/test/files/run/t6888.scala new file mode 100644 index 0000000000..0c64cbe5b6 --- /dev/null +++ b/test/files/run/t6888.scala @@ -0,0 +1,19 @@ +class C { + val x = 1 + object $ { + val y = x + x + class abc$ { + def xy = x + y + } + object abc$ { + def xy = x + y + } + } +} + +object Test extends App { + val c = new C() + println(c.$.y) + println(c.$.abc$.xy) + println(new c.$.abc$().xy) +} diff --git a/test/files/run/t6939.scala b/test/files/run/t6939.scala new file mode 100644 index 0000000000..9fe721555f --- /dev/null +++ b/test/files/run/t6939.scala @@ -0,0 +1,13 @@ +object Test extends App { + val foo = <x:foo xmlns:x="http://foo.com/"><x:bar xmlns:x="http://bar.com/"><x:baz/></x:bar></x:foo> + assert(foo.child.head.scope.toString == """ xmlns:x="http://bar.com/"""") + + val fooDefault = <foo xmlns="http://foo.com/"><bar xmlns="http://bar.com/"><baz/></bar></foo> + assert(fooDefault.child.head.scope.toString == """ xmlns="http://bar.com/"""") + + val foo2 = scala.xml.XML.loadString("""<x:foo xmlns:x="http://foo.com/"><x:bar xmlns:x="http://bar.com/"><x:baz/></x:bar></x:foo>""") + assert(foo2.child.head.scope.toString == """ xmlns:x="http://bar.com/"""") + + val foo2Default = scala.xml.XML.loadString("""<foo xmlns="http://foo.com/"><bar xmlns="http://bar.com/"><baz/></bar></foo>""") + assert(foo2Default.child.head.scope.toString == """ xmlns="http://bar.com/"""") +} diff --git a/test/files/run/t6955.scala b/test/files/run/t6955.scala index 2610acdec4..980aa420cc 100644 --- a/test/files/run/t6955.scala +++ b/test/files/run/t6955.scala @@ -1,5 +1,6 @@ import scala.tools.partest.IcodeTest +// this class should compile to code that uses switches (twice) class Switches { type Tag = Byte @@ -10,7 +11,8 @@ class Switches { case _ => 0 } - def switchOkay(i: Byte): Int = i match { // notice type of i is Byte + // this worked before, should keep working + def switchOkay(i: Byte): Int = i match { case 1 => 1 case 2 => 2 case 3 => 3 diff --git a/test/files/run/t6957.scala b/test/files/run/t6957.scala new file mode 100644 index 0000000000..d0bf8e7b5e --- /dev/null +++ b/test/files/run/t6957.scala @@ -0,0 +1,8 @@ +object Test { + def main(args: Array[String]) { + class Foo + class Parent(f:Foo) + class Child extends Parent({val x=new Foo{}; x}) + new Child + } +} diff --git a/test/files/run/t6989.check b/test/files/run/t6989.check new file mode 100644 index 0000000000..8943792115 --- /dev/null +++ b/test/files/run/t6989.check @@ -0,0 +1,216 @@ +============ +sym = class PackagePrivateJavaClass, signature = ClassInfoType(...), owner = package foo +isPrivate = false +isProtected = false +isPublic = false +privateWithin = package foo +============ +sym = constructor PackagePrivateJavaClass, signature = (x$1: Int, x$2: Int)foo.PackagePrivateJavaClass, owner = class PackagePrivateJavaClass +isPrivate = false +isProtected = false +isPublic = true +privateWithin = <none> +============ +sym = variable privateField, signature = Int, owner = class PackagePrivateJavaClass +isPrivate = true +isProtected = false +isPublic = false +privateWithin = <none> +============ +sym = method privateMethod, signature = ()Unit, owner = class PackagePrivateJavaClass +isPrivate = true +isProtected = false +isPublic = false +privateWithin = <none> +============ +sym = variable protectedField, signature = Int, owner = class PackagePrivateJavaClass +isPrivate = false +isProtected = true +isPublic = false +privateWithin = package foo +============ +sym = method protectedMethod, signature = ()Unit, owner = class PackagePrivateJavaClass +isPrivate = false +isProtected = true +isPublic = false +privateWithin = package foo +============ +sym = variable publicField, signature = Int, owner = class PackagePrivateJavaClass +isPrivate = false +isProtected = false +isPublic = true +privateWithin = <none> +============ +sym = method publicMethod, signature = ()Unit, owner = class PackagePrivateJavaClass +isPrivate = false +isProtected = false +isPublic = true +privateWithin = <none> +============ +sym = object PackagePrivateJavaClass, signature = foo.PackagePrivateJavaClass.type, owner = package foo +isPrivate = false +isProtected = false +isPublic = false +privateWithin = package foo +============ +sym = variable privateStaticField, signature = Int, owner = object PackagePrivateJavaClass +isPrivate = true +isProtected = false +isPublic = false +privateWithin = <none> +============ +sym = method privateStaticMethod, signature = ()Unit, owner = object PackagePrivateJavaClass +isPrivate = true +isProtected = false +isPublic = false +privateWithin = <none> +============ +sym = variable protectedStaticField, signature = Int, owner = object PackagePrivateJavaClass +isPrivate = false +isProtected = true +isPublic = false +privateWithin = package foo +============ +sym = method protectedStaticMethod, signature = ()Unit, owner = object PackagePrivateJavaClass +isPrivate = false +isProtected = true +isPublic = false +privateWithin = package foo +============ +sym = variable publicStaticField, signature = Int, owner = object PackagePrivateJavaClass +isPrivate = false +isProtected = false +isPublic = true +privateWithin = <none> +============ +sym = method publicStaticMethod, signature = ()Unit, owner = object PackagePrivateJavaClass +isPrivate = false +isProtected = false +isPublic = true +privateWithin = <none> +============ +sym = class JavaClass_1, signature = ClassInfoType(...), owner = package foo +isPrivate = false +isProtected = false +isPublic = true +privateWithin = <none> +============ +sym = class $PrivateJavaClass, signature = ClassInfoType(...), owner = class JavaClass_1 +isPrivate = true +isProtected = false +isPublic = false +privateWithin = <none> +============ +sym = value this$0, signature = foo.JavaClass_1, owner = class $PrivateJavaClass +isPrivate = false +isProtected = false +isPublic = false +privateWithin = package foo +============ +sym = object $PrivateJavaClass, signature = JavaClass_1.this.$PrivateJavaClass.type, owner = class JavaClass_1 +isPrivate = true +isProtected = false +isPublic = false +privateWithin = <none> +============ +sym = class $ProtectedJavaClass, signature = ClassInfoType(...), owner = class JavaClass_1 +isPrivate = false +isProtected = true +isPublic = false +privateWithin = package foo +============ +sym = value this$0, signature = foo.JavaClass_1, owner = class $ProtectedJavaClass +isPrivate = false +isProtected = false +isPublic = false +privateWithin = package foo +============ +sym = object $ProtectedJavaClass, signature = JavaClass_1.this.$ProtectedJavaClass.type, owner = class JavaClass_1 +isPrivate = false +isProtected = false +isPublic = false +privateWithin = package foo +============ +sym = class $PublicJavaClass, signature = ClassInfoType(...), owner = class JavaClass_1 +isPrivate = false +isProtected = false +isPublic = true +privateWithin = <none> +============ +sym = constructor $PublicJavaClass, signature = (x$1: foo.JavaClass_1)JavaClass_1.this.$PublicJavaClass, owner = class $PublicJavaClass +isPrivate = false +isProtected = false +isPublic = true +privateWithin = <none> +============ +sym = value this$0, signature = foo.JavaClass_1, owner = class $PublicJavaClass +isPrivate = false +isProtected = false +isPublic = false +privateWithin = package foo +============ +sym = object $PublicJavaClass, signature = JavaClass_1.this.$PublicJavaClass.type, owner = class JavaClass_1 +isPrivate = false +isProtected = false +isPublic = true +privateWithin = <none> +============ +sym = constructor JavaClass_1, signature = ()foo.JavaClass_1, owner = class JavaClass_1 +isPrivate = false +isProtected = false +isPublic = true +privateWithin = <none> +============ +sym = object JavaClass_1, signature = foo.JavaClass_1.type, owner = package foo +isPrivate = false +isProtected = false +isPublic = true +privateWithin = <none> +============ +sym = class PrivateStaticJavaClass, signature = ClassInfoType(...), owner = object JavaClass_1 +isPrivate = true +isProtected = false +isPublic = false +privateWithin = <none> +============ +sym = object PrivateStaticJavaClass, signature = foo.JavaClass_1.PrivateStaticJavaClass.type, owner = object JavaClass_1 +isPrivate = true +isProtected = false +isPublic = false +privateWithin = <none> +============ +sym = class ProtectedStaticJavaClass, signature = ClassInfoType(...), owner = object JavaClass_1 +isPrivate = true +isProtected = false +isPublic = false +privateWithin = <none> +============ +sym = object ProtectedStaticJavaClass, signature = foo.JavaClass_1.ProtectedStaticJavaClass.type, owner = object JavaClass_1 +isPrivate = true +isProtected = false +isPublic = false +privateWithin = <none> +============ +sym = class PublicStaticJavaClass, signature = ClassInfoType(...), owner = object JavaClass_1 +isPrivate = false +isProtected = false +isPublic = true +privateWithin = <none> +============ +sym = constructor PublicStaticJavaClass, signature = ()foo.JavaClass_1.PublicStaticJavaClass, owner = class PublicStaticJavaClass +isPrivate = false +isProtected = false +isPublic = true +privateWithin = <none> +============ +sym = object PublicStaticJavaClass, signature = foo.JavaClass_1.PublicStaticJavaClass.type, owner = object JavaClass_1 +isPrivate = false +isProtected = false +isPublic = true +privateWithin = <none> +============ +sym = variable staticField, signature = Int, owner = object JavaClass_1 +isPrivate = true +isProtected = false +isPublic = false +privateWithin = <none> diff --git a/test/files/run/t6989/JavaClass_1.java b/test/files/run/t6989/JavaClass_1.java new file mode 100644 index 0000000000..eb26a08700 --- /dev/null +++ b/test/files/run/t6989/JavaClass_1.java @@ -0,0 +1,41 @@ +package foo; + +// Originally composed to accommodate pull request feedback, this test has +// uncovered a handful of bugs in FromJavaClassCompleter, namely: +// * SI-7071 non-public ctors get lost +// * SI-7072 inner classes are read incorrectly + +// I'm leaving the incorrect results of FromJavaClassCompleters in the check +// file, so that we get notified when something changes there. + +class PackagePrivateJavaClass { + private int privateField = 0; + protected int protectedField = 1; + public int publicField = 2; + + private static int privateStaticField = 3; + protected static int protectedStaticField = 4; + public static int publicStaticField = 5; + + private void privateMethod() {} + protected void protectedMethod() {} + public void publicMethod() {} + + private static void privateStaticMethod() {} + protected static void protectedStaticMethod() {} + public static void publicStaticMethod() {} + + private PackagePrivateJavaClass() {} + protected PackagePrivateJavaClass(int x) {} + public PackagePrivateJavaClass(int x, int y) {} +} + +public class JavaClass_1 { + private class PrivateJavaClass {} + private static class PrivateStaticJavaClass {} + protected class ProtectedJavaClass {} + private static class ProtectedStaticJavaClass {} + public class PublicJavaClass {} + public static class PublicStaticJavaClass {} + private static int staticField = 0; +}
\ No newline at end of file diff --git a/test/files/run/t6989/Test_2.scala b/test/files/run/t6989/Test_2.scala new file mode 100644 index 0000000000..e48e82422d --- /dev/null +++ b/test/files/run/t6989/Test_2.scala @@ -0,0 +1,42 @@ +import scala.reflect.runtime.universe._ + +// Originally composed to accommodate pull request feedback, this test has +// uncovered a handful of bugs in FromJavaClassCompleter, namely: +// * SI-7071 non-public ctors get lost +// * SI-7072 inner classes are read incorrectly + +// I'm leaving the incorrect results of FromJavaClassCompleters in the check +// file, so that we get notified when something changes there. + +package object foo { + def testAll(): Unit = { + test(typeOf[foo.PackagePrivateJavaClass].typeSymbol) + test(typeOf[foo.PackagePrivateJavaClass].typeSymbol.companionSymbol) + test(typeOf[foo.JavaClass_1].typeSymbol) + test(typeOf[foo.JavaClass_1].typeSymbol.companionSymbol) + } + + def test(sym: Symbol): Unit = { + printSymbolDetails(sym) + if (sym.isClass || sym.isModule) { + sym.typeSignature.declarations.toList.sortBy(_.name.toString) foreach test + } + } + + def printSymbolDetails(sym: Symbol): Unit = { + def stableSignature(sym: Symbol) = sym.typeSignature match { + case ClassInfoType(_, _, _) => "ClassInfoType(...)" + case tpe => tpe.toString + } + println("============") + println(s"sym = $sym, signature = ${stableSignature(sym)}, owner = ${sym.owner}") + println(s"isPrivate = ${sym.isPrivate}") + println(s"isProtected = ${sym.isProtected}") + println(s"isPublic = ${sym.isPublic}") + println(s"privateWithin = ${sym.privateWithin}") + } +} + +object Test extends App { + foo.testAll() +}
\ No newline at end of file diff --git a/test/files/run/t7064-old-style-supercalls.check b/test/files/run/t7064-old-style-supercalls.check deleted file mode 100644 index 0cfbf08886..0000000000 --- a/test/files/run/t7064-old-style-supercalls.check +++ /dev/null @@ -1 +0,0 @@ -2 diff --git a/test/files/run/t7064-old-style-supercalls.scala b/test/files/run/t7064-old-style-supercalls.scala deleted file mode 100644 index cffa7b1888..0000000000 --- a/test/files/run/t7064-old-style-supercalls.scala +++ /dev/null @@ -1,48 +0,0 @@ -import scala.reflect.runtime.universe._ -import Flag._ -import definitions._ -import scala.reflect.runtime.{currentMirror => cm} -import scala.tools.reflect.ToolBox -import scala.tools.reflect.Eval - -object Test extends App { - val PARAMACCESSOR = (1L << 29).asInstanceOf[FlagSet] - - // these trees can be acquired by running the following incantation: - // echo 'class C(val x: Int); class D extends C(2)' > foo.scala - // ./scalac -Xprint:parser -Yshow-trees-stringified -Yshow-trees-compact foo.scala - - val c = ClassDef( - Modifiers(), newTypeName("C"), List(), - Template( - List(Select(Ident(ScalaPackage), newTypeName("AnyRef"))), - emptyValDef, - List( - ValDef(Modifiers(PARAMACCESSOR), newTermName("x"), Ident(newTypeName("Int")), EmptyTree), - DefDef( - Modifiers(), - nme.CONSTRUCTOR, - List(), - List(List(ValDef(Modifiers(PARAM | PARAMACCESSOR), newTermName("x"), Ident(newTypeName("Int")), EmptyTree))), - TypeTree(), - Block( - List(Apply(Select(Super(This(tpnme.EMPTY), tpnme.EMPTY), nme.CONSTRUCTOR), List())), - Literal(Constant(()))))))) - val d = ClassDef( - Modifiers(), newTypeName("D"), List(), - Template( - List(Ident(newTypeName("C"))), - emptyValDef, - List( - DefDef( - Modifiers(), - nme.CONSTRUCTOR, - List(), - List(List()), - TypeTree(), - Block( - List(Apply(Select(Super(This(tpnme.EMPTY), tpnme.EMPTY), nme.CONSTRUCTOR), List(Literal(Constant(2))))), - Literal(Constant(()))))))) - val result = Select(Apply(Select(New(Ident(newTypeName("D"))), nme.CONSTRUCTOR), List()), newTermName("x")) - println(cm.mkToolBox().eval(Block(List(c, d), result))) -}
\ No newline at end of file diff --git a/test/files/run/test-cpp.scala b/test/files/run/test-cpp.scala index 5b3bc7b746..f9fa85c4d0 100644 --- a/test/files/run/test-cpp.scala +++ b/test/files/run/test-cpp.scala @@ -3,7 +3,7 @@ * in the copy-propagation performed before ClosureElimination. * * In the general case, the local variable 'l' is connected through - * a alias chain with other local variables and at the end of the + * an alias chain with other local variables and at the end of the * alias chain there may be a Value, call it 'v'. * * If 'v' is cheaper to access (it is a Deref(This) or Const(_)), then diff --git a/test/files/run/toolbox_typecheck_implicitsdisabled.scala b/test/files/run/toolbox_typecheck_implicitsdisabled.scala index 8a3d433142..95a7056279 100644 --- a/test/files/run/toolbox_typecheck_implicitsdisabled.scala +++ b/test/files/run/toolbox_typecheck_implicitsdisabled.scala @@ -7,16 +7,16 @@ object Test extends App { val toolbox = cm.mkToolBox() val tree1 = Block(List( - Import(Select(Ident(newTermName("scala")), newTermName("Predef")), List(ImportSelector(nme.WILDCARD, -1, null, -1)))), - Apply(Select(Literal(Constant(1)), newTermName("$minus$greater")), List(Literal(Constant(2)))) + Import(Select(Ident(TermName("scala")), TermName("Predef")), List(ImportSelector(nme.WILDCARD, -1, null, -1)))), + Apply(Select(Literal(Constant(1)), TermName("$minus$greater")), List(Literal(Constant(2)))) ) val ttree1 = toolbox.typeCheck(tree1, withImplicitViewsDisabled = false) println(ttree1) try { val tree2 = Block(List( - Import(Select(Ident(newTermName("scala")), newTermName("Predef")), List(ImportSelector(nme.WILDCARD, -1, null, -1)))), - Apply(Select(Literal(Constant(1)), newTermName("$minus$greater")), List(Literal(Constant(2)))) + Import(Select(Ident(TermName("scala")), TermName("Predef")), List(ImportSelector(nme.WILDCARD, -1, null, -1)))), + Apply(Select(Literal(Constant(1)), TermName("$minus$greater")), List(Literal(Constant(2)))) ) val ttree2 = toolbox.typeCheck(tree2, withImplicitViewsDisabled = true) println(ttree2) diff --git a/test/files/run/toolbox_typecheck_macrosdisabled.scala b/test/files/run/toolbox_typecheck_macrosdisabled.scala index 51eb63f294..1f7fda8575 100644 --- a/test/files/run/toolbox_typecheck_macrosdisabled.scala +++ b/test/files/run/toolbox_typecheck_macrosdisabled.scala @@ -15,11 +15,11 @@ object Test extends App { val ru = build.newFreeTerm("ru", scala.reflect.runtime.universe) build.setTypeSignature(ru, rutpe) - val tree1 = Apply(Select(Ident(ru), newTermName("reify")), List(Literal(Constant(2)))) + val tree1 = Apply(Select(Ident(ru), TermName("reify")), List(Literal(Constant(2)))) val ttree1 = toolbox.typeCheck(tree1, withMacrosDisabled = false) println(ttree1) - val tree2 = Apply(Select(Ident(ru), newTermName("reify")), List(Literal(Constant(2)))) + val tree2 = Apply(Select(Ident(ru), TermName("reify")), List(Literal(Constant(2)))) val ttree2 = toolbox.typeCheck(tree2, withMacrosDisabled = true) println(ttree2) } diff --git a/test/files/run/toolbox_typecheck_macrosdisabled2.check b/test/files/run/toolbox_typecheck_macrosdisabled2.check index f5c9b6eeab..74dfb03666 100644 --- a/test/files/run/toolbox_typecheck_macrosdisabled2.check +++ b/test/files/run/toolbox_typecheck_macrosdisabled2.check @@ -19,7 +19,7 @@ def apply[U <: scala.reflect.api.Universe with Singleton]($m$untyped: scala.reflect.api.Mirror[U]): U#Tree = { val $u: U = $m$untyped.universe; val $m: $u.Mirror = $m$untyped.asInstanceOf[$u.Mirror]; - $u.Apply.apply($u.Select.apply($u.Select.apply($u.build.Ident($m.staticPackage("scala")), $u.newTermName("Array")), $u.newTermName("apply")), scala.collection.immutable.List.apply[$u.Literal]($u.Literal.apply($u.Constant.apply(2)))) + $u.Apply.apply($u.Select.apply($u.Select.apply($u.build.Ident($m.staticPackage("scala")), $u.TermName.apply("Array")), $u.TermName.apply("apply")), scala.collection.immutable.List.apply[$u.Literal]($u.Literal.apply($u.Constant.apply(2)))) } }; new $treecreator1() diff --git a/test/files/run/toolbox_typecheck_macrosdisabled2.scala b/test/files/run/toolbox_typecheck_macrosdisabled2.scala index 74fd09d9fd..7bfe3ba8a4 100644 --- a/test/files/run/toolbox_typecheck_macrosdisabled2.scala +++ b/test/files/run/toolbox_typecheck_macrosdisabled2.scala @@ -15,11 +15,11 @@ object Test extends App { val ru = build.newFreeTerm("ru", scala.reflect.runtime.universe) build.setTypeSignature(ru, rutpe) - val tree1 = Apply(Select(Ident(ru), newTermName("reify")), List(Apply(Select(Ident(newTermName("scala")), newTermName("Array")), List(Literal(Constant(2)))))) + val tree1 = Apply(Select(Ident(ru), TermName("reify")), List(Apply(Select(Ident(TermName("scala")), TermName("Array")), List(Literal(Constant(2)))))) val ttree1 = toolbox.typeCheck(tree1, withMacrosDisabled = false) println(ttree1) - val tree2 = Apply(Select(Ident(ru), newTermName("reify")), List(Apply(Select(Ident(newTermName("scala")), newTermName("Array")), List(Literal(Constant(2)))))) + val tree2 = Apply(Select(Ident(ru), TermName("reify")), List(Apply(Select(Ident(TermName("scala")), TermName("Array")), List(Literal(Constant(2)))))) val ttree2 = toolbox.typeCheck(tree2, withMacrosDisabled = true) println(ttree2) } |